[WIP] [NeedsAcceptOrRejectFromWalter] Move standard library config to dmd.conf#9944
[WIP] [NeedsAcceptOrRejectFromWalter] Move standard library config to dmd.conf#9944marler8997 wants to merge 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request and interest in making D better, @marler8997! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. 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. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#9944" |
| flags ~= " -I%@P%/../../../../../phobos"; | ||
| flags ~= " -L-L%@P%/../../../../../phobos/generated/{os}/{build}/{model}"; | ||
|
|
||
| if (os == "windows") |
There was a problem hiding this comment.
FreeBSD? Also use a switch for this.
|
Is |
|
It's similar to |
010f6d2 to
6a8b776
Compare
wilzbach
left a comment
There was a problem hiding this comment.
Not sure this is a net win as it adds a lot more code to remove a duplication which hardly ever changes.
Also,
- Not sure why we always need to rebuild
dmd.conf - Windows uses
sc.inifor weird historic reasons, so for this PR at least I would focus on making makedmdconf.d work solely for Posix.
| } | ||
| } | ||
|
|
||
| if (os == "linux" || os == "freebsd" || os == "openbsd" || os == "solaris" || os == "dragonflybsd") |
There was a problem hiding this comment.
| if (os == "linux" || os == "freebsd" || os == "openbsd" || os == "solaris" || os == "dragonflybsd") | |
| else if (os == "linux" || os == "freebsd" || os == "openbsd" || os == "solaris" || os == "dragonflybsd") |
| } | ||
| if (os == "linux") | ||
| sharedflags ~= " -L-lpthread -L-lm -L-ldl -L-lrt"; | ||
| if (os == "osx") |
There was a problem hiding this comment.
| if (os == "osx") | |
| else if (os == "osx") |
| } | ||
| else | ||
| mkdirRecurse(path.dirName); | ||
| std.file.write(path, content); |
There was a problem hiding this comment.
Could be shorter:
| std.file.write(path, content); | |
| content.toFile(path); |
| target: target, | ||
| name: "(TX) DMD_CONF", | ||
| commandFunction: commandFunction, | ||
| string[] options = new string[0]; |
There was a problem hiding this comment.
| string[] options = new string[0]; | |
| string[] options; |
There's no difference and the appends below will trigger a resize allocation anyhow.
| void delegate() commandFunction; // a custom dependency command which gets called instead of command | ||
| string name; // name of the dependency that is e.g. written to the CLI when it's executed | ||
| string[] trackSources; | ||
| bool forceOutOfDate; // always runs the command |
There was a problem hiding this comment.
maybe name this clearer: forceRebuild
| auto helpInfo = getopt(args, | ||
| "mscoff", &mscoff); | ||
| enum nonOptionArgCount = 3; | ||
| const wrongArgCount = (args.length != nonOptionArgCount + 1); |
There was a problem hiding this comment.
Better make all of these required arguments flags, then the user gets a better error message and you can let getopt do its job.
This will also help when in the future more flags get added (or removed).
|
|
||
| sharedflags ~= " -I%@P%/../../../../../druntime/import"; | ||
| sharedflags ~= " -I%@P%/../../../../../phobos"; | ||
| model32flags ~= " -L-L%@P%/../../../../../phobos/generated/{os}/{build}/32"; |
There was a problem hiding this comment.
| model32flags ~= " -L-L%@P%/../../../../../phobos/generated/{os}/{build}/32"; | |
| string model32flags = " -L-L%@P%/../../../../../phobos/generated/{os}/{build}/32"; |
| sharedflags ~= " -I%@P%/../../../../../druntime/import"; | ||
| sharedflags ~= " -I%@P%/../../../../../phobos"; | ||
| model32flags ~= " -L-L%@P%/../../../../../phobos/generated/{os}/{build}/32"; | ||
| model64flags ~= " -L-L%@P%/../../../../../phobos/generated/{os}/{build}/64"; |
There was a problem hiding this comment.
| model64flags ~= " -L-L%@P%/../../../../../phobos/generated/{os}/{build}/64"; | |
| string model64flags = " -L-L%@P%/../../../../../phobos/generated/{os}/{build}/64"; |
| string model32flags = ""; | ||
| string model64flags = ""; | ||
|
|
||
| sharedflags ~= " -I%@P%/../../../../../druntime/import"; |
There was a problem hiding this comment.
| sharedflags ~= " -I%@P%/../../../../../druntime/import"; | |
| string sharedflags = " -I%@P%/../../../../../druntime/import"; |
|
|
||
| if (os == "windows") | ||
| { | ||
| // NOTE: I don't think I need to add user32/kernel32 because I think the |
There was a problem hiding this comment.
- Not a good style to use the first person in remarks as no one knows immediately who you are
- Let's better verify before we add such comments. Currently, the sc.ini isn't generated for Windows, but the release sc.ini doesn't look like it needs this: https://github.com/dlang/dmd/blob/master/ini/windows/bin/sc.ini
There was a problem hiding this comment.
Yeah the plan isn't to merge this comment, it's to let me and reviewers know it's something that needs to be addressed before merging.
|
Right now @WalterBright has questioned whether moving the hard-coded information out of the compiler is justified. I explained the reasoning here #9936 (comment) . If he says no, then this PR and that PR will be axed, so I wouldn't spend any time reviewing these two until then. |
| import std.path, std.file, std.stdio; | ||
| import std.process; | ||
|
|
||
| int main(string[] args) |
There was a problem hiding this comment.
I'd prefer to have this file integrated into build.d as a new target. The logic for determining whether or not the target needs to be generated and the OS detection logic is already there, and I don't see much of a use case for generating the dmd.conf file outside of a typical build. The makefile can also generate the dmd.conf file by simply calling build.d conf (or whatever the target is called).
|
Probably makes sense. It's been too long I don't remember why I originally put it in its own file now. Still waiting on Walter to respond in #9936 though. He raised concerns on whether moving config to the dmd.conf file is justified. I explained the reasons I am aware of but he hasn't responded yet. |
|
Cleaning up old PRs that aren't going anywhere. |
This is a pre-requisite working towards moving the hard-coded standard library configuration out of the compiler (#9936).
This PR moves the logic to determine linker flags for the standard library from the compiler to the tool
makedmdconf.dwhich will use the logic to generatedmd.conf.This moves the responsibility of configuring the standard library out of the compiler into an external tool.