-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Clang link time optimization not working on OSX #19098
Comments
I seem to remember that the cctools we're using has the LTO option turned off. I tried turning it on a while back and ran into issues. Perhaps it'll work nowadays but I can't look for a while. |
@copumpkin thanks for the quick response. I'm more than happy to try and get cctools working with LTO if you can point me in the right direction. |
I think you'll want to take the cctools-port expression and make sure to pass Also keep in mind that both darwin and linux use cctools-port, so please make sure the linux build still works (or call out that you can't and see if you can get someone else to test it) |
Thanks for the pointers. I'll see if I can make any progress. I'll test on linux also to prevent breaking it. |
(triage) fixed? |
Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:
|
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/darwin-system-and-stdenv-hostplatform-features/9745/1 |
This is still a problem. |
I marked this as stale due to inactivity. → More info |
This is still an issue. |
This is still broken, in |
There are 2 tools that need to be adjusted to make things work:
Regarding |
lld isn’t a drop-in replacement for ld64. It doesn’t work with xcbuild or Qt’s build system (and probably others). I tried linking the Darwin stdenv with it, but it wasn’t even able to do that. I plan to try again with the clang 18 update next year, but it doesn’t look like much has changed so far upstream. |
firebird-emu supports darwin, but the derivation has not been tested on macOS. This commit adds darwin support to the derivation, with the necessary tweaks to support building for a darwin target. Namely, adds a workaround for NixOS#19098, and adds a missing dependency, qtquickcontrols. Also, adds a postInstall hook which moves the MacOS .app file to the Applications/ folder in the store, enabling proper linking to /Applications or ~/Applications and appearance in Spotlight and Launchpad.
Affecting our project too. What if anything can be done to fix this issue? I am not technically apt enough in this area but would be willing to fund the effort to get this fixed (if on the order of $100). |
I’m working on updates to libtapi, cctools, and ld64 to the latest versions from Apple’s OSS releases. I currently have libtapi and ld64 building with working LTO in ld64. $ nix run .#ld64 -- -v
@(#)PROGRAM:ld PROJECT:ld64-951.9
BUILD 00:00:00 Jan 1 1980
configured to support archs: i386 x86_64 x86_64h armv6 armv7 armv7s armv7m armv7k arm64 arm64e arm64_32
LTO support using: LLVM version 16.0.6 (static support for 29, runtime is 29)
TAPI support using: TAPI version 15.0.0 (tapi-1500.0.12.3)
$ nix run .#clang -- -flto -fuse-ld=$(nix path-info .#ld64)/bin/ld test.c -o test
# exit status: 0 Note that Apple’s upstream sources do not build on Linux. I am building ld64 (and plan to build cctools the same way) with Meson instead of the Xcode projects. I’ve also been replacing private API usage with portable APIs. I’m doing that with an eye towards restoring support for Linux (and I have limited patience for dealing with xcbuild failures). I should have a PR open against later this week. There is a clang piece needed for LTO. It’s passing the wrong path to ld64 (via |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
Shall we close this now that it’s in |
Closed via #307880. |
This is unnecessary now that NixOS#19098 is fixed.
This is unnecessary now that NixOS#19098 is fixed.
Initially, when LTO was first introduced in commit 55a7a94 (Enable LTO and -march=native, 2019-05-29), it was enabled by default on all platforms. Now that it is no longer broken in Nix, this old default may be restored. The reported upstream issue (NixOS/nixpkgs#19098) has been resolved and the fix is already included in the `nixpkgs-unstable` branch. This also enables LTO again on platforms other than Darwin, where it was unintentionally disabled by default due to a programming error.
When LTO was first introduced in commit 55a7a94 (Enable LTO and -march=native, 2019-05-29), it was enabled by default on all platforms. Now that it is no longer broken in Nix on Darwin, this old default may be restored. The reported upstream issue (NixOS/nixpkgs#19098) has been resolved and the fix is already included in the `nixpkgs-unstable` branch. This also enables LTO again on platforms other than Darwin, where it was unintentionally disabled by default due to a programming error.
Issue description
The example for Clang's Link Time Optimization (http://llvm.org/docs/LinkTimeOptimization.html#example-of-link-time-optimization) doesn't work in nix on OSX. I tested with clang versions 3.8.0, 3.7.1, and 3.6.2. I wasn't able to test with clang 3.9.0 because of an error compiling
llvm-3.9.0
.It fails with the following on OSX with Clang 3.7.1:
It fails with the following on OSX with Clang 3.8.0:
Steps to reproduce
On an OSX machine:
Install nix:
curl https://nixos.org/nix/install | sh
Run (for clang 3.8.0):
nix-shell --pure -p llvmPackages_38.clang
Run (for clang 3.7.1):
nix-shell --pure -p llvmPackages_37.clang
In shell: Follow instructions at http://llvm.org/docs/LinkTimeOptimization.html#example-of-link-time-optimization to test link time optimization with the example code.
Technical details
uname -a
:nix-env (Nix) 1.11.4
"17.03pre91937.5cda2be"
The text was updated successfully, but these errors were encountered: