diff options
Diffstat (limited to 'pkgs/development/compilers/llvm/git/default.nix')
-rw-r--r-- | pkgs/development/compilers/llvm/git/default.nix | 97 |
1 files changed, 68 insertions, 29 deletions
diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index 1a34130679db2..464c405dc0606 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -19,9 +19,9 @@ # LLVM release information; specify one of these but not both: , gitRelease ? { version = "19.0.0-git"; - rev = "cebf77fb936a7270c7e3fa5c4a7e76216321d385"; - rev-version = "19.0.0-unstable-2024-04-07"; - sha256 = "sha256-616tscgsiFgHQcXW4KzK5srrudYizQFnJVM6K0qRf+I="; + rev = "78ee473784e5ef6f0b19ce4cb111fb6e4d23c6b2"; + rev-version = "19.0.0-unstable-2024-06-12"; + sha256 = "sha256-oLVMwWjo6Nt8ZsTnDTfoiM5U0+1lVIc1NO+4qBNYlzs="; } # i.e.: # { @@ -44,7 +44,7 @@ # to you to make sure that the LLVM repo given matches the release configuration # specified. , monorepoSrc ? null -}: +}@args: assert lib.assertMsg @@ -56,15 +56,17 @@ assert let monorepoSrc' = monorepoSrc; in let - inherit (import ../common/common-let.nix { inherit lib gitRelease officialRelease; }) releaseInfo; - inherit (releaseInfo) release_version version; - - inherit (import ../common/common-let.nix { inherit lib fetchFromGitHub release_version gitRelease officialRelease monorepoSrc'; }) llvm_meta monorepoSrc; + metadata = rec { + # Import releaseInfo separately to avoid infinite recursion + inherit (import ../common/common-let.nix { inherit lib gitRelease officialRelease; }) releaseInfo; + inherit (releaseInfo) release_version version; + inherit (import ../common/common-let.nix { inherit lib fetchFromGitHub gitRelease release_version officialRelease monorepoSrc'; }) llvm_meta monorepoSrc; + }; tools = lib.makeExtensible (tools: let - callPackage = newScope (tools // { inherit stdenv cmake ninja libxml2 python3 release_version version monorepoSrc buildLlvmTools; }); - major = lib.versions.major release_version; + callPackage = newScope (tools // args // metadata); + major = lib.versions.major metadata.release_version; mkExtraBuildCommands0 = cc: '' rsrc="$out/resource-root" mkdir "$rsrc" @@ -87,8 +89,57 @@ in let in { - libllvm = callPackage ./llvm { - inherit llvm_meta; + libllvm = callPackage ../common/llvm { + patches = [ + ./llvm/gnu-install-dirs.patch + + # Running the tests involves invoking binaries (like `opt`) that depend on + # the LLVM dylibs and reference them by absolute install path (i.e. their + # nix store path). + # + # Because we have not yet run the install phase (we're running these tests + # as part of `checkPhase` instead of `installCheckPhase`) these absolute + # paths do not exist yet; to work around this we point the loader (`ld` on + # unix, `dyld` on macOS) at the `lib` directory which will later become this + # package's `lib` output. + # + # Previously we would just set `LD_LIBRARY_PATH` to include the build `lib` + # dir but: + # - this doesn't generalize well to other platforms; `lit` doesn't forward + # `DYLD_LIBRARY_PATH` (macOS): + # + https://github.com/llvm/llvm-project/blob/0d89963df354ee309c15f67dc47c8ab3cb5d0fb2/llvm/utils/lit/lit/TestingConfig.py#L26 + # - even if `lit` forwarded this env var, we actually cannot set + # `DYLD_LIBRARY_PATH` in the child processes `lit` launches because + # `DYLD_LIBRARY_PATH` (and `DYLD_FALLBACK_LIBRARY_PATH`) is cleared for + # "protected processes" (i.e. the python interpreter that runs `lit`): + # https://stackoverflow.com/a/35570229 + # - other LLVM subprojects deal with this issue by having their `lit` + # configuration set these env vars for us; it makes sense to do the same + # for LLVM: + # + https://github.com/llvm/llvm-project/blob/4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae/clang-tools-extra/test/Unit/lit.cfg.py#L22-L31 + # + # !!! TODO: look into upstreaming this patch + ./llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch + + # `lit` has a mode where it executes run lines as a shell script which is + # constructs; this is problematic for macOS because it means that there's + # another process in between `lit` and the binaries being tested. As noted + # above, this means that `DYLD_LIBRARY_PATH` is cleared which means that our + # tests fail with dyld errors. + # + # To get around this we patch `lit` to reintroduce `DYLD_LIBRARY_PATH`, when + # present in the test configuration. + # + # It's not clear to me why this isn't an issue for LLVM developers running + # on macOS (nothing about this _seems_ nix specific).. + ./llvm/lit-shell-script-runner-set-dyld-library-path.patch + ]; + pollyPatches = [ + ./llvm/gnu-install-dirs-polly.patch + + # Just like the `llvm-lit-cfg` patch, but for `polly`. + ./llvm/polly-lit-cfg-add-libs-to-dylib-path.patch + ]; }; # `llvm` historically had the binaries. When choosing an output explicitly, @@ -106,7 +157,6 @@ in let libllvmLibdir = "${tools.libllvm.lib}/lib"; }) ]; - inherit llvm_meta; }; clang-unwrapped = tools.libclang; @@ -155,15 +205,12 @@ in let patches = [ ./lld/gnu-install-dirs.patch ]; - inherit llvm_meta; }; - mlir = callPackage ../common/mlir { - inherit llvm_meta; - }; + mlir = callPackage ../common/mlir {}; lldb = callPackage ../common/lldb.nix { - src = callPackage ({ runCommand }: runCommand "lldb-src-${version}" {} '' + src = callPackage ({ runCommand }: runCommand "lldb-src-${metadata.version}" {} '' mkdir -p "$out" cp -r ${monorepoSrc}/cmake "$out" cp -r ${monorepoSrc}/lldb "$out" @@ -187,7 +234,6 @@ in let && !stdenv.targetPlatform.isAarch64 && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") ) ./lldb/cpu_subtype_arm64e_replacement.patch; - inherit llvm_meta; }; # Below, is the LLVM bootstrapping logic. It handles building a @@ -290,13 +336,11 @@ in let # Has to be in tools despite mostly being a library, # because we use a native helper executable from a # non-cross build in cross builds. - libclc = callPackage ../common/libclc.nix { - inherit buildLlvmTools; - }; + libclc = callPackage ../common/libclc.nix {}; }); libraries = lib.makeExtensible (libraries: let - callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake ninja libxml2 python3 release_version version monorepoSrc; }); + callPackage = newScope (libraries // buildLlvmTools // args // metadata); in { compiler-rt-libc = callPackage ../common/compiler-rt { @@ -310,7 +354,6 @@ in let # See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893 # ../common/compiler-rt/armv7l-15.patch ]; - inherit llvm_meta; stdenv = if stdenv.hostPlatform.useLLVM or false || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic) then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc else stdenv; @@ -327,7 +370,6 @@ in let # See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893 # ../common/compiler-rt/armv7l-15.patch ]; - inherit llvm_meta; stdenv = if stdenv.hostPlatform.useLLVM or false then overrideCC stdenv buildLlvmTools.clangNoCompilerRt else stdenv; @@ -350,12 +392,10 @@ in let # https://github.com/llvm/llvm-project/issues/64226 ./libcxx/0001-darwin-10.12-mbstate_t-fix.patch ]; - inherit llvm_meta; stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; libunwind = callPackage ../common/libunwind { - inherit llvm_meta; stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; @@ -364,9 +404,8 @@ in let ./openmp/fix-find-tool.patch ./openmp/run-lit-directly.patch ]; - inherit llvm_meta targetLlvm; }; }); noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ]; -in { inherit tools libraries release_version; } // (noExtend libraries) // (noExtend tools) +in { inherit tools libraries; inherit (metadata) release_version; } // (noExtend libraries) // (noExtend tools) |