diff options
Diffstat (limited to 'pkgs/development/compilers/llvm/10')
4 files changed, 70 insertions, 41 deletions
diff --git a/pkgs/development/compilers/llvm/10/clang/default.nix b/pkgs/development/compilers/llvm/10/clang/default.nix index b42f40b969439..5336e4ea35a3d 100644 --- a/pkgs/development/compilers/llvm/10/clang/default.nix +++ b/pkgs/development/compilers/llvm/10/clang/default.nix @@ -29,7 +29,6 @@ let "-DCMAKE_CXX_FLAGS=-std=c++14" "-DCLANGD_BUILD_XPC=OFF" "-DLLVM_ENABLE_RTTI=ON" - "-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}" ] ++ lib.optionals enableManpages [ "-DCLANG_INCLUDE_DOCS=ON" "-DLLVM_ENABLE_SPHINX=ON" diff --git a/pkgs/development/compilers/llvm/10/default.nix b/pkgs/development/compilers/llvm/10/default.nix index 8bd7e937e7d72..5cb6c278659d8 100644 --- a/pkgs/development/compilers/llvm/10/default.nix +++ b/pkgs/development/compilers/llvm/10/default.nix @@ -89,7 +89,11 @@ let # python3 = pkgs.python3; # don't use python-boot # }); - clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; + # pick clang appropriate for package set we are targeting + clang = + /**/ if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM + else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang + else tools.libcxxClang; libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; diff --git a/pkgs/development/compilers/llvm/10/llvm/default.nix b/pkgs/development/compilers/llvm/10/llvm/default.nix index 30a2d016d67c7..bb1b90b36a922 100644 --- a/pkgs/development/compilers/llvm/10/llvm/default.nix +++ b/pkgs/development/compilers/llvm/10/llvm/default.nix @@ -57,6 +57,12 @@ in stdenv.mkDerivation (rec { propagatedBuildInputs = [ ncurses zlib ]; patches = [ + # When cross-compiling we configure llvm-config-native with an approximation + # 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 + ./gnu-install-dirs.patch # On older CPUs (e.g. Hydra/wendy) we'd be getting an error in this test. (fetchpatch { @@ -93,11 +99,6 @@ in stdenv.mkDerivation (rec { substituteInPlace cmake/modules/AddLLVM.cmake \ --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ --replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' "" - '' - # Patch llvm-config to return correct library path based on --link-{shared,static}. - + optionalString (enableSharedLibraries) '' - substitute '${./outputs.patch}' ./outputs.patch --subst-var lib - patch -p1 < ./outputs.patch '' + '' # FileSystem permissions tests fail with various special bits substituteInPlace unittests/Support/CMakeLists.txt \ @@ -122,6 +123,32 @@ in stdenv.mkDerivation (rec { rm test/ExecutionEngine/frem.ll '' + '' patchShebangs test/BugPoint/compile-custom.ll.py + '' + '' + # Tweak tests to ignore namespace part of type to support + # gcc-12: https://gcc.gnu.org/PR103598. + # The change below mangles strings like: + # CHECK-NEXT: Starting llvm::Function pass manager run. + # to: + # CHECK-NEXT: Starting {{.*}}Function pass manager run. + for f in \ + test/Other/new-pass-manager.ll \ + test/Other/new-pm-defaults.ll \ + test/Other/new-pm-lto-defaults.ll \ + test/Other/new-pm-thinlto-defaults.ll \ + test/Other/pass-pipeline-parsing.ll \ + test/Transforms/Inline/cgscc-incremental-invalidate.ll \ + test/Transforms/Inline/clear-analyses.ll \ + test/Transforms/LoopUnroll/unroll-loop-invalidation.ll \ + test/Transforms/SCCP/ipsccp-preserve-analysis.ll \ + test/Transforms/SCCP/preserve-analysis.ll \ + test/Transforms/SROA/dead-inst.ll \ + test/tools/gold/X86/new-pm.ll \ + ; do + echo "PATCH: $f" + substituteInPlace $f \ + --replace 'Starting llvm::' 'Starting {{.*}}' \ + --replace 'Finished llvm::' 'Finished {{.*}}' + done ''; # hacky fix: created binaries need to be run before installation @@ -130,18 +157,28 @@ in stdenv.mkDerivation (rec { ln -sv $PWD/lib $out ''; - cmakeFlags = with stdenv; [ - "-DLLVM_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/llvm/" + cmakeFlags = with stdenv; let + # These flags influence llvm-config's BuildVariables.inc in addition to the + # general build. We need to make sure these are also passed via + # CROSS_TOOLCHAIN_FLAGS_NATIVE when cross-compiling or llvm-config-native + # will return different results from the cross llvm-config. + # + # Some flags don't need to be repassed because LLVM already does so (like + # CMAKE_BUILD_TYPE), others are irrelevant to the result. + flagsForLlvmConfig = [ + "-DLLVM_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/llvm/" + "-DLLVM_ENABLE_RTTI=ON" + ] ++ optionals enableSharedLibraries [ + "-DLLVM_LINK_LLVM_DYLIB=ON" + ]; + in flagsForLlvmConfig ++ [ "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc - "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}" "-DLLVM_ENABLE_FFI=ON" - "-DLLVM_ENABLE_RTTI=ON" "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" "-DLLVM_ENABLE_DUMP=ON" - ] ++ optionals enableSharedLibraries [ - "-DLLVM_LINK_LLVM_DYLIB=ON" ] ++ optionals enableManpages [ "-DLLVM_BUILD_DOCS=ON" "-DLLVM_ENABLE_SPHINX=ON" @@ -167,7 +204,21 @@ in stdenv.mkDerivation (rec { "-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip" "-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib" ]; - in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=${lib.concatStringsSep ";" nativeToolchainFlags}" + # We need to repass the custom GNUInstallDirs values, otherwise CMake + # will choose them for us, leading to wrong results in llvm-config-native + nativeInstallFlags = [ + "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}" + "-DCMAKE_INSTALL_BINDIR=${placeholder "out"}/bin" + "-DCMAKE_INSTALL_INCLUDEDIR=${placeholder "dev"}/include" + "-DCMAKE_INSTALL_LIBDIR=${placeholder "lib"}/lib" + "-DCMAKE_INSTALL_LIBEXECDIR=${placeholder "lib"}/libexec" + ]; + in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=" + + lib.concatStringsSep ";" (lib.concatLists [ + flagsForLlvmConfig + nativeToolchainFlags + nativeInstallFlags + ]) ) ]; @@ -197,7 +248,8 @@ in stdenv.mkDerivation (rec { cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native ''; - doCheck = stdenv.isLinux && (!stdenv.isx86_32); + doCheck = stdenv.isLinux && (!stdenv.isx86_32) + && (stdenv.hostPlatform == stdenv.buildPlatform); checkTarget = "check-all"; diff --git a/pkgs/development/compilers/llvm/10/llvm/outputs.patch b/pkgs/development/compilers/llvm/10/llvm/outputs.patch deleted file mode 100644 index 40096fa3497fd..0000000000000 --- a/pkgs/development/compilers/llvm/10/llvm/outputs.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp -index 94d426b..37f7794 100644 ---- a/tools/llvm-config/llvm-config.cpp -+++ b/tools/llvm-config/llvm-config.cpp -@@ -333,6 +333,21 @@ int main(int argc, char **argv) { - ActiveIncludeOption = "-I" + ActiveIncludeDir; - } - -+ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared -+ if (!IsInDevelopmentTree) { -+ bool WantShared = true; -+ for (int i = 1; i < argc; ++i) { -+ StringRef Arg = argv[i]; -+ if (Arg == "--link-shared") -+ WantShared = true; -+ else if (Arg == "--link-static") -+ WantShared = false; // the last one wins -+ } -+ -+ if (WantShared) -+ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX; -+ } -+ - /// We only use `shared library` mode in cases where the static library form - /// of the components provided are not available; note however that this is - /// skipped if we're run from within the build dir. However, once installed, |