llvmPackages_18: init

Changed files
+36 -60
pkgs
development
-27
pkgs/development/compilers/llvm/18/clang/gnu-install-dirs.patch
···
-
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/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake
index 75b0080f6715..c895b884cd27 100644
--- a/cmake/modules/AddClang.cmake
-2
pkgs/development/compilers/llvm/18/compiler-rt/default.nix
···
# 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
···
# ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
# extra `/`.
./normalize-var.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
+5 -17
pkgs/development/compilers/llvm/18/libcxx/default.nix
···
{ lib, stdenv, llvm_meta
-
, monorepoSrc, runCommand, fetchpatch
, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
, libcxxrt, libunwind
···
# 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)) [
"-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
···
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 = ''
···
{ lib, stdenv, llvm_meta
+
, monorepoSrc, runCommand
, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
, libcxxrt, libunwind
···
# Note: useLLVM is likely false for Darwin but true under pkgsLLVM
useLLVM = stdenv.hostPlatform.useLLVM or false;
+
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"
···
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 = ''
-9
pkgs/development/compilers/llvm/18/libunwind/default.nix
···
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
···
sourceRoot = "${src.name}/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
+4
pkgs/development/compilers/llvm/18/lld/default.nix
···
nativeBuildInputs = [ cmake ninja ];
buildInputs = [ libllvm libxml2 ];
cmakeFlags = [
"-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
···
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) [
+15
pkgs/development/compilers/llvm/18/lld/gnu-install-dirs.patch
···
···
+
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)
+7
pkgs/development/compilers/llvm/18/llvm/default.nix
···
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)" ""
'' + 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
···
--replace "$out/bin/llvm-config" "$dev/bin/llvm-config"
substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \
--replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "'"$lib"'")'
''
+ optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native
···
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
···
--replace "$out/bin/llvm-config" "$dev/bin/llvm-config"
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
+5 -5
pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs.patch
···
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})
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,
···
+ # 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})
if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
set_property(TARGET ${name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z,origin ")
···
if( APPLE )
- set(ocaml_rpath "@executable_path/../../../lib${LLVM_LIBDIR_SUFFIX}")
-
+ set(ocaml_rpath "@executable_path/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
elseif( UNIX )
- set(ocaml_rpath "\\$ORIGIN/../../../lib${LLVM_LIBDIR_SUFFIX}")
-
+ set(ocaml_rpath "\\$ORIGIN/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
endif()
list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}")
···
if (APPLE)
set(_install_name_dir INSTALL_NAME_DIR "@rpath")
- set(_install_rpath "@loader_path/../lib${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,
···
+ # 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/../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 ")
···
if( APPLE )
- set(ocaml_rpath "@executable_path/../../../lib${LLVM_LIBDIR_SUFFIX}")
+
+ set(ocaml_rpath ${LLVM_LIBRARY_DIR})
elseif( UNIX )
- set(ocaml_rpath "\\$ORIGIN/../../../lib${LLVM_LIBDIR_SUFFIX}")
+
+ set(ocaml_rpath ${LLVM_LIBRARY_DIR})
endif()
list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}")