From 87e4857acdda2a8be307365f5331312e4e157372 Mon Sep 17 00:00:00 2001 From: Rahul Butani Date: Sun, 8 Jan 2023 06:12:31 -0800 Subject: [PATCH] llvmPackages_15: apply some patches from `llvmPackages_14` See #194634 for details. PRs: - #191372 - #190936 - #82131 - #199844 - #197674 - #184408 - #193004 --- pkgs/development/compilers/llvm/15/clang/default.nix | 2 ++ .../compilers/llvm/15/compiler-rt/default.nix | 5 +++++ pkgs/development/compilers/llvm/15/default.nix | 5 +++-- pkgs/development/compilers/llvm/15/libcxxabi/default.nix | 2 +- pkgs/development/compilers/llvm/15/lld/default.nix | 1 + pkgs/development/compilers/llvm/15/llvm/default.nix | 9 +++++---- pkgs/development/compilers/llvm/15/openmp/default.nix | 5 ++++- pkgs/top-level/all-packages.nix | 3 +-- 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/pkgs/development/compilers/llvm/15/clang/default.nix b/pkgs/development/compilers/llvm/15/clang/default.nix index 3110bef09e969..d10c358ae1974 100644 --- a/pkgs/development/compilers/llvm/15/clang/default.nix +++ b/pkgs/development/compilers/llvm/15/clang/default.nix @@ -84,6 +84,7 @@ let fi mv $out/share/clang/*.py $python/share/clang rm $out/bin/c-index-test + patchShebangs $python/bin mkdir -p $dev/bin cp bin/clang-tblgen $dev/bin @@ -108,6 +109,7 @@ let of tools that can be built using the Clang frontend as a library to parse C/C++ code. ''; + mainProgram = "clang"; }; } // lib.optionalAttrs enableManpages { pname = "clang-manpages"; diff --git a/pkgs/development/compilers/llvm/15/compiler-rt/default.nix b/pkgs/development/compilers/llvm/15/compiler-rt/default.nix index ce28a7ef9bbd0..7b0996845e2e5 100644 --- a/pkgs/development/compilers/llvm/15/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/15/compiler-rt/default.nix @@ -1,6 +1,7 @@ { lib, stdenv, llvm_meta, version , monorepoSrc, runCommand , cmake, python3, libllvm, libcxxabi, libxcrypt +, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD }: let @@ -46,6 +47,8 @@ stdenv.mkDerivation { "-DCOMPILER_RT_BUILD_PROFILE=OFF" "-DCOMPILER_RT_BUILD_MEMPROF=OFF" "-DCOMPILER_RT_BUILD_ORC=OFF" # may be possible to build with musl if necessary + ] ++ lib.optionals (useLLVM || bareMetal) [ + "-DCOMPILER_RT_BUILD_PROFILE=OFF" ] ++ lib.optionals ((useLLVM && !haveLibc) || bareMetal) [ "-DCMAKE_C_COMPILER_WORKS=ON" "-DCMAKE_CXX_COMPILER_WORKS=ON" @@ -107,6 +110,8 @@ stdenv.mkDerivation { ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o + '' + lib.optionalString doFakeLibgcc '' + ln -s $out/lib/freebsd/libclang_rt.builtins-*.a $out/lib/libgcc.a ''; meta = llvm_meta // { diff --git a/pkgs/development/compilers/llvm/15/default.nix b/pkgs/development/compilers/llvm/15/default.nix index 3a1ba402ef671..26c0e23942068 100644 --- a/pkgs/development/compilers/llvm/15/default.nix +++ b/pkgs/development/compilers/llvm/15/default.nix @@ -3,6 +3,7 @@ , libxml2, python3, isl, fetchFromGitHub, overrideCC, wrapCCWith, wrapBintoolsWith , buildLlvmTools # tools, but from the previous stage, for cross , targetLlvmLibraries # libraries, but from the next stage, for cross +, targetLlvm # This is the default binutils, but with *this* version of LLD rather # than the default LLVM verion's, if LLD is the choice. We use these for # the `useLLVM` bootstrapping below. @@ -166,7 +167,7 @@ let ] ++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind" ++ lib.optional - (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) + (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) "-lunwind" ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; }; @@ -273,7 +274,7 @@ let }; openmp = callPackage ./openmp { - inherit llvm_meta; + inherit llvm_meta targetLlvm; }; }); diff --git a/pkgs/development/compilers/llvm/15/libcxxabi/default.nix b/pkgs/development/compilers/llvm/15/libcxxabi/default.nix index 2d4fe974c016b..6e4f2edee2b8d 100644 --- a/pkgs/development/compilers/llvm/15/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/15/libcxxabi/default.nix @@ -53,7 +53,7 @@ stdenv.mkDerivation rec { ''; nativeBuildInputs = [ cmake python3 ]; - buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind; + buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind; cmakeFlags = [ "-DLLVM_ENABLE_RUNTIMES=libcxxabi" diff --git a/pkgs/development/compilers/llvm/15/lld/default.nix b/pkgs/development/compilers/llvm/15/lld/default.nix index 9d17766436845..fea7bf227bf8a 100644 --- a/pkgs/development/compilers/llvm/15/lld/default.nix +++ b/pkgs/development/compilers/llvm/15/lld/default.nix @@ -35,6 +35,7 @@ stdenv.mkDerivation rec { ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" ]; + LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152"; outputs = [ "out" "lib" "dev" ]; diff --git a/pkgs/development/compilers/llvm/15/llvm/default.nix b/pkgs/development/compilers/llvm/15/llvm/default.nix index 656c226574a41..5730006a8985f 100644 --- a/pkgs/development/compilers/llvm/15/llvm/default.nix +++ b/pkgs/development/compilers/llvm/15/llvm/default.nix @@ -18,10 +18,10 @@ , debugVersion ? false , enableManpages ? false , enableSharedLibraries ? !stdenv.hostPlatform.isStatic -, enablePFM ? !(stdenv.isDarwin - || stdenv.isAarch64 # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245 - || stdenv.isAarch32 # broken for the armv7l builder -) +, enablePFM ? stdenv.isLinux /* PFM only supports Linux */ + # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245 + # broken for the armv7l builder + && !stdenv.hostPlatform.isAarch , enablePolly ? false } @args: @@ -141,6 +141,7 @@ in stdenv.mkDerivation (rec { # 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" # libxml2 needs to be disabled because the LLVM build system ignores its .la # file and doesn't link zlib as well. # https://github.com/ClangBuiltLinux/tc-build/issues/150#issuecomment-845418812 diff --git a/pkgs/development/compilers/llvm/15/openmp/default.nix b/pkgs/development/compilers/llvm/15/openmp/default.nix index 9355fe667f0cc..7c2ab76c52583 100644 --- a/pkgs/development/compilers/llvm/15/openmp/default.nix +++ b/pkgs/development/compilers/llvm/15/openmp/default.nix @@ -5,6 +5,7 @@ , runCommand , cmake , llvm +, targetLlvm , lit , clang-unwrapped , perl @@ -33,7 +34,9 @@ stdenv.mkDerivation rec { outputs = [ "out" "dev" ]; nativeBuildInputs = [ cmake perl pkg-config lit ]; - buildInputs = [ llvm ]; + buildInputs = [ + (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) + ]; # Unsup:Pass:XFail:Fail # 26:267:16:8 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 206a47aa2a7cd..dda69ec394f53 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15172,8 +15172,7 @@ with pkgs; inherit (stdenvAdapters) overrideCC; buildLlvmTools = buildPackages.llvmPackages_15.tools; targetLlvmLibraries = targetPackages.llvmPackages_15.libraries or llvmPackages_15.libraries; - } // lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.hostPlatform == stdenv.buildPlatform && buildPackages.stdenv.cc.isGNU) { - stdenv = gcc7Stdenv; + targetLlvm = targetPackages.llvmPackages_15.llvm or llvmPackages_15.llvm; })); llvmPackages_latest = llvmPackages_14;