Repository navigation
[staging] llvmPackages*.libllvm: drop outputs.patch for llvm-config.patch - #152944
Conversation
|
Note that this will cause a regression for cross compilation (see also #148367), which can be (better) fixed along the lines of 46240c3. Basically cc @r-burns I'll port the cross fix commit to all other LLVM versions and push it here later. |
|
The script pasted above produces the same output for normal |
d29b0cf to
b374593
Compare
Due to gnu-install-dirs.patch llvm-config will return correct results for --link-shared as well as --link-static even without this patch.
b374593 to
9a0a6d3
Compare
There was a problem hiding this comment.
I will aim to make this one not necessary to fix soon :)
9a0a6d3 to
28147cc
Compare
|
Okay, so now |
LLVM's build system creates NATIVE/bin/llvm-config by reexecuting cmake with entirely new flags. Problematically, the `CMAKE_INSTALL_*` flags are not inherited, causing llvm-config-native to return wrong installation paths, e. g. CMAKE_INSTALL_LIBDIR would default to `lib64` on x86_64-linux. Previously this was masked by outputs.patch which replaced ActiveLibDir with a string passed in from Nix, however `--cmakedir` for example would turn out to be wrong always, breaking cross-compilation of e. g. lld. Additionally LLVM_ENABLE_RTTI needs to be repassed, as it is used to determine if RTTI is available. Passing LLVM_LINK_LLVM_DYLIB is crucial if we are building LLVM non-statically: It influences the --shared-mode flag (which should indicate that -lLLVM is enough to link all components) and makes --link-shared work in the first place, i. e. llvm-config-native believes the built shared libs don't exist unless we repass this flag. Passing LLVM_LINK_LLVM_DYLIB=ON, however, makes the native build produce a full libLLVM.so which is something we don't want, so we introduce a patch which forces llvm-config to link statically against the LLVM components it needs.
28147cc to
e10edcc
Compare
|
Okay, I think I've finally untangled it. As it turns out Both these values are influenced by As you can see for LLVM 11, the --- build/NATIVE/tools/llvm-config/BuildVariables.inc 2022-01-03 13:06:13.482576812 +0100
+++ build/tools/llvm-config/BuildVariables.inc 2022-01-03 13:05:36.917470071 +0100
@@ -16,19 +16,19 @@
//===----------------------------------------------------------------------===//
#define LLVM_SRC_ROOT "/home/lukas/src/nix/nixpkgs/llvm-11.1.0.src"
-#define LLVM_OBJ_ROOT "/home/lukas/src/nix/nixpkgs/llvm-11.1.0.src/build/NATIVE"
+#define LLVM_OBJ_ROOT "/home/lukas/src/nix/nixpkgs/llvm-11.1.0.src/build"
#define LLVM_CPPFLAGS "-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
#define LLVM_CFLAGS " -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
#define LLVM_LDFLAGS ""
#define LLVM_CXXFLAGS "-std=c++14 -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
#define LLVM_BUILDMODE "Release"
#define LLVM_LIBDIR_SUFFIX ""
-#define LLVM_INSTALL_BINDIR "/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9/bin"
-#define LLVM_INSTALL_LIBDIR "/0sra2y18lr3h6j58qjm0w46yv36h1wjmilb09n8aimdpivdymscx/lib"
-#define LLVM_INSTALL_INCLUDEDIR "/02qcpld1y6xhs5gz9bchpxaw0xdhmsp5dv88lh25r2ss44kh8dxz/include"
+#define LLVM_INSTALL_BINDIR "/nix/store/f8w4zhgy974b3hsvfif3b6fj4wfb5506-llvm-aarch64-unknown-linux-gnu-11.1.0/bin"
+#define LLVM_INSTALL_LIBDIR "/nix/store/609l10l12vdlgq5vc72sfi4iaiqnv5bh-llvm-aarch64-unknown-linux-gnu-11.1.0-lib/lib"
+#define LLVM_INSTALL_INCLUDEDIR "/nix/store/2ajndk42qqh609ml69lih3liwigvwc43-llvm-aarch64-unknown-linux-gnu-11.1.0-dev/include"
#define LLVM_INSTALL_CMAKEDIR "/02qcpld1y6xhs5gz9bchpxaw0xdhmsp5dv88lh25r2ss44kh8dxz/lib/cmake/llvm/"
#define LLVM_TARGETS_BUILT "AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430 NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore"
-#define LLVM_SYSTEM_LIBS "-lrt -ldl -lpthread -lm -lxml2"
+#define LLVM_SYSTEM_LIBS "-lz -lrt -ldl -ltinfo -lpthread -lm -lxml2"
#define LLVM_BUILD_SYSTEM "cmake"
#define LLVM_HAS_RTTI 1
#define LLVM_ENABLE_DYLIB 1
@@ -37,4 +37,4 @@
#define LLVM_DYLIB_COMPONENTS "all"
#define LLVM_DYLIB_VERSION "11"
#define LLVM_HAS_GLOBAL_ISEL 1
-#define LLVM_TOOLS_INSTALL_DIR "/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9/bin"
+#define LLVM_TOOLS_INSTALL_DIR "/nix/store/f8w4zhgy974b3hsvfif3b6fj4wfb5506-llvm-aarch64-unknown-linux-gnu-11.1.0/bin" |
|
Okay, I've tested all LLVM versions again: LLVM 5 has discrepancies in the output, listing less components than the native build, but I suppose this is a genuine LLVM cross compilation issue only present in the oldest LLVM version we ship, so I don't think it's worth fixing for now. |
|
Successfully created backport PR #153868 for |
Reverts #162607 / 1748887. Reason for revert: This change caused llvm-config{,-native} to be unable to find static archives bundled with LLVM, as has been [reported]. Ever since #152944 using moveToOutput in LLVM is _evil_ because llvm-config obtains it knowledge about the installation locations from the CMake configure step. Consequently a change like #162607 will need to be implemented by making LLVM itself install the static archives to the correct location or by adding yet another patch which updates llvm-config's knowledge of the location. The latter is not desireable in my opinion, though, since it is just asking for this sort of trouble: Before #152944 we had an outputs.patch that did this sort of things which broke spectacularly in edge cases. Fixes #148117. [reported]: #148117 (comment)
Reverts #162607 / 1748887. Reason for revert: This change caused llvm-config{,-native} to be unable to find static archives bundled with LLVM, as has been [reported]. Ever since #152944 using moveToOutput in LLVM is _evil_ because llvm-config obtains it knowledge about the installation locations from the CMake configure step. Consequently a change like #162607 will need to be implemented by making LLVM itself install the static archives to the correct location or by adding yet another patch which updates llvm-config's knowledge of the location. The latter is not desireable in my opinion, though, since it is just asking for this sort of trouble: Before #152944 we had an outputs.patch that did this sort of things which broke spectacularly in edge cases. Fixes #148117. [reported]: #148117 (comment)
Reverts #162607 / 1748887. Reason for revert: This change caused llvm-config{,-native} to be unable to find static archives bundled with LLVM, as has been [reported]. Ever since #152944 using moveToOutput in LLVM is _evil_ because llvm-config obtains it knowledge about the installation locations from the CMake configure step. Consequently a change like #162607 will need to be implemented by making LLVM itself install the static archives to the correct location or by adding yet another patch which updates llvm-config's knowledge of the location. The latter is not desireable in my opinion, though, since it is just asking for this sort of trouble: Before #152944 we had an outputs.patch that did this sort of things which broke spectacularly in edge cases. Fixes #148117. [reported]: #148117 (comment) (cherry picked from commit a2ed5b2)
Reverts #162607 / 1748887. Reason for revert: This change caused llvm-config{,-native} to be unable to find static archives bundled with LLVM, as has been [reported]. Ever since #152944 using moveToOutput in LLVM is _evil_ because llvm-config obtains it knowledge about the installation locations from the CMake configure step. Consequently a change like #162607 will need to be implemented by making LLVM itself install the static archives to the correct location or by adding yet another patch which updates llvm-config's knowledge of the location. The latter is not desireable in my opinion, though, since it is just asking for this sort of trouble: Before #152944 we had an outputs.patch that did this sort of things which broke spectacularly in edge cases. Fixes #148117. [reported]: #148117 (comment) (cherry picked from commit a2ed5b2)
Due to gnu-install-dirs.patch llvm-config will return correct results
for --link-shared as well as --link-static even without this patch.
I am currently verifying this using the following script:
Will take some build time, currently checked:
Motivation for this change
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes