Move addDefaultVersionIdentifiers from mars.d to compiler.d#7524
Move addDefaultVersionIdentifiers from mars.d to compiler.d#7524RazvanN7 wants to merge 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
src/dmd/compiler.d
Outdated
|
|
||
| VersionCondition.addPredefinedGlobalIdent("D_HardFloat"); | ||
|
|
||
| printPredefinedVersions(); |
There was a problem hiding this comment.
Hmmm we should we really do this by default in this method?
How about moving printPredefinedVersions back to mars.d?
There was a problem hiding this comment.
It's ok to let it there since the printPredefined versions has all it's code in a block nested by a if (global.params.verbose)
There was a problem hiding this comment.
printPredefinedVersions() has nothing to do with addDefaultVersionIdentifiers() - note that no mention of it is made in the Ddoc comment - it should not be called here.
| else | ||
| static assert(0, "OS not supported yet."); | ||
|
|
||
| addDefaultVersionIdentifiers(); |
There was a problem hiding this comment.
You can now remove the OS detection above :)
I had to make a copy of this as addDefaultVersionIdentifiers was private and I wanted to keep the changes to a minimum in the initial version.
src/dmd/compiler.d
Outdated
| * Note that if `-defaultlib=` or `-debuglib=` was used, | ||
| * we don't override that either. | ||
| */ | ||
| void setDefaultLibrary() |
There was a problem hiding this comment.
Not sure whether this can be re-used by other compilers or the frontend. It looks fairly specific to DMD.
|
Note that there's this PR as well #7485. |
d2dcbf6 to
52b32f5
Compare
ab00dd9 to
26d0f14
Compare
|
@RazvanN7 this needs another rebase |
| else | ||
| static assert(0, "OS not supported yet."); | ||
|
|
||
| addDefaultVersionIdentifiers(); |
There was a problem hiding this comment.
printPredefinedVersions() call should go here.
| else version(OpenBSD) | ||
| global.params.isOpenBSD = 1; | ||
| else | ||
| static assert(0, "OS not supported yet."); |
There was a problem hiding this comment.
I see all this is deleted, but I don't see where it is moved to?
There was a problem hiding this comment.
Now that addDefaultVersionIdentifiers is called there is no need to do that since the code was duplicated from it initially.
26d0f14 to
c78f166
Compare
10c5634 to
70c010f
Compare
|
@wilzbach I addressed the issues. I think we're good to go. I had to add |
fd14a30 to
eb4ad41
Compare
Hmm, that's strange. The only file in the |
|
Furthermore, globals.d imports compiler.d which for the sake of |
|
I'll remove the import of dmd.compiler from the globals module tomorrow. |
|
Shouldn't this be moved to a module like (Saying that, however, the compiler module won't be shared code). |
| static assert(0, "OS not supported yet."); | ||
|
|
||
| addDefaultVersionIdentifiers(); | ||
| printPredefinedVersions(); |
There was a problem hiding this comment.
Are we sure that we want to call printPredefinedVersions here at all?
After all, this is the frontend for DMD as a library code.
You shouldn't need to add #7534 (comment)
|
|
@WalterBright ok with you? |
eb4ad41 to
55a73ff
Compare
| } | ||
| } | ||
| ======= | ||
| >>>>>>> Move addDefaultVersionIdentifiers to frontend.d |
There was a problem hiding this comment.
looks like some conflict made it into the pr
| static if (TARGET_WINDOS) | ||
| { | ||
| VersionCondition.addPredefinedGlobalIdent("Windows"); | ||
| global.params.isWindows = true; |
There was a problem hiding this comment.
This line should really not be here. "Setting predefined identifiers" and "setting the target platform in global" should be in different functions.
| VersionCondition.addPredefinedGlobalIdent("D_Version2"); | ||
| VersionCondition.addPredefinedGlobalIdent("all"); | ||
|
|
||
| if (global.params.cpu >= CPU.sse2) |
There was a problem hiding this comment.
Note how this section is using global to set versions, whereas the previous section used TARGET to set it. Using TARGET to set global should be in a separate function, then this function should rely only on global to set versions.
There was a problem hiding this comment.
Furthermore, instead of accessing global as a global variable, consider passing a const reference to it to the function.
| } | ||
| else | ||
| { | ||
| static assert(0, "fix this"); |
There was a problem hiding this comment.
Fixing a static assert failure is implied, so the message adds no value. "unsupported target" might be better.
|
Moving those functions to compiler.d is not a good idea. |
The frontend interface of the compiler library needs to do some initialization which is done in dmd/mars.d. In order to use initialization methods from mars.d there are 3 options:
(1), (2) are obviously bad solutions, so this PR implements (3)