Skip to content

llvm: fix crossbuilding on Darwin #381878

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brndnmtthws
Copy link

@brndnmtthws brndnmtthws commented Feb 13, 2025

The --build-id=sha1 flag isn't supported on Darwin, and we need to check that neither the host or build platform is Darwin.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

The `--build-id=sha1` flag isn't supported on Darwin, and we need to
check that neither the host or build platform is Darwin.
@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Feb 13, 2025
@github-actions github-actions bot added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label Feb 13, 2025
@NixOSInfra NixOSInfra added the 12. first-time contribution This PR is the author's first one; please be gentle! label Feb 13, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Feb 13, 2025
@@ -329,7 +329,7 @@ stdenv.mkDerivation (finalAttrs: {
'';

# E.g. Mesa uses the build-id as a cache key (see #93946):
LDFLAGS = optionalString (enableSharedLibraries && !stdenv.hostPlatform.isDarwin) "-Wl,--build-id=sha1";
LDFLAGS = optionalString (enableSharedLibraries && !stdenv.hostPlatform.isDarwin && !stdenv.buildPlatform.isDarwin) "-Wl,--build-id=sha1";
Copy link
Member

Choose a reason for hiding this comment

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

Is there no way to specify separate link flags for the build and host platforms? The comment above sounds like it would be suboptimal to produce builds for Linux hosts that didn't use --build-id.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not entirely sure, but I think it might make sense to drop the check for hostPlatform here. If you're cross-compiling from Linux, it would be fine to include the build flag (i.e., the compiler is being build to run on Linux, but produce binaries for Darwin).

I think you should be able to compile binaries for macOS from Linux, but I haven't tried this yet.

Copy link
Member

Choose a reason for hiding this comment

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

It's not something you can currently do in Nixpkgs. Checking hostPlatform seems right to me, because it's the host linker that needs to support the argument. Checking the build linker seems like a workaround for not being able to distinguish between build and host flags, which I bet there's a way to do.

@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: darwin Running or building packages on Darwin 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 12. first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants