Skip to content

[CFP] LLVM toolchains in Nixpkgs #20

Description

@Ericson2314

Title

LLVM toolchains in Nixpkgs

Author

John Ericson, John.Ericson@Obsidian.Systems, Obsidian Systems

Distribution

Nixpkgs is best known the package set behind the NixOS Linux distribution, but also runs on macOS, and arbitrary cross compilation. LLVM is used on macOS by default, and may be used for any platform; recently we've added a pkgsLLVM to encourage LLVM use in more contexts.

Abstract (optional)

About 5 years ago, we in the Nix community set out to be one of the few distros/package sets to support whole-system cross compilation, meaning not just providing cross toolchains, but also building arbitrary packages. Overhauling our infrastructure to do this, we found that the packaging of compilers was the keystone upon which many of our out decisions rested. To cut down complexity, we decided to strive for a few related polices:

  • Make cross compilation the default, native compilation should "just" be cross compilation such that "build = host".
  • Packages shouldn't manage their own bootstrapping, the distro should.
  • Compilers and run-times should be built separately, so every package installs artifacts just for one platform
  • Runtime libraries should be "unspecial" --- like any other library --- at least one building.

LLVM has easily been the compiler most amendable to re-package according to these principles. We want to highlight what has gone well, the current state of the LLVM packaging in Nixpkgs, and what we are trying to get upstreamed into LLVM next.

What's unique about the environment you package LLVM for?

Very open-world goals --- Nixpkgs aims to be the "universal" package set, running or cross compiling everywhere possible. All the other cross compilation targets being discussed --- we're listening and want to support your platform too, no matter how exotic!

What makes your distribution of LLVM unique? (optional)

Very fine-grained, with all runtime libraries and tools being built separately, and installed in separate prefixes.

What might others learn from your experience? (optional)

Techniques to manage many configurations / bootstraps without drowning in complexity.

(obligatory plug :)) Of course, you may find like we do that Nixpkgs a great foundation with which to develop toolchains and push them to their limits, and want to just use Nixpkgs rather than borrow our techniques.

What could be improved in upstream LLVM to make working with it easier as a downstream packager? (optional)

  • Better support for "GNU install dirs" --- how we separate regular and "dev" packages instead of DESTDIR or manual separation.
  • Perhaps giving the -B/-resource-dir division of labor a fresh review.
  • Clarify compiler-rt <-> libc dependencies.
  • Use of "target" in source code interfaces D44753

@sternenseemann just let me know about this conference, which I am quite grateful for as I've long hoped for a venue like this to discuss our work, and may have more information to provide about pkgsLLVM. I imagine our experience chasing after stray build failures in arbitrary packages using LLVM might also be of interest. If I had figured everything out earlier, I would have written the above knowing the answer of whether he had information to add, but as the deadlines looms I figured I better get something up ASAP. Sorry!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions