diff options
author | Tristan Ross <tristan.ross@midstall.com> | 2024-03-24 09:59:15 -0700 |
---|---|---|
committer | Tristan Ross <tristan.ross@midstall.com> | 2024-03-27 19:47:59 -0700 |
commit | aac3118ab56b878f5775b4302c70afc654de75ba (patch) | |
tree | fdc3f197622f6a8ef5666a9099a729127869601c /pkgs/development/compilers/llvm | |
parent | c635984e73c4c50215da7188732888ad8cc7abb5 (diff) |
llvmPackages_18: init
Diffstat (limited to 'pkgs/development/compilers/llvm')
8 files changed, 36 insertions, 60 deletions
diff --git a/pkgs/development/compilers/llvm/18/clang/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/18/clang/gnu-install-dirs.patch index 9185f4b03b847..9517df973ad09 100644 --- a/pkgs/development/compilers/llvm/18/clang/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/18/clang/gnu-install-dirs.patch @@ -1,30 +1,3 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index f7936d72e088..a362fa49b534 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -31,7 +31,21 @@ if(CLANG_BUILT_STANDALONE) - find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") - list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}") - -- # Turn into CACHE PATHs for overwritting -+ # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets -+ # LLVM_CONFIG. -+ if (NOT LLVM_CONFIG_FOUND) -+ # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config -+ # path is removed. -+ set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) -+ set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") -+ # N.B. this is just a default value, the CACHE PATHs below can be overriden. -+ set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") -+ set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") -+ set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}") -+ else() -+ set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}") -+ endif() -+ - set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") - set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree") - set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree") diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake index 75b0080f6715..c895b884cd27 100644 --- a/cmake/modules/AddClang.cmake diff --git a/pkgs/development/compilers/llvm/18/compiler-rt/default.nix b/pkgs/development/compilers/llvm/18/compiler-rt/default.nix index 5a0e3c2e52ce7..f51316beb5705 100644 --- a/pkgs/development/compilers/llvm/18/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/18/compiler-rt/default.nix @@ -90,8 +90,6 @@ stdenv.mkDerivation { # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the # extra `/`. ./normalize-var.patch - # Prevent a compilation error on darwin - ./darwin-targetconditionals.patch # See: https://github.com/NixOS/nixpkgs/pull/186575 ../../common/compiler-rt/darwin-plistbuddy-workaround.patch # See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893 diff --git a/pkgs/development/compilers/llvm/18/libcxx/default.nix b/pkgs/development/compilers/llvm/18/libcxx/default.nix index 4e3404dbe1945..d6c304c0b476a 100644 --- a/pkgs/development/compilers/llvm/18/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/18/libcxx/default.nix @@ -1,5 +1,5 @@ { lib, stdenv, llvm_meta -, monorepoSrc, runCommand, fetchpatch +, monorepoSrc, runCommand , cmake, lndir, ninja, python3, fixDarwinDylibNames, version , cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null , libcxxrt, libunwind @@ -19,11 +19,11 @@ let # Note: useLLVM is likely false for Darwin but true under pkgsLLVM useLLVM = stdenv.hostPlatform.useLLVM or false; - cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ - "-DLIBCXXABI_USE_COMPILER_RT=ON" - "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" - ] ++ lib.optionals (lib.versionAtLeast version "18" && !(useLLVM && !stdenv.hostPlatform.isWasm)) [ + cxxabiCMakeFlags = [ "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF" + ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ + "-DLIBCXXABI_ADDITIONAL_LIBRARIES=unwind" + "-DLIBCXXABI_USE_COMPILER_RT=ON" ] ++ lib.optionals stdenv.hostPlatform.isWasm [ "-DLIBCXXABI_ENABLE_THREADS=OFF" "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" @@ -87,18 +87,6 @@ stdenv.mkDerivation rec { 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 - ] ++ lib.optionals (cxxabi == null && lib.versionAtLeast version "18") [ - # Allow building libcxxabi alone when using LLVM unwinder - (fetchpatch { - url = "https://github.com/llvm/llvm-project/commit/77610dd10454e87bb387040d2b51100a17ac5755.patch"; - revert = true; - hash = "sha256-jFbC3vBY3nKfjknJ7UzaPyoy0iSYdD3+jUmOFeOaVcA="; - }) - (fetchpatch { - url = "https://github.com/llvm/llvm-project/commit/48e5b5ea92674ded69b998cf35724d9012c0f57d.patch"; - revert = true; - hash = "sha256-WN63L4T3GxVozPZb6kx21AgNe4rwwSUOeeryIGsvQYY="; - }) ]; postPatch = '' diff --git a/pkgs/development/compilers/llvm/18/libunwind/default.nix b/pkgs/development/compilers/llvm/18/libunwind/default.nix index a3c8e2594f5a7..e67823ffb85c2 100644 --- a/pkgs/development/compilers/llvm/18/libunwind/default.nix +++ b/pkgs/development/compilers/llvm/18/libunwind/default.nix @@ -27,15 +27,6 @@ stdenv.mkDerivation rec { sourceRoot = "${src.name}/runtimes"; - prePatch = '' - cd ../${pname} - chmod -R u+w . - ''; - - postPatch = '' - cd ../runtimes - ''; - postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) '' # libcxxabi wants to link to libunwind_shared.so (?). ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so diff --git a/pkgs/development/compilers/llvm/18/lld/default.nix b/pkgs/development/compilers/llvm/18/lld/default.nix index 775eb94701b14..24ff0933dd1d8 100644 --- a/pkgs/development/compilers/llvm/18/lld/default.nix +++ b/pkgs/development/compilers/llvm/18/lld/default.nix @@ -27,6 +27,10 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ninja ]; buildInputs = [ libllvm libxml2 ]; + patches = [ + ./gnu-install-dirs.patch + ]; + cmakeFlags = [ "-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld" ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ diff --git a/pkgs/development/compilers/llvm/18/lld/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/18/lld/gnu-install-dirs.patch new file mode 100644 index 0000000000000..6c73a240ab6d2 --- /dev/null +++ b/pkgs/development/compilers/llvm/18/lld/gnu-install-dirs.patch @@ -0,0 +1,15 @@ +diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake +index d3924f7243d4..42a7cd62281c 100644 +--- a/cmake/modules/AddLLD.cmake ++++ b/cmake/modules/AddLLD.cmake +@@ -18,8 +18,8 @@ macro(add_lld_library name) + install(TARGETS ${name} + COMPONENT ${name} + ${export_to_lldtargets} +- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} +- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} ++ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + + if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES) diff --git a/pkgs/development/compilers/llvm/18/llvm/default.nix b/pkgs/development/compilers/llvm/18/llvm/default.nix index 94b4d0116173a..670171a707f9c 100644 --- a/pkgs/development/compilers/llvm/18/llvm/default.nix +++ b/pkgs/development/compilers/llvm/18/llvm/default.nix @@ -179,6 +179,10 @@ stdenv.mkDerivation (rec { substituteInPlace test/ExecutionEngine/Interpreter/intrinsics.ll \ --replace "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \ --replace "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" "" + + # fails when run in sandbox + substituteInPlace unittests/Support/VirtualFileSystemTest.cpp \ + --replace "PhysicalFileSystemWorkingDirFailure" "DISABLED_PhysicalFileSystemWorkingDirFailure" '' + optionalString (stdenv.isDarwin && stdenv.hostPlatform.isx86) '' # This test fails on darwin x86_64 because `sw_vers` reports a different # macOS version than what LLVM finds by reading @@ -381,6 +385,9 @@ stdenv.mkDerivation (rec { substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \ --replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "'"$lib"'")' '' + + optionalString (stdenv.isDarwin && enableSharedLibraries) '' + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib + '' + optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native ''; diff --git a/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs.patch index e2122ebf603d9..8b89839490ba5 100644 --- a/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs.patch @@ -40,7 +40,7 @@ index 230620c37027..dd16cab1835e 100644 if (APPLE) set(_install_name_dir INSTALL_NAME_DIR "@rpath") - set(_install_rpath "@loader_path/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) -+ set(_install_rpath "@loader_path/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) ++ set(_install_rpath ${extra_libdir}) elseif(${CMAKE_SYSTEM_NAME} MATCHES "AIX" AND BUILD_SHARED_LIBS) # $ORIGIN is not interpreted at link time by aix ld. # Since BUILD_SHARED_LIBS is only recommended for use by developers, @@ -72,8 +72,8 @@ index 230620c37027..dd16cab1835e 100644 + # As noted in the differential above, an alternative solution is to have + # all rdeps of nixpkgs' LLVM (that use the AddLLVM.cmake machinery) set + # `CMAKE_INSTALL_RPATH`. -+ set(_build_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) -+ set(_install_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) ++ set(_build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) ++ set(_install_rpath ${extra_libdir}) if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)") set_property(TARGET ${name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-z,origin ") @@ -86,10 +86,10 @@ index 891c9e6d618c..8d963f3b0069 100644 if( APPLE ) - set(ocaml_rpath "@executable_path/../../../lib${LLVM_LIBDIR_SUFFIX}") -+ set(ocaml_rpath "@executable_path/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") ++ set(ocaml_rpath ${LLVM_LIBRARY_DIR}) elseif( UNIX ) - set(ocaml_rpath "\\$ORIGIN/../../../lib${LLVM_LIBDIR_SUFFIX}") -+ set(ocaml_rpath "\\$ORIGIN/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") ++ set(ocaml_rpath ${LLVM_LIBRARY_DIR}) endif() list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}") |