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

LLVM-based cross compilation #36867

Closed
Ericson2314 opened this issue Mar 12, 2018 · 8 comments
Closed

LLVM-based cross compilation #36867

Ericson2314 opened this issue Mar 12, 2018 · 8 comments
Labels
6.topic: cross-compilation Building packages on a different platform than they will be used on
Milestone

Comments

@Ericson2314
Copy link
Member

LLVM is a much nicer for cross compilation. It has been multi-target for the vast majority, and its associated runtime libraries (e.g. compiler-rt, libcxx) are readily built separately from the compiler itself.

Unfortunately, our current packaging doesn't take advantage of either of these. We build compiler-rt in the same derivation as LLVM, and we pull everything from the same boostrappping stage, precluding cross compilation infra from working its magic.

I took a stab at this in obsidiansystems@acf2ed5 (the top commit in https://github.com/obsidiansystems/nixpkgs/tree/split-compiler-rt). I should get around to at least rebasing that, but even in its current state that serves as a basic reference to what should be accomplished.


CC @angerman @dtzWill

@Ericson2314 Ericson2314 added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Mar 12, 2018
@Mic92
Copy link
Member

Mic92 commented Mar 14, 2018

Too bad it still cannot build the kernel: https://lwn.net/Articles/734071/

@eternaleye
Copy link

eternaleye commented Mar 15, 2018

@Mic92: Um, to quote the article:

This work has shown that the FUD surrounding using a new toolchain for the kernel is unfounded, Desaulniers said. It is working now, but there are a few asterisks. Clang, the front end, can compile the kernel, but the assembler and the linker from GNU Binutils are needed to complete the build process.

(emphasis mine)

Reducing the use of gcc down to using gas for the kernel (rather than the full stack for everything) is pretty big in its own right, and using binutils' ld will likely be needed in various cases for a while anyway as lld gets up to speed.

In addition, this mail from one month later claims that the gas requirement boils down to this bug affecting x86, and works on other architectures (such as arm64).

Further improvement has likely occurred in the four months since then.

@Ericson2314
Copy link
Member Author

Anyways, the point of this is to change how we package LLVM. Once we do that, we'll be able to attempt cross compiling any package we want, including Linux. Getting Linux to build with LLVM is an orthogonal concern.

@wmertens
Copy link
Contributor

Does this mean your ultimate goal is to only build Nixpkgs with LLVM? Because that seems untenable :-/

@eternaleye
Copy link

@wmertens I'd argue that using clang, libc++, etc. would count as a distinct cross target - one potentially easier/simpler/cleaner to bootstrap.

@Ericson2314
Copy link
Member Author

@wmertens No. I want to support as many combinations as we can without a a soup of conditionals. What we choose to support via CI resources I'll happily leave to others. Compare to NixOS/rfcs#23 not being about ditching glibc.

@Ericson2314
Copy link
Member Author

@eternaleye Today, compiler and libc++ choices don't require a different platform name, but they could. libc ones do with -musl vs -gnu, for example, and in any event, the hashes will reflect the change like any other dependency change.

@matthewbauer
Copy link
Member

@Ericson2314 Can this be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: cross-compilation Building packages on a different platform than they will be used on
Projects
None yet
Development

No branches or pull requests

5 participants