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

llvmPackages_{9,12,13,14,15,16,17,18,git}.clang: fix libLTO.dylib path #302481

Closed
wants to merge 11 commits into from

Conversation

reckenrode
Copy link
Contributor

Description of changes

Clang assumes that libLTO.dylib is located at ../lib in the same prefix as clang, but that’s not true in nixpkgs. libLTO.dylib is actually located at libllvm^lib/lib.libLTO.dylib.

This is the first piece to fixing LTO on Darwin. The other is updating ld64, which I will be doing in a separate PR later this week. This PR does not depend on that PR because there is no harm passing the correct path to ld64. It does not perform LTO by default, and trying to use -flto even with the correct path remains broken.

Testing was done using my WIP PR for ld64 with clang 16. See #19098 (comment) for output. It can also be validated by setting NIX_DEBUG=1 when running clang, then confirming that the path passed to -lto_library actually exists in the store.

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/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 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.

@RossComputerGuy
Copy link
Member

RossComputerGuy commented Apr 8, 2024

This is a good set of changes from the looks of it, I'll give this a look over when I have the time. Right now, my priority is on making all LLVM subpackages common and I am hoping to get that done asap so this PR will probably take a bit for me to look over. I also don't want to have to rebase that PR heh.

'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
# Make sure clang passes the correct location of libLTO to ld64
substituteInPlace clang/lib/Driver/ToolChains/Darwin.cpp \
--replace-fail 'StringRef P = llvm::sys::path::parent_path(D.Dir);' 'StringRef P = "${lib.getLib libllvm}";'
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be unconditional, so that Linux users catch it if the replacement starts failing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can make it unconditional.

Copy link
Contributor Author

@reckenrode reckenrode Apr 8, 2024

Choose a reason for hiding this comment

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

It’s unconditional now. I also moved it to postPatch. Clang 16 already correctly had it there. Now they all should.

@alyssais
Copy link
Member

alyssais commented Apr 9, 2024

Conflict :(

@reckenrode
Copy link
Contributor Author

reckenrode commented Apr 9, 2024

Conflict :(

Rebased and dropped clang 9 since it was removed in #302750.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/darwin-updates-news/42249/10

Artturin and others added 5 commits April 14, 2024 20:48
fixes NixOS#302629

After updating from `3.15.0 -> 3.19.2` build for `goose` was failing.
This was due to the tests failing esp on integration tests which
required the docker darmon to be running.

Tests with similar nature were already skipped, but on the upgraded
version newer integration tests were added. This change adds these
changes to the test skip list aswell.

Skip following tests which require a docker daemon to be running
- TestLockModeAdvisorySession
- TestDialectStore
- TestGoMigrationStats
- TestPostgresSessionLocker

Links:
- Commit adding the new integration tests: pressly/goose@b2c483a
mweinelt and others added 6 commits April 15, 2024 18:23
Firefox: 124.0.2 -> 125.0; 115.9.0esr -> 115.10.0esr
goose: update test skip list with newer tests
Clang assumes that `libLTO.dylib` is located at `../lib` in the same
prefix as `clang`, but that’s not true in nixpkgs. `libLTO.dylib` is
actually located at `libllvm^lib/lib.libLTO.dylib`.
@reckenrode
Copy link
Contributor Author

Closing because of the mass ping. I’ll reopen targeting staging with the consolidated clang.

@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.

10 participants