Skip to content
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

Merged
merged 1 commit into from
Jan 18, 2022

Conversation

MoonlightSentinel
Copy link
Contributor

@MoonlightSentinel MoonlightSentinel commented Jan 18, 2022

  • 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

This is also a workaround because dlang/installer#492 broke the nightlies

@dlang-bot
Copy link
Contributor

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

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • 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 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")
Copy link
Member

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

Copy link
Contributor Author

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

dmd/src/build.d

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`)];
}

Copy link
Member

Choose a reason for hiding this comment

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

ok lets merge

Copy link
Member

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

Copy link
Contributor Author

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
@MoonlightSentinel MoonlightSentinel changed the title build.d: Ignore ENABLE_LTO when building with dmd build.d: Properly translate ENABLE_LTO for other compilers than LDC Jan 18, 2022
@dlang-bot dlang-bot merged commit ad2621a into dlang:master Jan 18, 2022
@MoonlightSentinel MoonlightSentinel deleted the ci/ignore-lto branch January 28, 2022 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants