-
-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build.d: Properly translate ENABLE_LTO for other compilers than LDC #13548
Conversation
Thanks for your pull request and interest in making D better, @MoonlightSentinel! 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 run digger -- build "master + dmd#13548" |
src/build.d
Outdated
@@ -1230,7 +1230,10 @@ void processEnvironment() | |||
} | |||
if (env.getNumberedBool("ENABLE_LTO")) | |||
{ | |||
dflags ~= ["-flto=full"]; | |||
if (env["HOST_DMD_KIND"] == "dmd") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is ldmd considered a different kind? If yes, then LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, HOST_DMD_KIND
is set to either dmd
, ldc
or gdc
based on the actual compiler.
See
Lines 1159 to 1195 in 019e5c3
const hostDmdInfo = [env["HOST_DMD_RUN"], `-Xi=compilerInfo`, `-Xf=-`].execute(); | |
if (hostDmdInfo.status) // Failed, JSON output currently not supported for GDC | |
{ | |
env["HOST_DMD_KIND"] = "gdc"; | |
env["HOST_DMD_VERSION"] = "v2.076"; | |
} | |
else | |
{ | |
/// Reads the content of a single field without parsing the entire JSON | |
alias get = field => hostDmdInfo.output | |
.findSplitAfter(field ~ `" : "`)[1] | |
.findSplitBefore(`"`)[0]; | |
const ver = env["HOST_DMD_VERSION"] = get(`version`)[1 .. "vX.XXX.X".length]; | |
// Vendor was introduced in 2.080 | |
if (ver < "2.080.1") | |
{ | |
auto name = get("binary").baseName().stripExtension(); | |
if (name == "ldmd2") | |
name = "ldc"; | |
else if (name == "gdmd") | |
name = "gdc"; | |
else | |
enforce(name == "dmd", "Unknown compiler: " ~ name); | |
env["HOST_DMD_KIND"] = name; | |
} | |
else | |
{ | |
env["HOST_DMD_KIND"] = [ | |
"Digital Mars D": "dmd", | |
"LDC": "ldc", | |
"GNU D": "gdc" | |
][get(`vendor`)]; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok lets merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually GDC doesn't want the full part so maybe another branch is required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, it will now use -flto
for GDC
- Uses `-flto` when building with GDC - Issues a warning that DMD does not support LTO instead of failing due to the unknown flag -flto=full
f8d4ea5
to
35b8618
Compare
-flto
when building with GDCThis is also a workaround because dlang/installer#492 broke the nightlies