diff --git a/pkgs/development/compilers/llvm/common/bolt/default.nix b/pkgs/development/compilers/llvm/common/bolt/default.nix index 9d6385ae74b3..d62841b48d0a 100644 --- a/pkgs/development/compilers/llvm/common/bolt/default.nix +++ b/pkgs/development/compilers/llvm/common/bolt/default.nix @@ -3,6 +3,7 @@ stdenv, llvm_meta, monorepoSrc, + release_version, runCommand, cmake, libxml2, @@ -20,16 +21,22 @@ stdenv.mkDerivation (finalAttrs: { inherit version patches; # Blank llvm dir just so relative path works - src = runCommand "bolt-src-${finalAttrs.version}" { } '' - mkdir $out - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${finalAttrs.pname} "$out" - cp -r ${monorepoSrc}/third-party "$out" + src = runCommand "bolt-src-${finalAttrs.version}" { } ( + '' + mkdir $out + '' + + lib.optionalString (lib.versionAtLeast release_version "14") '' + cp -r ${monorepoSrc}/cmake "$out" + '' + + '' + cp -r ${monorepoSrc}/${finalAttrs.pname} "$out" + cp -r ${monorepoSrc}/third-party "$out" - # tablegen stuff, probably not the best way but it works... - cp -r ${monorepoSrc}/llvm/ "$out" - chmod -R +w $out/llvm - ''; + # tablegen stuff, probably not the best way but it works... + cp -r ${monorepoSrc}/llvm/ "$out" + chmod -R +w $out/llvm + '' + ); sourceRoot = "${finalAttrs.src.name}/bolt"; diff --git a/pkgs/development/compilers/llvm/common/clang/default.nix b/pkgs/development/compilers/llvm/common/clang/default.nix index 2b5aca109348..5c9662c24d58 100644 --- a/pkgs/development/compilers/llvm/common/clang/default.nix +++ b/pkgs/development/compilers/llvm/common/clang/default.nix @@ -24,12 +24,14 @@ let pname = "clang"; src' = if monorepoSrc != null then - runCommand "${pname}-src-${version}" {} '' + runCommand "${pname}-src-${version}" {} ('' mkdir -p "$out" + '' + lib.optionalString (lib.versionAtLeast release_version "14") '' cp -r ${monorepoSrc}/cmake "$out" + '' + '' cp -r ${monorepoSrc}/${pname} "$out" cp -r ${monorepoSrc}/clang-tools-extra "$out" - '' else src; + '') else src; self = stdenv.mkDerivation (finalAttrs: rec { inherit pname version patches; diff --git a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix index a6d727739d27..cce348b3ef50 100644 --- a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix @@ -47,11 +47,13 @@ let pname = baseName + lib.optionalString (haveLibc) "-libc"; src' = if monorepoSrc != null then - runCommand "${baseName}-src-${version}" {} '' + runCommand "${baseName}-src-${version}" {} ('' mkdir -p "$out" + '' + lib.optionalString (lib.versionAtLeast release_version "14") '' cp -r ${monorepoSrc}/cmake "$out" + '' + '' cp -r ${monorepoSrc}/${baseName} "$out" - '' else src; + '') else src; preConfigure = lib.optionalString (!haveLibc) '' cmakeFlagsArray+=(-DCMAKE_C_FLAGS="-nodefaultlibs -ffreestanding") diff --git a/pkgs/development/compilers/llvm/common/default.nix b/pkgs/development/compilers/llvm/common/default.nix index 55d26de9fc09..2f47f1a583c5 100644 --- a/pkgs/development/compilers/llvm/common/default.nix +++ b/pkgs/development/compilers/llvm/common/default.nix @@ -346,13 +346,7 @@ let tools = lib.makeExtensible ( tools: let - callPackage = newScope ( - tools - // args - // metadata - # Previously monorepoSrc was erroneously not being passed through. - // lib.optionalAttrs (lib.versionOlder metadata.release_version "14") { monorepoSrc = null; } # Preserve a bug during #307211, TODO: remove; causes llvm 13 rebuild. - ); + callPackage = newScope (tools // args // metadata); clangVersion = if (lib.versionOlder metadata.release_version "16") then metadata.release_version diff --git a/pkgs/development/compilers/llvm/common/libclc.nix b/pkgs/development/compilers/llvm/common/libclc.nix index 299b27417b6a..c24fc6e3b4c0 100644 --- a/pkgs/development/compilers/llvm/common/libclc.nix +++ b/pkgs/development/compilers/llvm/common/libclc.nix @@ -22,11 +22,17 @@ stdenv.mkDerivation rec { pname = "libclc"; inherit version; - src = runCommand "${pname}-src-${version}" { } '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - ''; + src = runCommand "${pname}-src-${version}" { } ( + '' + mkdir -p "$out" + '' + + lib.optionalString (lib.versionAtLeast release_version "14") '' + cp -r ${monorepoSrc}/cmake "$out" + '' + + '' + cp -r ${monorepoSrc}/${pname} "$out" + '' + ); sourceRoot = "${src.name}/${pname}"; diff --git a/pkgs/development/compilers/llvm/common/libunwind/default.nix b/pkgs/development/compilers/llvm/common/libunwind/default.nix index 77854ddfcc5d..63b9737092b8 100644 --- a/pkgs/development/compilers/llvm/common/libunwind/default.nix +++ b/pkgs/development/compilers/llvm/common/libunwind/default.nix @@ -19,7 +19,9 @@ let src' = if monorepoSrc != null then runCommand "${pname}-src-${version}" {} ('' mkdir -p "$out" + '' + lib.optionalString (lib.versionAtLeast release_version "14") '' cp -r ${monorepoSrc}/cmake "$out" + '' + '' cp -r ${monorepoSrc}/${pname} "$out" mkdir -p "$out/libcxx" cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx" diff --git a/pkgs/development/compilers/llvm/common/lld/default.nix b/pkgs/development/compilers/llvm/common/lld/default.nix index d5c0f7cb3a09..32cf5cb46460 100644 --- a/pkgs/development/compilers/llvm/common/lld/default.nix +++ b/pkgs/development/compilers/llvm/common/lld/default.nix @@ -19,21 +19,23 @@ let pname = "lld"; src' = if monorepoSrc != null then - runCommand "lld-src-${version}" {} '' + runCommand "lld-src-${version}" {} ('' mkdir -p "$out" + '' + lib.optionalString (lib.versionAtLeast release_version "14") '' cp -r ${monorepoSrc}/cmake "$out" + '' + '' cp -r ${monorepoSrc}/${pname} "$out" mkdir -p "$out/libunwind" cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" mkdir -p "$out/llvm" - '' else src; + '') else src; postPatch = lib.optionalString (lib.versions.major release_version == "12") '' substituteInPlace MachO/CMakeLists.txt --replace \ '(''${LLVM_MAIN_SRC_DIR}/' '(' mkdir -p libunwind/include tar -xf "${libunwind.src}" --wildcards -C libunwind/include --strip-components=2 "libunwind-*/include/" - '' + lib.optionalString (lib.versions.major release_version == "13" && stdenv.hostPlatform.isDarwin) '' + '' + lib.optionalString (lib.versions.major release_version == "13") '' substituteInPlace MachO/CMakeLists.txt --replace \ '(''${LLVM_MAIN_SRC_DIR}/' '(../' ''; @@ -75,4 +77,4 @@ stdenv.mkDerivation (rec { of several different linkers. ''; }; -} // (if (postPatch == "" && lib.versions.major release_version != "13") then {} else { inherit postPatch; })) +} // (lib.optionalAttrs (postPatch != "") { inherit postPatch; })) diff --git a/pkgs/development/compilers/llvm/common/lldb.nix b/pkgs/development/compilers/llvm/common/lldb.nix index 4f679f4dcff1..38bc91977c36 100644 --- a/pkgs/development/compilers/llvm/common/lldb.nix +++ b/pkgs/development/compilers/llvm/common/lldb.nix @@ -32,7 +32,9 @@ let if monorepoSrc != null then runCommand "lldb-src-${version}" { } ('' mkdir -p "$out" + '' + lib.optionalString (lib.versionAtLeast release_version "14") '' cp -r ${monorepoSrc}/cmake "$out" + '' + '' cp -r ${monorepoSrc}/lldb "$out" '' + lib.optionalString (lib.versionAtLeast release_version "19" && enableManpages) '' mkdir -p "$out/llvm" diff --git a/pkgs/development/compilers/llvm/common/llvm/default.nix b/pkgs/development/compilers/llvm/common/llvm/default.nix index 281a21ca1524..fc139c703774 100644 --- a/pkgs/development/compilers/llvm/common/llvm/default.nix +++ b/pkgs/development/compilers/llvm/common/llvm/default.nix @@ -77,11 +77,15 @@ let pname = "llvm"; + # TODO: simplify versionAtLeast condition for cmake and third-party via rebuild src' = if monorepoSrc != null then runCommand "${pname}-src-${version}" {} ('' mkdir -p "$out" + '' + lib.optionalString (lib.versionAtLeast release_version "14") '' cp -r ${monorepoSrc}/cmake "$out" + '' + '' cp -r ${monorepoSrc}/${pname} "$out" + '' + lib.optionalString (lib.versionAtLeast release_version "14") '' cp -r ${monorepoSrc}/third-party "$out" '' + lib.optionalString enablePolly '' chmod u+w "$out/${pname}/tools" diff --git a/pkgs/development/compilers/llvm/common/mlir/default.nix b/pkgs/development/compilers/llvm/common/mlir/default.nix index e4dd12d69e58..9c3c71c3b705 100644 --- a/pkgs/development/compilers/llvm/common/mlir/default.nix +++ b/pkgs/development/compilers/llvm/common/mlir/default.nix @@ -1,6 +1,7 @@ { lib , stdenv , llvm_meta +, release_version , buildLlvmTools , monorepoSrc , runCommand @@ -18,14 +19,16 @@ stdenv.mkDerivation rec { inherit version doCheck; # Blank llvm dir just so relative path works - src = runCommand "${pname}-src-${version}" { } '' + src = runCommand "${pname}-src-${version}" { } ('' mkdir -p "$out" + '' + lib.optionalString (lib.versionAtLeast release_version "14") '' cp -r ${monorepoSrc}/cmake "$out" + '' + '' cp -r ${monorepoSrc}/mlir "$out" cp -r ${monorepoSrc}/third-party "$out/third-party" mkdir -p "$out/llvm" - ''; + ''); sourceRoot = "${src.name}/mlir"; diff --git a/pkgs/development/compilers/llvm/common/openmp/default.nix b/pkgs/development/compilers/llvm/common/openmp/default.nix index 57c6de07c784..1ad5948edb86 100644 --- a/pkgs/development/compilers/llvm/common/openmp/default.nix +++ b/pkgs/development/compilers/llvm/common/openmp/default.nix @@ -21,11 +21,13 @@ let pname = "openmp"; src' = if monorepoSrc != null then - runCommand "${pname}-src-${version}" {} '' + runCommand "${pname}-src-${version}" {} ('' mkdir -p "$out" + '' + lib.optionalString (lib.versionAtLeast release_version "14") '' cp -r ${monorepoSrc}/cmake "$out" + '' + '' cp -r ${monorepoSrc}/${pname} "$out" - '' else src; + '') else src; in stdenv.mkDerivation (rec { inherit pname version patches;