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

Add mingwW64-llvm cross-system. #171418

Merged
merged 18 commits into from
May 18, 2022
Merged

Add mingwW64-llvm cross-system. #171418

merged 18 commits into from
May 18, 2022

Conversation

shlevy
Copy link
Member

@shlevy shlevy commented May 3, 2022

This adds a new cross system targeting mingwW64 + ucrt using an llvm-based toolchain.

Similar in spirit to and inspired by @mstorsjo's https://github.com/mstorsjo/llvm-mingw.

Among other benefits of LLVM + ucrt, this will be necessary to build a GHC compiler targeting Windows in 9.4 or later.

@shlevy
Copy link
Member Author

shlevy commented May 3, 2022

Easiest reviewed commit-wise.

@Mindavi Mindavi added 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: windows Running, or buiding, packages on Windows labels May 3, 2022
@ofborg ofborg bot requested review from lovek323, 7c6f434c, dtzWill and primeos May 3, 2022 17:28
@Ericson2314
Copy link
Member

This generally looks good to me. It looks like you made some attempt to backport changes to older LLVMs to keep things consistent? That's good. I asked @sternenseemann to review too. There's a lot of new passthru items and I think they are OK, but it's a good thing to get a second set of eyes upon.

@shlevy
Copy link
Member Author

shlevy commented May 4, 2022

@Ericson2314 llvm 14 is not yet working fully, so this actually uses 13 by default. I forward-ported the changes to 14 so they won't get lost as llvm gets upgraded

pkgs/development/compilers/llvm/13/bintools/default.nix Outdated Show resolved Hide resolved
@@ -17,6 +17,7 @@
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
, buildPackages ? {}
, libcxx ? null
, isCompilerRT ? false
Copy link
Member

Choose a reason for hiding this comment

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

Isn't useLLVM the only way to get a compiler-rt stdenv.cc at the moment? stdenv.hostPlatform.useLLVM or false should also be a feasible replacement.

This disambiguator is probably useful regardless, but I'm wondering if we should be conservative about what we tack on here and if there's possibly a better system for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, you can use this with llvmPackages.tools.clangUseLLVM etc.

Probably there is a better system. e.g. something like compiler-rt is perhaps plausibly an attribute of the platform (if it's required to be consistent across libraries and executables being linked together) whereas something like the linker really isn't (at least on platforms where there are multiple interchangeable linkers). But I'd prefer to separate out these improvements to how these are handled from the functional addition in this PR, unless there's a better current alternative.

Copy link
Member

Choose a reason for hiding this comment

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

@sternenseemann yeah I think this is good too. useLLVM is kind of a sledge hammer when we ought to support more mix and match. I would not be opposed to specifying the default like we do for the linker in the platform description, but non-default compilers can do different things so we can track in the wrapper too.

"-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE"
"-DLIBCXX_CXX_ABI_LIBRARY_PATH=${libcxxabi}/lib"
] ++ lib.optional (!headersOnly && libcxxabi.useLLVMUnwinder)
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON";
Copy link
Member

Choose a reason for hiding this comment

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

Curious about this; libcxx/CMakeLists.txt claims this is only about linking the test cases which we don't run.

Copy link
Member Author

Choose a reason for hiding this comment

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

I got link errors without this, I wouldn't be surprised if it's only needed when LIBCXX_ENABLE_STATIC_ABI_LIBRARY (which is narrowly tested).

Copy link
Member

@Ericson2314 Ericson2314 May 7, 2022

Choose a reason for hiding this comment

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

In which versions, @sternenseemann? I don't see that in LLVM 13's libcxx/CMakeLists.txt.

Copy link
Member

Choose a reason for hiding this comment

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

@sternenseemann
Copy link
Member

I forward-ported the changes to 14 so they won't get lost as llvm gets upgraded

You should do llvmPackages_git as well then.

@shlevy
Copy link
Member Author

shlevy commented May 4, 2022

This will now be a mass rebuild on llvm systems, will rebase on staging once all open issues are addressed

shlevy added 14 commits May 9, 2022 10:03
This is expected e.g. by the GHC cross-compilation code
libtool upstream seems quite slow to merge...
By specifying pkgs.libffi here instead of letting callPackage handle
it, we confuse the splicing logic and put the host libffi into
NIX_LDFLAGS_FOR_TARGET. This previously hasn't been a problem, as we
also pass an explicit configure flag pointing to the target libffi,
and so the only side-effect is a senseless -rpath flag.

ld.lld (rightly) does not recognize the -rpath flag when targeting
Windows, however, so this causes build failures.
@shlevy shlevy requested review from Ericson2314 and removed request for expipiplus1 May 9, 2022 14:18
@shlevy
Copy link
Member Author

shlevy commented May 9, 2022

@Ericson2314 @sternenseemann OK looks like I've addressed all outstanding issues, any remaining concerns?

@shlevy
Copy link
Member Author

shlevy commented May 16, 2022

@Ericson2314 @sternenseemann Any further thoughts?

@shlevy shlevy merged commit 0f68ed1 into NixOS:staging May 18, 2022
@shlevy shlevy deleted the mingwW64-clang branch May 18, 2022 10:31
@sternenseemann
Copy link
Member

Can you revert this merge, please? The second staging-next iteration for 22.05 has not yet started and LLVM is considered release critical, so potentially breaking changes are disallowed. See also #165792

I'd also like to have another look, didn't find the time in the last week unfortunately.

@Ericson2314
Copy link
Member

Is there some way we can contort this to be a non-mass-rebuild just for 22.05?

@shlevy
Copy link
Member Author

shlevy commented May 18, 2022

@sternenseemann Ah I didn't realize staging-next was restricted. This should be documented in the nixpkgs manual, currently it suggests that merging staging into staging-next when the latter is already in master (as it is now) is fine to do.

@shlevy
Copy link
Member Author

shlevy commented May 18, 2022

@Ericson2314 We could make the libtool patching conditional. Any strong reason to do so?

@shlevy
Copy link
Member Author

shlevy commented May 18, 2022

PR to add this back in up at #173498

@angerman angerman mentioned this pull request Sep 8, 2023
12 tasks
@rrbutani rrbutani added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants