diff options
Diffstat (limited to 'pkgs/development/compilers/llvm')
45 files changed, 152 insertions, 75 deletions
diff --git a/pkgs/development/compilers/llvm/11/clang/default.nix b/pkgs/development/compilers/llvm/11/clang/default.nix index 5ddecd1f47e90..a31d0422f52b3 100644 --- a/pkgs/development/compilers/llvm/11/clang/default.nix +++ b/pkgs/development/compilers/llvm/11/clang/default.nix @@ -50,7 +50,7 @@ let # https://reviews.llvm.org/D51899 ./gnu-install-dirs.patch (substituteAll { - src = ../../clang-11-15-LLVMgold-path.patch; + src = ../../common/clang/clang-11-15-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; }) ]; diff --git a/pkgs/development/compilers/llvm/11/libcxx/default.nix b/pkgs/development/compilers/llvm/11/libcxx/default.nix index 3e77e03b124b7..10b8c00dd16a8 100644 --- a/pkgs/development/compilers/llvm/11/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/11/libcxx/default.nix @@ -30,7 +30,7 @@ stdenv.mkDerivation { }) ./gnu-install-dirs.patch ] ++ lib.optionals stdenv.hostPlatform.isMusl [ - ../../libcxx-0001-musl-hacks.patch + ../../common/libcxx/libcxx-0001-musl-hacks.patch ]; # Prevent errors like "error: 'foo' is unavailable: introduced in macOS yy.zz" diff --git a/pkgs/development/compilers/llvm/11/libcxxabi/default.nix b/pkgs/development/compilers/llvm/11/libcxxabi/default.nix index 8a0a18f678226..6c8487a2eb991 100644 --- a/pkgs/development/compilers/llvm/11/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/11/libcxxabi/default.nix @@ -20,7 +20,7 @@ stdenv.mkDerivation { '' + lib.optionalString stdenv.isDarwin '' export TRIPLE=x86_64-apple-darwin '' + lib.optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -d libcxx -i ${../../libcxx-0001-musl-hacks.patch} + patch -p1 -d libcxx -i ${../../common/libcxx/libcxx-0001-musl-hacks.patch} '' + lib.optionalString stdenv.hostPlatform.isWasm '' patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch} ''; diff --git a/pkgs/development/compilers/llvm/11/llvm/default.nix b/pkgs/development/compilers/llvm/11/llvm/default.nix index 423b08396666b..5e22d3f4af161 100644 --- a/pkgs/development/compilers/llvm/11/llvm/default.nix +++ b/pkgs/development/compilers/llvm/11/llvm/default.nix @@ -86,7 +86,7 @@ in stdenv.mkDerivation (rec { # of the flags used for the normal LLVM build. To avoid the need for building # a native libLLVM.so (which would fail) we force llvm-config to be linked # statically against the necessary LLVM components always. - ../../llvm-config-link-static.patch + ../../common/llvm/llvm-config-link-static.patch ./gnu-install-dirs.patch # On older CPUs (e.g. Hydra/wendy) we'd be getting an error in this test. @@ -149,7 +149,7 @@ in stdenv.mkDerivation (rec { --replace "Path.cpp" "" rm unittests/Support/Path.cpp '' + optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -i ${../../TLI-musl.patch} + patch -p1 -i ${../../common/llvm/TLI-musl.patch} substituteInPlace unittests/Support/CMakeLists.txt \ --replace "add_subdirectory(DynamicLibrary)" "" rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @@ -212,6 +212,8 @@ in stdenv.mkDerivation (rec { # E.g. mesa.drivers use the build-id as a cache key (see #93946): LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; + hardeningDisable = [ "trivialautovarinit" ]; + cmakeBuildType = if debugVersion then "Debug" else "Release"; cmakeFlags = with stdenv; let diff --git a/pkgs/development/compilers/llvm/12/clang/default.nix b/pkgs/development/compilers/llvm/12/clang/default.nix index 28f976a26bdb3..c482a8ee6875a 100644 --- a/pkgs/development/compilers/llvm/12/clang/default.nix +++ b/pkgs/development/compilers/llvm/12/clang/default.nix @@ -47,7 +47,7 @@ let # https://reviews.llvm.org/D51899 ./gnu-install-dirs.patch (substituteAll { - src = ../../clang-11-15-LLVMgold-path.patch; + src = ../../common/clang/clang-11-15-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; }) ]; diff --git a/pkgs/development/compilers/llvm/12/libcxx/default.nix b/pkgs/development/compilers/llvm/12/libcxx/default.nix index 40bff3c1168b7..67e2aed35cb66 100644 --- a/pkgs/development/compilers/llvm/12/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/12/libcxx/default.nix @@ -24,7 +24,7 @@ stdenv.mkDerivation { patches = [ ./gnu-install-dirs.patch ] ++ lib.optionals stdenv.hostPlatform.isMusl [ - ../../libcxx-0001-musl-hacks.patch + ../../common/libcxx/libcxx-0001-musl-hacks.patch ]; preConfigure = lib.optionalString stdenv.hostPlatform.isMusl '' diff --git a/pkgs/development/compilers/llvm/12/libcxxabi/default.nix b/pkgs/development/compilers/llvm/12/libcxxabi/default.nix index 78a4a68d6a16e..5ebb77ad3880f 100644 --- a/pkgs/development/compilers/llvm/12/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/12/libcxxabi/default.nix @@ -20,7 +20,7 @@ stdenv.mkDerivation { '' + lib.optionalString stdenv.isDarwin '' export TRIPLE=x86_64-apple-darwin '' + lib.optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -d libcxx -i ${../../libcxx-0001-musl-hacks.patch} + patch -p1 -d libcxx -i ${../../common/libcxx/libcxx-0001-musl-hacks.patch} '' + lib.optionalString stdenv.hostPlatform.isWasm '' patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch} ''; diff --git a/pkgs/development/compilers/llvm/12/llvm/default.nix b/pkgs/development/compilers/llvm/12/llvm/default.nix index 3263c4ddaf359..d75ce3b3b052c 100644 --- a/pkgs/development/compilers/llvm/12/llvm/default.nix +++ b/pkgs/development/compilers/llvm/12/llvm/default.nix @@ -87,7 +87,7 @@ in stdenv.mkDerivation (rec { # of the flags used for the normal LLVM build. To avoid the need for building # a native libLLVM.so (which would fail) we force llvm-config to be linked # statically against the necessary LLVM components always. - ../../llvm-config-link-static.patch + ../../common/llvm/llvm-config-link-static.patch # Fix llvm being miscompiled by some gccs. See llvm/llvm-project#49955 # Fix llvm being miscompiled by some gccs. See https://github.com/llvm/llvm-project/issues/49955 ./fix-llvm-issue-49955.patch @@ -138,7 +138,7 @@ in stdenv.mkDerivation (rec { # TODO: Fix failing tests: rm test/DebugInfo/X86/vla-multi.ll '' + optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -i ${../../TLI-musl.patch} + patch -p1 -i ${../../common/llvm/TLI-musl.patch} substituteInPlace unittests/Support/CMakeLists.txt \ --replace "add_subdirectory(DynamicLibrary)" "" rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @@ -202,6 +202,8 @@ in stdenv.mkDerivation (rec { # E.g. mesa.drivers use the build-id as a cache key (see #93946): LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; + hardeningDisable = [ "trivialautovarinit" ]; + cmakeBuildType = if debugVersion then "Debug" else "Release"; cmakeFlags = with stdenv; let diff --git a/pkgs/development/compilers/llvm/13/clang/default.nix b/pkgs/development/compilers/llvm/13/clang/default.nix index 7673c903e71cc..2d02ffb60b365 100644 --- a/pkgs/development/compilers/llvm/13/clang/default.nix +++ b/pkgs/development/compilers/llvm/13/clang/default.nix @@ -43,7 +43,7 @@ let ./revert-malloc-alignment-assumption.patch ../../common/clang/add-nostdlibinc-flag.patch (substituteAll { - src = ../../clang-11-15-LLVMgold-path.patch; + src = ../../common/clang/clang-11-15-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; }) ]; diff --git a/pkgs/development/compilers/llvm/13/libcxx/default.nix b/pkgs/development/compilers/llvm/13/libcxx/default.nix index 994ec7dd5a56e..2974fc80e191b 100644 --- a/pkgs/development/compilers/llvm/13/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/13/libcxx/default.nix @@ -25,7 +25,7 @@ stdenv.mkDerivation rec { patches = [ ./gnu-install-dirs.patch ] ++ lib.optionals stdenv.hostPlatform.isMusl [ - ../../libcxx-0001-musl-hacks.patch + ../../common/libcxx/libcxx-0001-musl-hacks.patch ]; preConfigure = lib.optionalString stdenv.hostPlatform.isMusl '' diff --git a/pkgs/development/compilers/llvm/13/llvm/default.nix b/pkgs/development/compilers/llvm/13/llvm/default.nix index 1e71cdd89c6c0..58e742b9b41ea 100644 --- a/pkgs/development/compilers/llvm/13/llvm/default.nix +++ b/pkgs/development/compilers/llvm/13/llvm/default.nix @@ -81,7 +81,7 @@ in stdenv.mkDerivation (rec { # of the flags used for the normal LLVM build. To avoid the need for building # a native libLLVM.so (which would fail) we force llvm-config to be linked # statically against the necessary LLVM components always. - ../../llvm-config-link-static.patch + ../../common/llvm/llvm-config-link-static.patch ./gnu-install-dirs.patch @@ -128,7 +128,7 @@ in stdenv.mkDerivation (rec { rm unittests/IR/PassBuilderCallbacksTest.cpp rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test '' + optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -i ${../../TLI-musl.patch} + patch -p1 -i ${../../common/llvm/TLI-musl.patch} substituteInPlace unittests/Support/CMakeLists.txt \ --replace "add_subdirectory(DynamicLibrary)" "" rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @@ -164,6 +164,8 @@ in stdenv.mkDerivation (rec { # E.g. mesa.drivers use the build-id as a cache key (see #93946): LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; + hardeningDisable = [ "trivialautovarinit" ]; + cmakeBuildType = if debugVersion then "Debug" else "Release"; cmakeFlags = with stdenv; let diff --git a/pkgs/development/compilers/llvm/14/clang/default.nix b/pkgs/development/compilers/llvm/14/clang/default.nix index f63f55cfa5466..829edb15d6008 100644 --- a/pkgs/development/compilers/llvm/14/clang/default.nix +++ b/pkgs/development/compilers/llvm/14/clang/default.nix @@ -46,7 +46,7 @@ let ./gnu-install-dirs.patch ../../common/clang/add-nostdlibinc-flag.patch (substituteAll { - src = ../../clang-11-15-LLVMgold-path.patch; + src = ../../common/clang/clang-11-15-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; }) ]; diff --git a/pkgs/development/compilers/llvm/14/libcxx/default.nix b/pkgs/development/compilers/llvm/14/libcxx/default.nix index 3e42a8b1e43c7..ad9e82291cde7 100644 --- a/pkgs/development/compilers/llvm/14/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/14/libcxx/default.nix @@ -41,7 +41,7 @@ stdenv.mkDerivation rec { patches = [ ./gnu-install-dirs.patch ] ++ lib.optionals stdenv.hostPlatform.isMusl [ - ../../libcxx-0001-musl-hacks.patch + ../../common/libcxx/libcxx-0001-musl-hacks.patch ]; preConfigure = lib.optionalString stdenv.hostPlatform.isMusl '' diff --git a/pkgs/development/compilers/llvm/14/llvm/default.nix b/pkgs/development/compilers/llvm/14/llvm/default.nix index eab49d326ad4b..124d07e4bb2b1 100644 --- a/pkgs/development/compilers/llvm/14/llvm/default.nix +++ b/pkgs/development/compilers/llvm/14/llvm/default.nix @@ -94,6 +94,12 @@ in stdenv.mkDerivation (rec { relative = "llvm"; hash = "sha256-XPbvNJ45SzjMGlNUgt/IgEvM2dHQpDOe6woUJY+nUYA="; }) + # fix RuntimeDyld usage on aarch64-linux (e.g. python312Packages.numba tests) + (fetchpatch { + url = "https://github.com/llvm/llvm-project/commit/2e1b838a889f9793d4bcd5dbfe10db9796b77143.patch"; + relative = "llvm"; + hash = "sha256-Ot45P/iwaR4hkcM3xtLwfryQNgHI6pv6ADjv98tgdZA="; + }) ] ++ lib.optional enablePolly ./gnu-install-dirs-polly.patch; postPatch = optionalString stdenv.isDarwin '' @@ -110,7 +116,7 @@ in stdenv.mkDerivation (rec { rm unittests/IR/PassBuilderCallbacksTest.cpp rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test '' + optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -i ${../../TLI-musl.patch} + patch -p1 -i ${../../common/llvm/TLI-musl.patch} substituteInPlace unittests/Support/CMakeLists.txt \ --replace "add_subdirectory(DynamicLibrary)" "" rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @@ -162,6 +168,8 @@ in stdenv.mkDerivation (rec { # E.g. mesa.drivers use the build-id as a cache key (see #93946): LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; + hardeningDisable = [ "trivialautovarinit" ]; + cmakeBuildType = if debugVersion then "Debug" else "Release"; cmakeFlags = with stdenv; let diff --git a/pkgs/development/compilers/llvm/15/clang/default.nix b/pkgs/development/compilers/llvm/15/clang/default.nix index 9ec15a3930040..de789edaa9ff2 100644 --- a/pkgs/development/compilers/llvm/15/clang/default.nix +++ b/pkgs/development/compilers/llvm/15/clang/default.nix @@ -52,7 +52,7 @@ let ./gnu-install-dirs.patch ../../common/clang/add-nostdlibinc-flag.patch (substituteAll { - src = ../../clang-11-15-LLVMgold-path.patch; + src = ../../common/clang/clang-11-15-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; }) ]; diff --git a/pkgs/development/compilers/llvm/15/libcxx/default.nix b/pkgs/development/compilers/llvm/15/libcxx/default.nix index be56770039d80..6a055581fffd5 100644 --- a/pkgs/development/compilers/llvm/15/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/15/libcxx/default.nix @@ -65,7 +65,7 @@ stdenv.mkDerivation rec { relative = "libcxx"; }) ] ++ lib.optionals stdenv.hostPlatform.isMusl [ - ../../libcxx-0001-musl-hacks.patch + ../../common/libcxx/libcxx-0001-musl-hacks.patch ]; postPatch = '' diff --git a/pkgs/development/compilers/llvm/15/llvm/default.nix b/pkgs/development/compilers/llvm/15/llvm/default.nix index 4f17678ba14f7..d7ebcbcf8b760 100644 --- a/pkgs/development/compilers/llvm/15/llvm/default.nix +++ b/pkgs/development/compilers/llvm/15/llvm/default.nix @@ -230,7 +230,7 @@ in stdenv.mkDerivation (rec { # timing-based tests are trouble rm utils/lit/tests/googletest-timeout.py '' + optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -i ${../../TLI-musl.patch} + patch -p1 -i ${../../common/llvm/TLI-musl.patch} substituteInPlace unittests/Support/CMakeLists.txt \ --replace "add_subdirectory(DynamicLibrary)" "" rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @@ -300,6 +300,8 @@ in stdenv.mkDerivation (rec { # E.g. mesa.drivers use the build-id as a cache key (see #93946): LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; + hardeningDisable = [ "trivialautovarinit" ]; + cmakeBuildType = if debugVersion then "Debug" else "Release"; cmakeFlags = with stdenv; let diff --git a/pkgs/development/compilers/llvm/16/clang/default.nix b/pkgs/development/compilers/llvm/16/clang/default.nix index 43c497b927615..c5d9af356d9ea 100644 --- a/pkgs/development/compilers/llvm/16/clang/default.nix +++ b/pkgs/development/compilers/llvm/16/clang/default.nix @@ -52,7 +52,7 @@ let ./gnu-install-dirs.patch ../../common/clang/add-nostdlibinc-flag.patch (substituteAll { - src = ../../clang-at-least-16-LLVMgold-path.patch; + src = ../../common/clang/clang-at-least-16-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; }) ]; diff --git a/pkgs/development/compilers/llvm/16/default.nix b/pkgs/development/compilers/llvm/16/default.nix index db9385043be26..143076c3f76ee 100644 --- a/pkgs/development/compilers/llvm/16/default.nix +++ b/pkgs/development/compilers/llvm/16/default.nix @@ -149,6 +149,10 @@ in let inherit llvm_meta; }; + mlir = callPackage ../common/mlir { + inherit llvm_meta; + }; + lldb = callPackage ../common/lldb.nix { src = callPackage ({ runCommand }: runCommand "lldb-src-${version}" {} '' mkdir -p "$out" diff --git a/pkgs/development/compilers/llvm/16/llvm/default.nix b/pkgs/development/compilers/llvm/16/llvm/default.nix index 73fb6a7854131..aed9c367d1ad3 100644 --- a/pkgs/development/compilers/llvm/16/llvm/default.nix +++ b/pkgs/development/compilers/llvm/16/llvm/default.nix @@ -223,7 +223,7 @@ in # timing-based tests are trouble rm utils/lit/tests/googletest-timeout.py '' + optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -i ${../../TLI-musl.patch} + patch -p1 -i ${../../common/llvm/TLI-musl.patch} substituteInPlace unittests/Support/CMakeLists.txt \ --replace "add_subdirectory(DynamicLibrary)" "" rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @@ -287,6 +287,8 @@ in # E.g. mesa.drivers use the build-id as a cache key (see #93946): LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; + hardeningDisable = [ "trivialautovarinit" ]; + cmakeBuildType = if debugVersion then "Debug" else "Release"; cmakeFlags = with stdenv; let diff --git a/pkgs/development/compilers/llvm/17/clang/default.nix b/pkgs/development/compilers/llvm/17/clang/default.nix index f2f114233c283..f7922f3d99515 100644 --- a/pkgs/development/compilers/llvm/17/clang/default.nix +++ b/pkgs/development/compilers/llvm/17/clang/default.nix @@ -53,7 +53,7 @@ let ./gnu-install-dirs.patch ../../common/clang/add-nostdlibinc-flag.patch (substituteAll { - src = ../../clang-at-least-16-LLVMgold-path.patch; + src = ../../common/clang/clang-at-least-16-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; }) ]; diff --git a/pkgs/development/compilers/llvm/17/default.nix b/pkgs/development/compilers/llvm/17/default.nix index 67076da64941b..60cae920945b7 100644 --- a/pkgs/development/compilers/llvm/17/default.nix +++ b/pkgs/development/compilers/llvm/17/default.nix @@ -144,7 +144,7 @@ in let inherit llvm_meta; }; - mlir = callPackage ./mlir { + mlir = callPackage ../common/mlir { inherit llvm_meta; }; diff --git a/pkgs/development/compilers/llvm/17/llvm/default.nix b/pkgs/development/compilers/llvm/17/llvm/default.nix index 627679ce812fc..2c5d6aeb5cec9 100644 --- a/pkgs/development/compilers/llvm/17/llvm/default.nix +++ b/pkgs/development/compilers/llvm/17/llvm/default.nix @@ -220,7 +220,7 @@ stdenv.mkDerivation (rec { rm unittests/IR/PassBuilderCallbacksTest.cpp rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test '' + optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -i ${../../TLI-musl.patch} + patch -p1 -i ${../../common/llvm/TLI-musl.patch} substituteInPlace unittests/Support/CMakeLists.txt \ --replace "add_subdirectory(DynamicLibrary)" "" rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp diff --git a/pkgs/development/compilers/llvm/9/clang/default.nix b/pkgs/development/compilers/llvm/9/clang/default.nix index e8a2a4bd0db19..37138b13bd4c8 100644 --- a/pkgs/development/compilers/llvm/9/clang/default.nix +++ b/pkgs/development/compilers/llvm/9/clang/default.nix @@ -52,7 +52,7 @@ let ./HIP-use-PATH-9.patch ./gnu-install-dirs.patch (substituteAll { - src = ../../clang-6-10-LLVMgold-path.patch; + src = ../../common/clang/clang-6-10-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; }) ]; diff --git a/pkgs/development/compilers/llvm/9/libcxx/default.nix b/pkgs/development/compilers/llvm/9/libcxx/default.nix index ec09998ed37d0..65f0e19225a5e 100644 --- a/pkgs/development/compilers/llvm/9/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/9/libcxx/default.nix @@ -22,7 +22,7 @@ stdenv.mkDerivation { patches = [ ./gnu-install-dirs.patch ] ++ lib.optionals stdenv.hostPlatform.isMusl [ - ../../libcxx-0001-musl-hacks.patch + ../../common/libcxx/libcxx-0001-musl-hacks.patch ]; # Prevent errors like "error: 'foo' is unavailable: introduced in macOS yy.zz" diff --git a/pkgs/development/compilers/llvm/9/libcxxabi/default.nix b/pkgs/development/compilers/llvm/9/libcxxabi/default.nix index 24d89b1a2da5c..7d4a83db390b1 100644 --- a/pkgs/development/compilers/llvm/9/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/9/libcxxabi/default.nix @@ -17,7 +17,7 @@ stdenv.mkDerivation { '' + lib.optionalString stdenv.isDarwin '' export TRIPLE=x86_64-apple-darwin '' + lib.optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -d $(ls -d libcxx-*) -i ${../../libcxx-0001-musl-hacks.patch} + patch -p1 -d $(ls -d libcxx-*) -i ${../../common/libcxx/libcxx-0001-musl-hacks.patch} '' + lib.optionalString stdenv.hostPlatform.isWasm '' patch -p1 -d $(ls -d llvm-*) -i ${../../common/libcxxabi/wasm.patch} ''; diff --git a/pkgs/development/compilers/llvm/9/llvm/default.nix b/pkgs/development/compilers/llvm/9/llvm/default.nix index c0ef7801c348a..f8f1c67670ecc 100644 --- a/pkgs/development/compilers/llvm/9/llvm/default.nix +++ b/pkgs/development/compilers/llvm/9/llvm/default.nix @@ -86,12 +86,12 @@ in stdenv.mkDerivation (rec { # of the flags used for the normal LLVM build. To avoid the need for building # a native libLLVM.so (which would fail) we force llvm-config to be linked # statically against the necessary LLVM components always. - ../../llvm-config-link-static.patch + ../../common/llvm/llvm-config-link-static.patch ./gnu-install-dirs.patch # Force a test to evaluate the saved benchmark for a CPU for which LLVM has # an execution model. See NixOS/nixpkgs#119673. - ../../exegesis-force-bdver2.patch + ./exegesis-force-bdver2.patch # Fix missing includes for GCC 11 (fetchpatch { @@ -137,7 +137,7 @@ in stdenv.mkDerivation (rec { --replace "Path.cpp" "" rm unittests/Support/Path.cpp '' + optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -i ${../../TLI-musl.patch} + patch -p1 -i ${../../common/llvm/TLI-musl.patch} substituteInPlace unittests/Support/CMakeLists.txt \ --replace "add_subdirectory(DynamicLibrary)" "" rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @@ -203,6 +203,8 @@ in stdenv.mkDerivation (rec { ln -sv $PWD/lib $out ''; + hardeningDisable = [ "trivialautovarinit" ]; + cmakeBuildType = if debugVersion then "Debug" else "Release"; cmakeFlags = with stdenv; let diff --git a/pkgs/development/compilers/llvm/exegesis-force-bdver2.patch b/pkgs/development/compilers/llvm/9/llvm/exegesis-force-bdver2.patch index c2654153ed5af..c2654153ed5af 100644 --- a/pkgs/development/compilers/llvm/exegesis-force-bdver2.patch +++ b/pkgs/development/compilers/llvm/9/llvm/exegesis-force-bdver2.patch diff --git a/pkgs/development/compilers/llvm/clang-11-15-LLVMgold-path.patch b/pkgs/development/compilers/llvm/common/clang/clang-11-15-LLVMgold-path.patch index 8f8991976f33c..8f8991976f33c 100644 --- a/pkgs/development/compilers/llvm/clang-11-15-LLVMgold-path.patch +++ b/pkgs/development/compilers/llvm/common/clang/clang-11-15-LLVMgold-path.patch diff --git a/pkgs/development/compilers/llvm/clang-6-10-LLVMgold-path.patch b/pkgs/development/compilers/llvm/common/clang/clang-6-10-LLVMgold-path.patch index 93504316edf30..93504316edf30 100644 --- a/pkgs/development/compilers/llvm/clang-6-10-LLVMgold-path.patch +++ b/pkgs/development/compilers/llvm/common/clang/clang-6-10-LLVMgold-path.patch diff --git a/pkgs/development/compilers/llvm/clang-at-least-16-LLVMgold-path.patch b/pkgs/development/compilers/llvm/common/clang/clang-at-least-16-LLVMgold-path.patch index 74cdbacc8a717..74cdbacc8a717 100644 --- a/pkgs/development/compilers/llvm/clang-at-least-16-LLVMgold-path.patch +++ b/pkgs/development/compilers/llvm/common/clang/clang-at-least-16-LLVMgold-path.patch diff --git a/pkgs/development/compilers/llvm/libcxx-0001-musl-hacks.patch b/pkgs/development/compilers/llvm/common/libcxx/libcxx-0001-musl-hacks.patch index bcb5ad8cfb87d..bcb5ad8cfb87d 100644 --- a/pkgs/development/compilers/llvm/libcxx-0001-musl-hacks.patch +++ b/pkgs/development/compilers/llvm/common/libcxx/libcxx-0001-musl-hacks.patch diff --git a/pkgs/development/compilers/llvm/TLI-musl.patch b/pkgs/development/compilers/llvm/common/llvm/TLI-musl.patch index 1a69080866372..1a69080866372 100644 --- a/pkgs/development/compilers/llvm/TLI-musl.patch +++ b/pkgs/development/compilers/llvm/common/llvm/TLI-musl.patch diff --git a/pkgs/development/compilers/llvm/llvm-config-link-static.patch b/pkgs/development/compilers/llvm/common/llvm/llvm-config-link-static.patch index 3881cc5206e27..3881cc5206e27 100644 --- a/pkgs/development/compilers/llvm/llvm-config-link-static.patch +++ b/pkgs/development/compilers/llvm/common/llvm/llvm-config-link-static.patch diff --git a/pkgs/development/compilers/llvm/17/mlir/default.nix b/pkgs/development/compilers/llvm/common/mlir/default.nix index 8e99fa0fe337f..7a79ac30ba864 100644 --- a/pkgs/development/compilers/llvm/17/mlir/default.nix +++ b/pkgs/development/compilers/llvm/common/mlir/default.nix @@ -17,22 +17,28 @@ stdenv.mkDerivation rec { src = runCommand "${pname}-src-${version}" {} '' mkdir -p "$out" cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" + cp -r ${monorepoSrc}/mlir "$out" cp -r ${monorepoSrc}/third-party "$out/third-party" mkdir -p "$out/llvm" ''; - sourceRoot = "${src.name}/${pname}"; + sourceRoot = "${src.name}/mlir"; patches = [ ./gnu-install-dirs.patch ]; - nativeBuildInputs = [ cmake ninja ]; - buildInputs = [ libllvm libxml2 ]; + nativeBuildInputs = [ + cmake + ninja + ]; + + buildInputs = [ + libllvm + libxml2 + ]; - ninjaFlags = [ "-v " ]; cmakeFlags = [ "-DLLVM_BUILD_TOOLS=ON" # Install headers as well @@ -45,11 +51,11 @@ stdenv.mkDerivation rec { "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" "-DLLVM_ENABLE_DUMP=ON" - ] ++ lib.optionals stdenv.hostPlatform.isStatic [ + ] ++ lib.optionals stdenv.hostPlatform.isStatic [ # Disables building of shared libs, -fPIC is still injected by cc-wrapper "-DLLVM_ENABLE_PIC=OFF" "-DLLVM_BUILD_STATIC=ON" - "-DLLVM_LINK_LLVM_DYLIB=off" + "-DLLVM_LINK_LLVM_DYLIB=OFF" ] ++ lib.optionals ((stdenv.hostPlatform != stdenv.buildPlatform) && !(stdenv.buildPlatform.canExecute stdenv.hostPlatform)) [ "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" "-DMLIR_TABLEGEN_EXE=${buildLlvmTools.mlir}/bin/mlir-tblgen" diff --git a/pkgs/development/compilers/llvm/17/mlir/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/common/mlir/gnu-install-dirs.patch index 95191022d1a38..95191022d1a38 100644 --- a/pkgs/development/compilers/llvm/17/mlir/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/common/mlir/gnu-install-dirs.patch diff --git a/pkgs/development/compilers/llvm/git/clang/default.nix b/pkgs/development/compilers/llvm/git/clang/default.nix index eea346ef22efc..01b33c540ca28 100644 --- a/pkgs/development/compilers/llvm/git/clang/default.nix +++ b/pkgs/development/compilers/llvm/git/clang/default.nix @@ -54,7 +54,7 @@ let ./gnu-install-dirs.patch ../../common/clang/add-nostdlibinc-flag.patch (substituteAll { - src = ../../clang-at-least-16-LLVMgold-path.patch; + src = ../../common/clang/clang-at-least-16-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; }) ]; diff --git a/pkgs/development/compilers/llvm/git/compiler-rt/default.nix b/pkgs/development/compilers/llvm/git/compiler-rt/default.nix index 0f15a9e12cde5..7b44a872adc4a 100644 --- a/pkgs/development/compilers/llvm/git/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/git/compiler-rt/default.nix @@ -116,7 +116,7 @@ stdenv.mkDerivation { --replace "#include <stdlib.h>" "" substituteInPlace lib/builtins/clear_cache.c \ --replace "#include <assert.h>" "" - substituteInPlace lib/builtins/cpu_model.c \ + substituteInPlace lib/builtins/cpu_model${lib.optionalString (lib.versionAtLeast version "18") "/x86"}.c \ --replace "#include <assert.h>" "" ''; diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index 7dfec234104d9..f968ebecb2c8e 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -1,5 +1,5 @@ -{ lowPrio, newScope, pkgs, lib, stdenv, stdenvNoCC, cmake, ninja -, gccForLibs, preLibcCrossHeaders +{ lowPrio, newScope, pkgs, lib, stdenv, cmake, ninja +, preLibcCrossHeaders , libxml2, python3, fetchFromGitHub, overrideCC, wrapCCWith, wrapBintoolsWith , buildLlvmTools # tools, but from the previous stage, for cross , targetLlvmLibraries # libraries, but from the next stage, for cross @@ -17,12 +17,7 @@ else pkgs.bintools , darwin # LLVM release information; specify one of these but not both: -, gitRelease ? { - version = "18.0.0"; - rev = "2fd7657b6609454af7adb75765d164ec7d1bb80b"; - rev-version = "18.0.0-unstable-2023-12-13"; - sha256 = "sha256-/sMQzzFid0tAnreOIV9SUm2H6QbEGhpNcizl3LDPM5s="; -} +, gitRelease ? null # i.e.: # { # version = /* i.e. "15.0.0" */; @@ -30,7 +25,7 @@ # rev-version = /* human readable version; i.e. "unstable-2022-26-07" */; # sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */; # } -, officialRelease ? null +, officialRelease ? { version = "18.1.0-rc4"; sha256 = "sha256-fVpwewbjoPMPslIEZ+WAtaQ+YKc0XWGl8EbP/TbQb8o="; } # i.e.: # { # version = /* i.e. "15.0.0" */; @@ -149,6 +144,10 @@ in let inherit llvm_meta; }; + mlir = callPackage ../common/mlir { + inherit llvm_meta; + }; + lldb = callPackage ../common/lldb.nix { src = callPackage ({ runCommand }: runCommand "lldb-src-${version}" {} '' mkdir -p "$out" @@ -275,6 +274,12 @@ in let nixSupport.cc-cflags = [ "-fno-exceptions" ]; }); + # 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; + }; }); libraries = lib.makeExtensible (libraries: let diff --git a/pkgs/development/compilers/llvm/git/libcxx/0001-darwin-10.12-mbstate_t-fix.patch b/pkgs/development/compilers/llvm/git/libcxx/0001-darwin-10.12-mbstate_t-fix.patch new file mode 100644 index 0000000000000..0a2e8db07391c --- /dev/null +++ b/pkgs/development/compilers/llvm/git/libcxx/0001-darwin-10.12-mbstate_t-fix.patch @@ -0,0 +1,31 @@ +From 9c1cb26c1dd3f92d1c1177e548107d2cd3c5e616 Mon Sep 17 00:00:00 2001 +From: annalee <150648636+a-n-n-a-l-e-e@users.noreply.github.com> +Date: Fri, 23 Feb 2024 22:58:58 +0000 +Subject: [PATCH] darwin 10.12 mbstate_t fix + +https://github.com/llvm/llvm-project/issues/64226 + +removes space from +https://github.com/macports/macports-ports/raw/acd8acb171f1658596ed1cf25da48d5b932e2d19/lang/llvm-17/files/0042-mbstate_t-not-defined.patch +so it applies cleanly +--- + include/__mbstate_t.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/include/__mbstate_t.h b/include/__mbstate_t.h +index bfa6d61..5f51112 100644 +--- a/include/__mbstate_t.h ++++ b/include/__mbstate_t.h +@@ -42,6 +42,9 @@ + #elif __has_include(<bits/types/mbstate_t.h>) + # include <bits/types/mbstate_t.h> // works on most Unixes + #elif __has_include(<sys/_types/_mbstate_t.h>) ++# if __has_include(<machine/_types.h>) ++# include <machine/_types.h> ++# endif + # include <sys/_types/_mbstate_t.h> // works on Darwin + #elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) && __has_include_next(<wchar.h>) + # include_next <wchar.h> // fall back to the C standard provider of mbstate_t +-- +2.43.0 + diff --git a/pkgs/development/compilers/llvm/git/libcxx/default.nix b/pkgs/development/compilers/llvm/git/libcxx/default.nix index 8a5272ea07af0..11f4c6fe5fd10 100644 --- a/pkgs/development/compilers/llvm/git/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxx/default.nix @@ -45,15 +45,9 @@ stdenv.mkDerivation rec { chmod -R u+w . ''; - patches = [ - # fix for https://github.com/NixOS/nixpkgs/issues/269548 - # https://github.com/llvm/llvm-project/pull/77218 - (fetchpatch { - name = "darwin-system-libcxxabi-link-flags.patch"; - url = "https://github.com/llvm/llvm-project/commit/c5b89b29ee6e3c444a355fd1cf733ce7ab2e316a.patch"; - hash = "sha256-LNoPg1KCoP8RWxU/AzHR52f4Dww24I9BGQJedMhFxyQ="; - relative = "libcxx"; - }) + patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [ + # https://github.com/llvm/llvm-project/issues/64226 + ./0001-darwin-10.12-mbstate_t-fix.patch ]; postPatch = '' @@ -82,7 +76,9 @@ stdenv.mkDerivation rec { "-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}" ] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1" ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" - ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ + ++ lib.optionals (lib.versionAtLeast version "18" && !(stdenv.hostPlatform.useLLVM or false) && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [ + "-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s" + ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ "-DLIBCXX_USE_COMPILER_RT=ON" # There's precedent for this in llvm-project/libcxx/cmake/caches. # In a monorepo build you might do the following in the libcxxabi build: diff --git a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix b/pkgs/development/compilers/llvm/git/libcxxabi/default.nix index 0a795da44ae41..8e19796543250 100644 --- a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxxabi/default.nix @@ -44,6 +44,20 @@ stdenv.mkDerivation rec { sha256 = "1xyjd56m4pfwq8p3xh6i8lhkk9kq15jaml7qbhxdf87z4jjkk63a"; stripLen = 1; }) + ] ++ lib.optionals (lib.versionAtLeast version "18") [ + # Allow building libcxxabi alone when using LLVM unwinder + (fetchpatch { + url = "https://github.com/llvm/llvm-project/commit/77610dd10454e87bb387040d2b51100a17ac5755.patch"; + stripLen = 1; + revert = true; + hash = "sha256-Jogx/cvTJ6fdyprTD1QzMIeRWcBlZZMWE/y9joOtVH0="; + }) + (fetchpatch { + url = "https://github.com/llvm/llvm-project/commit/48e5b5ea92674ded69b998cf35724d9012c0f57d.patch"; + stripLen = 1; + revert = true; + hash = "sha256-7VeBFjG7CnEMWn0hpBvyNOyhRfz50PnD3zyQNDhNChk="; + }) ]; postPatch = '' @@ -63,6 +77,8 @@ stdenv.mkDerivation rec { # CMake however checks for this anyways; this flag tells it not to. See: # https://github.com/llvm/llvm-project/blob/4bd3f3759259548e159aeba5c76efb9a0864e6fa/llvm/runtimes/CMakeLists.txt#L243 "-DCMAKE_CXX_COMPILER_WORKS=ON" + ] ++ lib.optionals (lib.versionAtLeast version "18" && !(stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm)) [ + "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF" ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [ "-DLLVM_ENABLE_LIBCXX=ON" "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" @@ -110,8 +126,5 @@ stdenv.mkDerivation rec { # the UIUC License (a BSD-like license)": license = with lib.licenses; [ mit ncsa ]; maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ]; - # Broken until https://github.com/llvm/llvm-project/issues/64226 is resolved - # We should check if the version is not 10.13 but that is currently broken. - broken = stdenv.isDarwin && stdenv.isx86_64; }; } diff --git a/pkgs/development/compilers/llvm/git/llvm/default.nix b/pkgs/development/compilers/llvm/git/llvm/default.nix index 3c52b7a9bb0bf..6dc2b51aaf9a8 100644 --- a/pkgs/development/compilers/llvm/git/llvm/default.nix +++ b/pkgs/development/compilers/llvm/git/llvm/default.nix @@ -224,7 +224,7 @@ stdenv.mkDerivation (rec { rm unittests/IR/PassBuilderCallbacksTest.cpp rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test '' + optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -i ${../../TLI-musl.patch} + patch -p1 -i ${../../common/llvm/TLI-musl.patch} substituteInPlace unittests/Support/CMakeLists.txt \ --replace "add_subdirectory(DynamicLibrary)" "" rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @@ -290,6 +290,8 @@ stdenv.mkDerivation (rec { # E.g. mesa.drivers use the build-id as a cache key (see #93946): LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; + hardeningDisable = [ "trivialautovarinit" ]; + cmakeBuildType = if debugVersion then "Debug" else "Release"; cmakeFlags = with stdenv; let diff --git a/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch b/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch index b01363e98aa00..442ebddad3f60 100644 --- a/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch +++ b/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch @@ -6,14 +6,14 @@ diff --git a/tools/polly/cmake/polly_macros.cmake b/tools/polly/cmake/polly_macr index 518a09b45a42..bd9d6f5542ad 100644 --- a/tools/polly/cmake/polly_macros.cmake +++ b/tools/polly/cmake/polly_macros.cmake -@@ -44,8 +44,8 @@ macro(add_polly_library name) - if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly") +@@ -45,8 +45,8 @@ macro(add_polly_library name) install(TARGETS ${name} + COMPONENT ${name} EXPORT LLVMExports - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) -+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) + add_llvm_install_targets(install-${name} + COMPONENT ${name}) endif() - set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) - endmacro(add_polly_library) diff --git a/pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch index 77a93208832a1..0d0d4130c7610 100644 --- a/pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch @@ -6,17 +6,17 @@ index b6ddbe90516d..311ab1d50e7f 100644 set(OPENMP_LIBDIR_SUFFIX "" CACHE STRING "Suffix of lib installation directory, e.g. 64 => lib64") # Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR. -- set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}") -+ set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}") +- set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}" CACHE STRING ++ set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}" CACHE STRING + "Path where built OpenMP libraries should be installed.") # Group test settings. - set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING -@@ -40,7 +40,7 @@ if (OPENMP_STANDALONE_BUILD) +@@ -47,7 +47,7 @@ if (OPENMP_STANDALONE_BUILD) else() set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR}) # If building in tree, we honor the same install suffix LLVM uses. -- set(OPENMP_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}") -+ set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") +- set(OPENMP_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}" CACHE STRING ++ set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" CACHE STRING + "Path where built OpenMP libraries should be installed.") if (NOT MSVC) - set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) |