Skip to content

[WIP] [NeedsAcceptOrRejectFromWalter] Move standard library config to dmd.conf#9944

Closed
marler8997 wants to merge 1 commit intodlang:masterfrom
marler8997:genconf
Closed

[WIP] [NeedsAcceptOrRejectFromWalter] Move standard library config to dmd.conf#9944
marler8997 wants to merge 1 commit intodlang:masterfrom
marler8997:genconf

Conversation

@marler8997
Copy link
Copy Markdown
Contributor

@marler8997 marler8997 commented Jun 2, 2019

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.d which will use the logic to generate dmd.conf.

This moves the responsibility of configuring the standard library out of the compiler into an external tool.

@dlang-bot dlang-bot added the Review:WIP Work In Progress - not ready for review or pulling label Jun 2, 2019
@dlang-bot
Copy link
Copy Markdown
Contributor

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 verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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 references

Your 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 locally

If 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"

@marler8997 marler8997 changed the title [WIP] Move more config to dmd.conf [WIP] Move standard library config dmd.conf Jun 2, 2019
@marler8997 marler8997 changed the title [WIP] Move standard library config dmd.conf [WIP] Move standard library config to dmd.conf Jun 2, 2019
flags ~= " -I%@P%/../../../../../phobos";
flags ~= " -L-L%@P%/../../../../../phobos/generated/{os}/{build}/{model}";

if (os == "windows")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FreeBSD? Also use a switch for this.

@thewilsonator
Copy link
Copy Markdown
Contributor

Is makedmdconf meant to be at top level? Also should we make a /build/ directory for this, src/build.d and whatever else you're going to add in the future? src is already very crowded and unfortunately likely wont change soon.

@marler8997
Copy link
Copy Markdown
Contributor Author

It's similar to config.d which is also at the top level, except config.d generates the version file.

@marler8997 marler8997 force-pushed the genconf branch 11 times, most recently from 010f6d2 to 6a8b776 Compare June 2, 2019 14:57
Copy link
Copy Markdown
Contributor

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is a net win as it adds a lot more code to remove a duplication which hardly ever changes.
Also,

  1. Not sure why we always need to rebuild dmd.conf
  2. Windows uses sc.ini for 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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (os == "osx")
else if (os == "osx")

}
else
mkdirRecurse(path.dirName);
std.file.write(path, content);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be shorter:

Suggested change
std.file.write(path, content);
content.toFile(path);

target: target,
name: "(TX) DMD_CONF",
commandFunction: commandFunction,
string[] options = new string[0];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe name this clearer: forceRebuild

auto helpInfo = getopt(args,
"mscoff", &mscoff);
enum nonOptionArgCount = 3;
const wrongArgCount = (args.length != nonOptionArgCount + 1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Not a good style to use the first person in remarks as no one knows immediately who you are
  2. 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@marler8997
Copy link
Copy Markdown
Contributor Author

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.

@marler8997 marler8997 changed the title [WIP] Move standard library config to dmd.conf [WIP] [NeedsAcceptOrRejectFromWalter] Move standard library config to dmd.conf Jun 3, 2019
@thewilsonator
Copy link
Copy Markdown
Contributor

cc @WalterBright

import std.path, std.file, std.stdio;
import std.process;

int main(string[] args)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@marler8997
Copy link
Copy Markdown
Contributor Author

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.

@marler8997
Copy link
Copy Markdown
Contributor Author

Cleaning up old PRs that aren't going anywhere.

@marler8997 marler8997 closed this May 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:WIP Work In Progress - not ready for review or pulling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants