diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2022-02-28 00:02:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-28 00:02:07 +0000 |
commit | 678711689037773117624ade4db4f977640cbb36 (patch) | |
tree | 4b900fe0c2d61be387687b901c36e8aa62739603 /pkgs/development/compilers | |
parent | 0a79f47878472cf5e12c1986a9a09829b0f32fee (diff) | |
parent | 0a8007498f9dba0d5feb191d16317ffa85a9e698 (diff) | |
download | nixpkgs-678711689037773117624ade4db4f977640cbb36.tar nixpkgs-678711689037773117624ade4db4f977640cbb36.tar.gz nixpkgs-678711689037773117624ade4db4f977640cbb36.tar.bz2 nixpkgs-678711689037773117624ade4db4f977640cbb36.tar.lz nixpkgs-678711689037773117624ade4db4f977640cbb36.tar.xz nixpkgs-678711689037773117624ade4db4f977640cbb36.tar.zst nixpkgs-678711689037773117624ade4db4f977640cbb36.zip |
Merge master into staging-next
Diffstat (limited to 'pkgs/development/compilers')
35 files changed, 2394 insertions, 10 deletions
diff --git a/pkgs/development/compilers/fstar/default.nix b/pkgs/development/compilers/fstar/default.nix index 25abd794907..fc0f50d0797 100644 --- a/pkgs/development/compilers/fstar/default.nix +++ b/pkgs/development/compilers/fstar/default.nix @@ -11,20 +11,26 @@ stdenv.mkDerivation rec { sha256 = "sha256-bK3McF/wTjT9q6luihPaEXjx7Lu6+ZbQ9G61Mc4KoB0="; }; - nativeBuildInputs = [ makeWrapper installShellFiles ]; + strictDeps = true; - buildInputs = [ - z3 + nativeBuildInputs = [ + makeWrapper + installShellFiles ] ++ (with ocamlPackages; [ ocaml findlib ocamlbuild + menhir + ]); + + buildInputs = [ + z3 + ] ++ (with ocamlPackages; [ batteries zarith stdint yojson fileutils - menhir menhirLib pprint sedlex_2 diff --git a/pkgs/development/compilers/llvm/14/bintools/default.nix b/pkgs/development/compilers/llvm/14/bintools/default.nix new file mode 100644 index 00000000000..53f7941e336 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/bintools/default.nix @@ -0,0 +1,29 @@ +{ runCommand, stdenv, llvm, lld, version }: + +let + prefix = + if stdenv.hostPlatform != stdenv.targetPlatform + then "${stdenv.targetPlatform.config}-" + else ""; +in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' + mkdir -p $out/bin + for prog in ${lld}/bin/*; do + ln -s $prog $out/bin/${prefix}$(basename $prog) + done + for prog in ${llvm}/bin/*; do + ln -sf $prog $out/bin/${prefix}$(basename $prog) + done + + ln -s ${llvm}/bin/llvm-ar $out/bin/${prefix}ar + ln -s ${llvm}/bin/llvm-as $out/bin/${prefix}as + ln -s ${llvm}/bin/llvm-dwp $out/bin/${prefix}dwp + ln -s ${llvm}/bin/llvm-nm $out/bin/${prefix}nm + ln -s ${llvm}/bin/llvm-objcopy $out/bin/${prefix}objcopy + ln -s ${llvm}/bin/llvm-objdump $out/bin/${prefix}objdump + ln -s ${llvm}/bin/llvm-ranlib $out/bin/${prefix}ranlib + ln -s ${llvm}/bin/llvm-readelf $out/bin/${prefix}readelf + ln -s ${llvm}/bin/llvm-size $out/bin/${prefix}size + ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip + + ln -s ${lld}/bin/lld $out/bin/${prefix}ld +'' diff --git a/pkgs/development/compilers/llvm/14/clang/default.nix b/pkgs/development/compilers/llvm/14/clang/default.nix new file mode 100644 index 00000000000..9544494b356 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/clang/default.nix @@ -0,0 +1,131 @@ +{ lib, stdenv, llvm_meta +, monorepoSrc, runCommand +, substituteAll, cmake, libxml2, libllvm, version, python3 +, buildLlvmTools +, fixDarwinDylibNames +, enableManpages ? false +}: + +let + self = stdenv.mkDerivation (rec { + pname = "clang"; + inherit version; + + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + ''; + + sourceRoot = "${src.name}/${pname}"; + + nativeBuildInputs = [ cmake python3 ] + ++ lib.optional enableManpages python3.pkgs.sphinx + ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; + + buildInputs = [ libxml2 libllvm ]; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++14" + "-DCLANGD_BUILD_XPC=OFF" + "-DLLVM_ENABLE_RTTI=ON" + ] ++ lib.optionals enableManpages [ + "-DCLANG_INCLUDE_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" + "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" + ]; + + patches = [ + ./purity.patch + # https://reviews.llvm.org/D51899 + ./gnu-install-dirs.patch + (substituteAll { + src = ../../clang-11-12-LLVMgold-path.patch; + libllvmLibdir = "${libllvm.lib}/lib"; + }) + ]; + + postPatch = '' + (cd tools && ln -s ../../clang-tools-extra extra) + + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ + -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ + lib/Driver/ToolChains/*.cpp + + # Patch for standalone doc building + sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt + '' + lib.optionalString stdenv.hostPlatform.isMusl '' + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp + ''; + + outputs = [ "out" "lib" "dev" "python" ]; + + postInstall = '' + ln -sv $out/bin/clang $out/bin/cpp + + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + moveToOutput "lib/libclang-cpp.*" "$lib" + substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ + --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." + + mkdir -p $python/bin $python/share/clang/ + mv $out/bin/{git-clang-format,scan-view} $python/bin + if [ -e $out/bin/set-xcode-analyzer ]; then + mv $out/bin/set-xcode-analyzer $python/bin + fi + mv $out/share/clang/*.py $python/share/clang + rm $out/bin/c-index-test + + mkdir -p $dev/bin + cp bin/clang-tblgen $dev/bin + ''; + + passthru = { + isClang = true; + inherit libllvm; + }; + + meta = llvm_meta // { + homepage = "https://clang.llvm.org/"; + description = "A C language family frontend for LLVM"; + longDescription = '' + The Clang project provides a language front-end and tooling + infrastructure for languages in the C language family (C, C++, Objective + C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. + It aims to deliver amazingly fast compiles, extremely useful error and + warning messages and to provide a platform for building great source + level tools. The Clang Static Analyzer and clang-tidy are tools that + automatically find bugs in your code, and are great examples of the sort + of tools that can be built using the Clang frontend as a library to + parse C/C++ code. + ''; + }; + } // lib.optionalAttrs enableManpages { + pname = "clang-manpages"; + + buildPhase = '' + make docs-clang-man + ''; + + installPhase = '' + mkdir -p $out/share/man/man1 + # Manually install clang manpage + cp docs/man/*.1 $out/share/man/man1/ + ''; + + outputs = [ "out" ]; + + doCheck = false; + + meta = llvm_meta // { + description = "man page for Clang ${version}"; + }; + }); +in self diff --git a/pkgs/development/compilers/llvm/14/clang/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/clang/gnu-install-dirs.patch new file mode 100644 index 00000000000..57c54e18c37 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/clang/gnu-install-dirs.patch @@ -0,0 +1,50 @@ +diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake +index 9bbbfc032b7d..947bd0da865d 100644 +--- a/cmake/modules/AddClang.cmake ++++ b/cmake/modules/AddClang.cmake +@@ -119,8 +119,8 @@ macro(add_clang_library name) + install(TARGETS ${lib} + COMPONENT ${lib} + ${export_to_clangtargets} +- 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 (NOT LLVM_ENABLE_IDE) +@@ -175,7 +175,7 @@ endmacro() + macro(add_clang_symlink name dest) + add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE) + # Always generate install targets +- llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE) ++ llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE) + endmacro() + + function(clang_target_link_libraries target type) +diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt +index 078988980c52..14b58614b40a 100644 +--- a/lib/Headers/CMakeLists.txt ++++ b/lib/Headers/CMakeLists.txt +@@ -234,7 +234,7 @@ set_target_properties(clang-resource-headers PROPERTIES + FOLDER "Misc" + RUNTIME_OUTPUT_DIRECTORY "${output_dir}") + +-set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) ++set(header_install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) + + install( + FILES ${files} ${generated_files} +diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt +index 4e0647971ab4..68dd67fcc476 100644 +--- a/tools/libclang/CMakeLists.txt ++++ b/tools/libclang/CMakeLists.txt +@@ -216,7 +216,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS}) + COMPONENT + libclang-python-bindings + DESTINATION +- "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages") ++ "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages") + endforeach() + if(NOT LLVM_ENABLE_IDE) + add_custom_target(libclang-python-bindings) diff --git a/pkgs/development/compilers/llvm/14/clang/purity.patch b/pkgs/development/compilers/llvm/14/clang/purity.patch new file mode 100644 index 00000000000..deb230a36c5 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/clang/purity.patch @@ -0,0 +1,28 @@ +From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Thu, 18 May 2017 11:56:12 -0500 +Subject: [PATCH] "purity" patch for 5.0 + +--- + lib/Driver/ToolChains/Gnu.cpp | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +index fe3c0191bb..c6a482bece 100644 +--- a/lib/Driver/ToolChains/Gnu.cpp ++++ b/lib/Driver/ToolChains/Gnu.cpp +@@ -487,12 +487,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + if (!IsStatic) { + if (Args.hasArg(options::OPT_rdynamic)) + CmdArgs.push_back("-export-dynamic"); +- +- if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) { +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) + +- ToolChain.getDynamicLinker(Args))); +- } + } + + CmdArgs.push_back("-o"); +-- +2.11.0 diff --git a/pkgs/development/compilers/llvm/14/compiler-rt/X86-support-extension.patch b/pkgs/development/compilers/llvm/14/compiler-rt/X86-support-extension.patch new file mode 100644 index 00000000000..66742e5b149 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/compiler-rt/X86-support-extension.patch @@ -0,0 +1,21 @@ +diff --git a/lib/builtins/CMakeLists.txt b/lib/builtins/CMakeLists.txt +index 3a66dd9c3fb..7efc85d9f9f 100644 +--- a/lib/builtins/CMakeLists.txt ++++ b/lib/builtins/CMakeLists.txt +@@ -345,4 +345,8 @@ if (NOT MSVC) + ++ set(i486_SOURCES ${i386_SOURCES}) ++ set(i586_SOURCES ${i386_SOURCES}) ++ set(i686_SOURCES ${i386_SOURCES}) ++ + if (WIN32) + set(i386_SOURCES + ${i386_SOURCES} +@@ -608,6 +612,7 @@ else () + endif() + + foreach (arch ${BUILTIN_SUPPORTED_ARCH}) ++ message("arch: ${arch}") + if (CAN_TARGET_${arch}) + # For ARM archs, exclude any VFP builtins if VFP is not supported + if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") diff --git a/pkgs/development/compilers/llvm/14/compiler-rt/armv7l.patch b/pkgs/development/compilers/llvm/14/compiler-rt/armv7l.patch new file mode 100644 index 00000000000..120cfe6feb2 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/compiler-rt/armv7l.patch @@ -0,0 +1,32 @@ +diff -ur compiler-rt-10.0.0.src/cmake/builtin-config-ix.cmake compiler-rt-10.0.0.src-patched/cmake/builtin-config-ix.cmake +--- compiler-rt-10.0.0.src/cmake/builtin-config-ix.cmake 2020-03-24 00:01:02.000000000 +0900 ++++ compiler-rt-10.0.0.src-patched/cmake/builtin-config-ix.cmake 2020-05-10 03:42:00.883450706 +0900 +@@ -24,7 +24,7 @@ + + + set(ARM64 aarch64) +-set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k) ++set(ARM32 arm armhf armv6m armv7m armv7em armv7 armv7s armv7k armv7l) + set(HEXAGON hexagon) + set(X86 i386) + set(X86_64 x86_64) +diff -ur compiler-rt-10.0.0.src/lib/builtins/CMakeLists.txt compiler-rt-10.0.0.src-patched/lib/builtins/CMakeLists.txt +--- compiler-rt-10.0.0.src/lib/builtins/CMakeLists.txt 2020-03-24 00:01:02.000000000 +0900 ++++ compiler-rt-10.0.0.src-patched/lib/builtins/CMakeLists.txt 2020-05-10 03:44:49.468579650 +0900 +@@ -474,6 +474,7 @@ + set(armv7_SOURCES ${arm_SOURCES}) + set(armv7s_SOURCES ${arm_SOURCES}) + set(armv7k_SOURCES ${arm_SOURCES}) ++set(armv7l_SOURCES ${arm_SOURCES}) + set(arm64_SOURCES ${aarch64_SOURCES}) + + # macho_embedded archs +@@ -595,7 +596,7 @@ + foreach (arch ${BUILTIN_SUPPORTED_ARCH}) + if (CAN_TARGET_${arch}) + # For ARM archs, exclude any VFP builtins if VFP is not supported +- if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") ++ if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7l|armv7m|armv7em)$") + string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}") + check_compile_definition(__VFP_FP__ "${CMAKE_C_FLAGS} ${_TARGET_${arch}_CFLAGS}" COMPILER_RT_HAS_${arch}_VFP) + if(NOT COMPILER_RT_HAS_${arch}_VFP) diff --git a/pkgs/development/compilers/llvm/14/compiler-rt/codesign.patch b/pkgs/development/compilers/llvm/14/compiler-rt/codesign.patch new file mode 100644 index 00000000000..065959d14d4 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/compiler-rt/codesign.patch @@ -0,0 +1,33 @@ +From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Tue, 19 Sep 2017 13:13:06 -0500 +Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that + needs it + +--- + cmake/Modules/AddCompilerRT.cmake | 8 ------ + test/asan/CMakeLists.txt | 52 --------------------------------------- + test/tsan/CMakeLists.txt | 47 ----------------------------------- + 3 files changed, 107 deletions(-) + +diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake +index bc69ec95c419..9f100fdcec2f 100644 +--- a/cmake/Modules/AddCompilerRT.cmake ++++ b/cmake/Modules/AddCompilerRT.cmake +@@ -366,14 +366,6 @@ function(add_compiler_rt_runtime name type) + set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "") + set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib") + endif() +- if(APPLE) +- # Ad-hoc sign the dylibs +- add_custom_command(TARGET ${libname} +- POST_BUILD +- COMMAND codesign --sign - $<TARGET_FILE:${libname}> +- WORKING_DIRECTORY ${COMPILER_RT_OUTPUT_LIBRARY_DIR} +- ) +- endif() + endif() + + set(parent_target_arg) +2.14.1 + diff --git a/pkgs/development/compilers/llvm/14/compiler-rt/darwin-targetconditionals.patch b/pkgs/development/compilers/llvm/14/compiler-rt/darwin-targetconditionals.patch new file mode 100644 index 00000000000..425dc2af01e --- /dev/null +++ b/pkgs/development/compilers/llvm/14/compiler-rt/darwin-targetconditionals.patch @@ -0,0 +1,71 @@ +diff --git a/lib/sanitizer_common/sanitizer_mac.cpp b/lib/sanitizer_common/sanitizer_mac.cpp +--- a/lib/sanitizer_common/sanitizer_mac.cpp ++++ b/lib/sanitizer_common/sanitizer_mac.cpp +@@ -613,9 +613,15 @@ HandleSignalMode GetHandleSignalMode(int signum) { + // Offset example: + // XNU 17 -- macOS 10.13 -- iOS 11 -- tvOS 11 -- watchOS 4 + constexpr u16 GetOSMajorKernelOffset() { +- if (TARGET_OS_OSX) return 4; +- if (TARGET_OS_IOS || TARGET_OS_TV) return 6; +- if (TARGET_OS_WATCH) return 13; ++#if TARGET_OS_OSX ++ return 4; ++#endif ++#if TARGET_OS_IOS || TARGET_OS_TV ++ return 6; ++#endif ++#if TARGET_OS_WATCH ++ return 13; ++#endif + } + + using VersStr = char[64]; +@@ -627,13 +633,13 @@ static uptr ApproximateOSVersionViaKernelVersion(VersStr vers) { + u16 os_major = kernel_major - offset; + + const char *format = "%d.0"; +- if (TARGET_OS_OSX) { +- if (os_major >= 16) { // macOS 11+ +- os_major -= 5; +- } else { // macOS 10.15 and below +- format = "10.%d"; +- } ++#if TARGET_OS_OSX ++ if (os_major >= 16) { // macOS 11+ ++ os_major -= 5; ++ } else { // macOS 10.15 and below ++ format = "10.%d"; + } ++#endif + return internal_snprintf(vers, sizeof(VersStr), format, os_major); + } + +@@ -681,15 +687,14 @@ void ParseVersion(const char *vers, u16 *major, u16 *minor) { + // Aligned versions example: + // macOS 10.15 -- iOS 13 -- tvOS 13 -- watchOS 6 + static void MapToMacos(u16 *major, u16 *minor) { +- if (TARGET_OS_OSX) +- return; +- +- if (TARGET_OS_IOS || TARGET_OS_TV) ++#if !TARGET_OS_OSX ++#if TARGET_OS_IOS || TARGET_OS_TV + *major += 2; +- else if (TARGET_OS_WATCH) ++#elif TARGET_OS_WATCH + *major += 9; +- else ++#else + UNREACHABLE("unsupported platform"); ++#endif + + if (*major >= 16) { // macOS 11+ + *major -= 5; +@@ -697,6 +702,7 @@ static void MapToMacos(u16 *major, u16 *minor) { + *minor = *major; + *major = 10; + } ++#endif + } + + static MacosVersion GetMacosAlignedVersionInternal() { diff --git a/pkgs/development/compilers/llvm/14/compiler-rt/default.nix b/pkgs/development/compilers/llvm/14/compiler-rt/default.nix new file mode 100644 index 00000000000..59ca5348fed --- /dev/null +++ b/pkgs/development/compilers/llvm/14/compiler-rt/default.nix @@ -0,0 +1,126 @@ +{ lib, stdenv, llvm_meta, version +, monorepoSrc, runCommand +, cmake, python3, libllvm, libcxxabi +}: + +let + + useLLVM = stdenv.hostPlatform.useLLVM or false; + bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; + haveLibc = stdenv.cc.libc != null; + inherit (stdenv.hostPlatform) isMusl; + + baseName = "compiler-rt"; + + src = runCommand "${baseName}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${baseName} "$out" + ''; +in + +stdenv.mkDerivation { + pname = baseName + lib.optionalString (haveLibc) "-libc"; + inherit version; + + inherit src; + sourceRoot = "${src.name}/${baseName}"; + + nativeBuildInputs = [ cmake python3 libllvm.dev ]; + buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; + + NIX_CFLAGS_COMPILE = [ + "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0" + ]; + + cmakeFlags = [ + "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" + "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}" + "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}" + ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [ + "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" + "-DCOMPILER_RT_BUILD_XRAY=OFF" + "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" + "-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) && !haveLibc) [ + "-DCMAKE_C_COMPILER_WORKS=ON" + "-DCMAKE_CXX_COMPILER_WORKS=ON" + "-DCOMPILER_RT_BAREMETAL_BUILD=ON" + "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" + ] ++ lib.optionals (useLLVM && !haveLibc) [ + "-DCMAKE_C_FLAGS=-nodefaultlibs" + ] ++ lib.optionals (useLLVM) [ + "-DCOMPILER_RT_BUILD_BUILTINS=ON" + #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program + "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" + ] ++ lib.optionals (bareMetal) [ + "-DCOMPILER_RT_OS_DIR=baremetal" + ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ + "-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON" + "-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}" + "-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}" + ]; + + outputs = [ "out" "dev" ]; + + patches = [ + ./codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ./X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config + ./gnu-install-dirs.patch + # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the + # extra `/`. + ./normalize-var.patch + ] # Prevent a compilation error on darwin + ++ lib.optional stdenv.hostPlatform.isDarwin ./darwin-targetconditionals.patch + ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; + + # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks + # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra + # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd + # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by + # a flag and turn the flag off during the stdenv build. + postPatch = lib.optionalString (!stdenv.isDarwin) '' + substituteInPlace cmake/builtin-config-ix.cmake \ + --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' + '' + lib.optionalString stdenv.isDarwin '' + substituteInPlace cmake/builtin-config-ix.cmake \ + --replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)' + substituteInPlace cmake/config-ix.cmake \ + --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' + '' + lib.optionalString (useLLVM) '' + substituteInPlace lib/builtins/int_util.c \ + --replace "#include <stdlib.h>" "" + substituteInPlace lib/builtins/clear_cache.c \ + --replace "#include <assert.h>" "" + substituteInPlace lib/builtins/cpu_model.c \ + --replace "#include <assert.h>" "" + ''; + + # Hack around weird upsream RPATH bug + postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) '' + ln -s "$out/lib"/*/* "$out/lib" + '' + lib.optionalString (useLLVM) '' + ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o + 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 + ''; + + meta = llvm_meta // { + homepage = "https://compiler-rt.llvm.org/"; + description = "Compiler runtime libraries"; + longDescription = '' + The compiler-rt project provides highly tuned implementations of the + low-level code generator support routines like "__fixunsdfdi" and other + calls generated when a target doesn't have a short sequence of native + instructions to implement a core IR operation. It also provides + implementations of run-time libraries for dynamic testing tools such as + AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer. + ''; + # "All of the code in the compiler-rt project is dual licensed under the MIT + # license and the UIUC License (a BSD-like license)": + license = with lib.licenses; [ mit ncsa ]; + }; +} diff --git a/pkgs/development/compilers/llvm/14/compiler-rt/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/compiler-rt/gnu-install-dirs.patch new file mode 100644 index 00000000000..55837bd8e45 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/compiler-rt/gnu-install-dirs.patch @@ -0,0 +1,42 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3a41aa43e406..f000cee6eae0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,6 +5,8 @@ + + cmake_minimum_required(VERSION 3.13.4) + ++include(GNUInstallDirs) ++ + # Check if compiler-rt is built as a standalone project. + if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR COMPILER_RT_STANDALONE_BUILD) + project(CompilerRT C CXX ASM) +diff --git a/cmake/base-config-ix.cmake b/cmake/base-config-ix.cmake +index d7b0124f3546..3e111146df4d 100644 +--- a/cmake/base-config-ix.cmake ++++ b/cmake/base-config-ix.cmake +@@ -67,7 +67,7 @@ if (LLVM_TREE_AVAILABLE) + else() + # Take output dir and install path from the user. + set(COMPILER_RT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH +- "Path where built compiler-rt libraries should be stored.") ++ "Path where built compiler-rt build artifacts should be stored.") + set(COMPILER_RT_EXEC_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH + "Path where built compiler-rt executables should be stored.") + set(COMPILER_RT_INSTALL_PATH "" CACHE PATH +@@ -99,13 +99,13 @@ endif() + if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + set(COMPILER_RT_OUTPUT_LIBRARY_DIR + ${COMPILER_RT_OUTPUT_DIR}/lib) +- extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" lib) ++ extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_LIBDIR}") + set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH + "Path where built compiler-rt libraries should be installed.") + else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + set(COMPILER_RT_OUTPUT_LIBRARY_DIR + ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR}) +- extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "lib/${COMPILER_RT_OS_DIR}") ++ extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_LIBDIR}/${COMPILER_RT_OS_DIR}") + set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH + "Path where built compiler-rt libraries should be installed.") + endif() diff --git a/pkgs/development/compilers/llvm/14/compiler-rt/normalize-var.patch b/pkgs/development/compilers/llvm/14/compiler-rt/normalize-var.patch new file mode 100644 index 00000000000..135cf625ef7 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/compiler-rt/normalize-var.patch @@ -0,0 +1,16 @@ +diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake +index f1f46fb9599c..6f19e69507ba 100644 +--- a/cmake/Modules/CompilerRTUtils.cmake ++++ b/cmake/Modules/CompilerRTUtils.cmake +@@ -302,8 +302,9 @@ macro(load_llvm_config) + # Get some LLVM variables from LLVMConfig. + include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake") + +- set(LLVM_LIBRARY_OUTPUT_INTDIR +- ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) ++ get_filename_component(LLVM_LIBRARY_OUTPUT_INTDIR ++ ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX} ++ REALPATH) + endif() + endmacro() + diff --git a/pkgs/development/compilers/llvm/14/default.nix b/pkgs/development/compilers/llvm/14/default.nix new file mode 100644 index 00000000000..6f4a0d8ee75 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/default.nix @@ -0,0 +1,278 @@ +{ lowPrio, newScope, pkgs, lib, stdenv, cmake +, gccForLibs, preLibcCrossHeaders +, 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 +# 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. +, bootBintoolsNoLibc ? + if stdenv.targetPlatform.linker == "lld" + then null + else pkgs.bintoolsNoLibc +, bootBintools ? + if stdenv.targetPlatform.linker == "lld" + then null + else pkgs.bintools +, darwin +}: + +let + release_version = "14.0.0"; + candidate = "rc1"; # empty or "rcN" + dash-candidate = lib.optionalString (candidate != "") "-${candidate}"; + rev = ""; # When using a Git commit + rev-version = ""; # When using a Git commit + version = if rev != "" then rev-version else "${release_version}${dash-candidate}"; + targetConfig = stdenv.targetPlatform.config; + + monorepoSrc = fetchFromGitHub { + owner = "llvm"; + repo = "llvm-project"; + rev = if rev != "" then rev else "llvmorg-${version}"; + sha256 = "sha256-bO13J5bhE4YVGvoaTuzFgf62HYh+Shv6T0u07CFjI9E="; + }; + + llvm_meta = { + license = lib.licenses.ncsa; + maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ]; + platforms = lib.platforms.all; + }; + + tools = lib.makeExtensible (tools: let + callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version monorepoSrc buildLlvmTools; }); + mkExtraBuildCommands0 = cc: '' + rsrc="$out/resource-root" + mkdir "$rsrc" + ln -s "${cc.lib}/lib/clang/${release_version}/include" "$rsrc" + echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags + ''; + mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + '' + ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib" + ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share" + ''; + + bintoolsNoLibc' = + if bootBintoolsNoLibc == null + then tools.bintoolsNoLibc + else bootBintoolsNoLibc; + bintools' = + if bootBintools == null + then tools.bintools + else bootBintools; + + in { + + libllvm = callPackage ./llvm { + inherit llvm_meta; + }; + + # `llvm` historically had the binaries. When choosing an output explicitly, + # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* + llvm = tools.libllvm.out // { outputSpecified = false; }; + + libclang = callPackage ./clang { + inherit llvm_meta; + }; + + clang-unwrapped = tools.libclang.out // { outputSpecified = false; }; + + llvm-manpages = lowPrio (tools.libllvm.override { + enableManpages = true; + python3 = pkgs.python3; # don't use python-boot + }); + + clang-manpages = lowPrio (tools.libclang.override { + enableManpages = true; + python3 = pkgs.python3; # don't use python-boot + }); + + # TODO: lldb/docs/index.rst:155:toctree contains reference to nonexisting document 'design/structureddataplugins' + # lldb-manpages = lowPrio (tools.lldb.override { + # enableManpages = true; + # python3 = pkgs.python3; # don't use python-boot + # }); + + # 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; + # libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper. + libcxx = null; + extraPackages = [ + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = mkExtraBuildCommands cc; + }; + + libcxxClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = targetLlvmLibraries.libcxx; + extraPackages = [ + targetLlvmLibraries.libcxxabi + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = mkExtraBuildCommands cc; + }; + + lld = callPackage ./lld { + inherit llvm_meta; + }; + + lldb = callPackage ./lldb { + inherit llvm_meta; + inherit (darwin) libobjc bootstrap_cmds; + inherit (darwin.apple_sdk.libs) xpc; + inherit (darwin.apple_sdk.frameworks) Foundation Carbon Cocoa; + }; + + # Below, is the LLVM bootstrapping logic. It handles building a + # fully LLVM toolchain from scratch. No GCC toolchain should be + # pulled in. As a consequence, it is very quick to build different + # targets provided by LLVM and we can also build for what GCC + # doesn’t support like LLVM. Probably we should move to some other + # file. + + bintools-unwrapped = callPackage ./bintools {}; + + bintoolsNoLibc = wrapBintoolsWith { + bintools = tools.bintools-unwrapped; + libc = preLibcCrossHeaders; + }; + + bintools = wrapBintoolsWith { + bintools = tools.bintools-unwrapped; + }; + + clangUseLLVM = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = targetLlvmLibraries.libcxx; + bintools = bintools'; + extraPackages = [ + targetLlvmLibraries.libcxxabi + targetLlvmLibraries.compiler-rt + ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ + targetLlvmLibraries.libunwind + ]; + extraBuildCommands = '' + echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags + echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags + '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' + echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags + '' + lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) '' + echo "-lunwind" >> $out/nix-support/cc-ldflags + '' + lib.optionalString stdenv.targetPlatform.isWasm '' + echo "-fno-exceptions" >> $out/nix-support/cc-cflags + '' + mkExtraBuildCommands cc; + }; + + clangNoLibcxx = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = null; + bintools = bintools'; + extraPackages = [ + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = '' + echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags + echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags + echo "-nostdlib++" >> $out/nix-support/cc-cflags + '' + mkExtraBuildCommands cc; + }; + + clangNoLibc = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = null; + bintools = bintoolsNoLibc'; + extraPackages = [ + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = '' + echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags + echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags + '' + mkExtraBuildCommands cc; + }; + + clangNoCompilerRt = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = null; + bintools = bintoolsNoLibc'; + extraPackages = [ ]; + extraBuildCommands = '' + echo "-nostartfiles" >> $out/nix-support/cc-cflags + '' + mkExtraBuildCommands0 cc; + }; + + clangNoCompilerRtWithLibc = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = null; + bintools = bintools'; + extraPackages = [ ]; + extraBuildCommands = mkExtraBuildCommands0 cc; + }; + + }); + + libraries = lib.makeExtensible (libraries: let + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version monorepoSrc; }); + in { + + compiler-rt-libc = callPackage ./compiler-rt { + inherit llvm_meta; + stdenv = if stdenv.hostPlatform.useLLVM or false + then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc + else stdenv; + }; + + compiler-rt-no-libc = callPackage ./compiler-rt { + inherit llvm_meta; + stdenv = if stdenv.hostPlatform.useLLVM or false + then overrideCC stdenv buildLlvmTools.clangNoCompilerRt + else stdenv; + }; + + # N.B. condition is safe because without useLLVM both are the same. + compiler-rt = if stdenv.hostPlatform.isAndroid + then libraries.compiler-rt-libc + else libraries.compiler-rt-no-libc; + + stdenv = overrideCC stdenv buildLlvmTools.clang; + + libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; + + libcxx = callPackage ./libcxx { + inherit llvm_meta; + stdenv = if stdenv.hostPlatform.useLLVM or false + then overrideCC stdenv buildLlvmTools.clangNoLibcxx + else stdenv; + }; + + libcxxabi = let + stdenv_ = if stdenv.hostPlatform.useLLVM or false + then overrideCC stdenv buildLlvmTools.clangNoLibcxx + else stdenv; + cxx-headers = callPackage ./libcxx { + inherit llvm_meta; + stdenv = stdenv_; + headersOnly = true; + }; + in callPackage ./libcxxabi { + stdenv = stdenv_; + inherit llvm_meta cxx-headers; + }; + + libunwind = callPackage ./libunwind { + inherit llvm_meta; + stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; + }; + + openmp = callPackage ./openmp { + inherit llvm_meta; + }; + }); + +in { inherit tools libraries release_version; } // libraries // tools diff --git a/pkgs/development/compilers/llvm/14/libcxx/default.nix b/pkgs/development/compilers/llvm/14/libcxx/default.nix new file mode 100644 index 00000000000..8891a69937a --- /dev/null +++ b/pkgs/development/compilers/llvm/14/libcxx/default.nix @@ -0,0 +1,89 @@ +{ lib, stdenv, llvm_meta +, monorepoSrc, runCommand +, cmake, python3, fixDarwinDylibNames, version +, libcxxabi +, enableShared ? !stdenv.hostPlatform.isStatic + +# If headersOnly is true, the resulting package would only include the headers. +# Use this to break the circular dependency between libcxx and libcxxabi. +# +# Some context: +# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb +, headersOnly ? false +}: + +let + basename = "libcxx"; +in + +stdenv.mkDerivation rec { + pname = basename + lib.optionalString headersOnly "-headers"; + inherit version; + + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${basename} "$out" + mkdir -p "$out/libcxxabi" + cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi" + mkdir -p "$out/llvm" + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" + cp -r ${monorepoSrc}/llvm/utils "$out/llvm" + ''; + + sourceRoot = "${src.name}/${basename}"; + + outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev"; + + patches = [ + ./gnu-install-dirs.patch + ] ++ lib.optionals stdenv.hostPlatform.isMusl [ + ../../libcxx-0001-musl-hacks.patch + ]; + + preConfigure = lib.optionalString stdenv.hostPlatform.isMusl '' + patchShebangs utils/cat_files.py + ''; + + nativeBuildInputs = [ cmake python3 ] + ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + buildInputs = lib.optionals (!headersOnly) [ libcxxabi ]; + + cmakeFlags = [ "-DLIBCXX_CXX_ABI=libcxxabi" ] + ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" + ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" + ++ lib.optionals stdenv.hostPlatform.isWasm [ + "-DLIBCXX_ENABLE_THREADS=OFF" + "-DLIBCXX_ENABLE_FILESYSTEM=OFF" + "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" + ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"; + + buildFlags = lib.optional headersOnly "generate-cxx-headers"; + installTargets = lib.optional headersOnly "install-cxx-headers"; + + # At this point, cxxabi headers would be installed in the dev output, which + # prevents moveToOutput from doing its job later in the build process. + postInstall = lib.optionalString (!headersOnly) '' + mv "$dev/include/c++/v1/"* "$out/include/c++/v1/" + pushd "$dev" + rmdir -p include/c++/v1 + popd + ''; + + passthru = { + isLLVM = true; + }; + + meta = llvm_meta // { + homepage = "https://libcxx.llvm.org/"; + description = "C++ standard library"; + longDescription = '' + libc++ is an implementation of the C++ standard library, targeting C++11, + C++14 and above. + ''; + # "All of the code in libc++ is dual licensed under the MIT license and the + # UIUC License (a BSD-like license)": + license = with lib.licenses; [ mit ncsa ]; + }; +} diff --git a/pkgs/development/compilers/llvm/14/libcxx/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/libcxx/gnu-install-dirs.patch new file mode 100644 index 00000000000..0f1d5c411ab --- /dev/null +++ b/pkgs/development/compilers/llvm/14/libcxx/gnu-install-dirs.patch @@ -0,0 +1,85 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b0569a4a54ca..7d665f5a3258 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -10,6 +10,8 @@ endif() + #=============================================================================== + cmake_minimum_required(VERSION 3.13.4) + ++include(GNUInstallDirs) ++ + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") + + # Add path for custom modules +@@ -415,13 +417,13 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) + set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1") +- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH ++ set(LIBCXX_INSTALL_LIBRARY_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE PATH + "Path where built libc++ libraries should be installed.") +- set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libc++ runtime libraries should be installed.") +- set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH ++ set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH + "Path where target-agnostic libc++ headers should be installed.") +- set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH ++ set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH + "Path where target-specific libc++ headers should be installed.") + if(LIBCXX_LIBDIR_SUBDIR) + string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) +@@ -431,11 +433,11 @@ elseif(LLVM_LIBRARY_OUTPUT_INTDIR) + set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) + set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") +- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH ++ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH + "Path where built libc++ libraries should be installed.") +- set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}/c++/v1" CACHE PATH + "Path where built libc++ runtime libraries should be installed.") +- set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH ++ set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH + "Path where target-agnostic libc++ headers should be installed.") + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH + "Path where target-specific libc++ headers should be installed.") +@@ -443,11 +445,11 @@ else() + set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) + set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") +- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH ++ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH + "Path where built libc++ libraries should be installed.") +- set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libc++ runtime libraries should be installed.") +- set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH ++ set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH + "Path where target-agnostic libc++ headers should be installed.") + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH + "Path where target-specific libc++ headers should be installed.") +diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake +index 5a8a4a270a1a..d69405ddeeac 100644 +--- a/cmake/Modules/HandleLibCXXABI.cmake ++++ b/cmake/Modules/HandleLibCXXABI.cmake +@@ -1,8 +1,9 @@ +- + #=============================================================================== + # Add an ABI library if appropriate + #=============================================================================== + ++include(GNUInstallDirs) ++ + # + # _setup_abi: Set up the build to use an ABI library + # +@@ -63,7 +64,7 @@ macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs) + + if (LIBCXX_INSTALL_HEADERS) + install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}" +- DESTINATION include/c++/v1/${dstdir} ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir}" + COMPONENT cxx-headers + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + ) diff --git a/pkgs/development/compilers/llvm/14/libcxxabi/default.nix b/pkgs/development/compilers/llvm/14/libcxxabi/default.nix new file mode 100644 index 00000000000..d64708ab040 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/libcxxabi/default.nix @@ -0,0 +1,86 @@ +{ lib, stdenv, llvm_meta, cmake, python3 +, monorepoSrc, runCommand +, cxx-headers, libunwind, version +, enableShared ? !stdenv.hostPlatform.isStatic +}: + +stdenv.mkDerivation rec { + pname = "libcxxabi"; + inherit version; + + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + mkdir -p "$out/libcxx/src" + cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx" + cp -r ${monorepoSrc}/libcxx/include "$out/libcxx" + cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src" + mkdir -p "$out/llvm" + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" + ''; + + sourceRoot = "${src.name}/${pname}"; + + outputs = [ "out" "dev" ]; + + postUnpack = lib.optionalString stdenv.isDarwin '' + export TRIPLE=x86_64-apple-darwin + '' + lib.optionalString stdenv.hostPlatform.isWasm '' + patch -p1 -d llvm -i ${./wasm.patch} + ''; + + patches = [ + ./gnu-install-dirs.patch + ]; + + nativeBuildInputs = [ cmake python3 ]; + buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind; + + cmakeFlags = [ + "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1" + ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" + ] ++ lib.optionals stdenv.hostPlatform.isWasm [ + "-DLIBCXXABI_ENABLE_THREADS=OFF" + "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" + ] ++ lib.optionals (!enableShared) [ + "-DLIBCXXABI_ENABLE_SHARED=OFF" + ]; + + installPhase = if stdenv.isDarwin + then '' + for file in lib/*.dylib; do + # this should be done in CMake, but having trouble figuring out + # the magic combination of necessary CMake variables + # if you fancy a try, take a look at + # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling + install_name_tool -id $out/$file $file + done + make install + install -d 755 $out/include + install -m 644 ../include/*.h $out/include + '' + else '' + install -d -m 755 $out/include $out/lib + install -m 644 lib/libc++abi.a $out/lib + install -m 644 ../include/cxxabi.h $out/include + '' + lib.optionalString enableShared '' + install -m 644 lib/libc++abi.so.1.0 $out/lib + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 + ''; + + meta = llvm_meta // { + homepage = "https://libcxxabi.llvm.org/"; + description = "Provides C++ standard library support"; + longDescription = '' + libc++abi is a new implementation of low level support for a standard C++ library. + ''; + # "All of the code in libc++abi is dual licensed under the MIT license and + # the UIUC License (a BSD-like license)": + license = with lib.licenses; [ mit ncsa ]; + maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ]; + }; +} diff --git a/pkgs/development/compilers/llvm/14/libcxxabi/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/libcxxabi/gnu-install-dirs.patch new file mode 100644 index 00000000000..a93348ded0c --- /dev/null +++ b/pkgs/development/compilers/llvm/14/libcxxabi/gnu-install-dirs.patch @@ -0,0 +1,46 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 858f5d5cfd7f..16c67d7062be 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -10,6 +10,8 @@ endif() + + cmake_minimum_required(VERSION 3.13.4) + ++include(GNUInstallDirs) ++ + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") + + # Add path for custom modules +@@ -213,9 +215,9 @@ set(CMAKE_MODULE_PATH + if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) + set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) +- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH ++ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH + "Path where built libc++abi libraries should be installed.") +- set(LIBCXXABI_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libc++abi runtime libraries should be installed.") + if(LIBCXX_LIBDIR_SUBDIR) + string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR}) +@@ -224,16 +226,16 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + elseif(LLVM_LIBRARY_OUTPUT_INTDIR) + set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) + set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) +- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH ++ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH + "Path where built libc++abi libraries should be installed.") +- set(LIBCXXABI_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libc++abi runtime libraries should be installed.") + else() + set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR}) + set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) +- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH ++ set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH + "Path where built libc++abi libraries should be installed.") +- set(LIBCXXABI_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libc++abi runtime libraries should be installed.") + endif() + diff --git a/pkgs/development/compilers/llvm/14/libcxxabi/wasm.patch b/pkgs/development/compilers/llvm/14/libcxxabi/wasm.patch new file mode 100644 index 00000000000..4ebfe46aa81 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/libcxxabi/wasm.patch @@ -0,0 +1,16 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 15497d405e0..33f7f18193a 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -127,7 +127,10 @@ else(WIN32) + set(LLVM_HAVE_LINK_VERSION_SCRIPT 1) + endif() + else(FUCHSIA OR UNIX) +- MESSAGE(SEND_ERROR "Unable to determine platform") ++ if(${CMAKE_SYSTEM_NAME} MATCHES "Wasi") ++ else() ++ MESSAGE(SEND_ERROR "Unable to determine platform") ++ endif() + endif(FUCHSIA OR UNIX) + endif(WIN32) + diff --git a/pkgs/development/compilers/llvm/14/libunwind/default.nix b/pkgs/development/compilers/llvm/14/libunwind/default.nix new file mode 100644 index 00000000000..c6d9eda5e47 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/libunwind/default.nix @@ -0,0 +1,47 @@ +{ lib, stdenv, llvm_meta, version +, monorepoSrc, runCommand +, cmake +, enableShared ? !stdenv.hostPlatform.isStatic +}: + +stdenv.mkDerivation rec { + pname = "libunwind"; + inherit version; + + # I am not so comfortable giving libc++ and friends the whole monorepo as + # requested, so I filter it to what is needed. + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + mkdir -p "$out/libcxx" + cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx" + cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx" + mkdir -p "$out/llvm" + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" + ''; + + sourceRoot = "${src.name}/${pname}"; + + patches = [ + ./gnu-install-dirs.patch + ]; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ cmake ]; + + cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF"; + + meta = llvm_meta // { + # Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst + homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library"; + description = "LLVM's unwinder library"; + longDescription = '' + The unwind library provides a family of _Unwind_* functions implementing + the language-neutral stack unwinding portion of the Itanium C++ ABI (Level + I). It is a dependency of the C++ ABI library, and sometimes is a + dependency of other runtimes. + ''; + }; +} diff --git a/pkgs/development/compilers/llvm/14/libunwind/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/libunwind/gnu-install-dirs.patch new file mode 100644 index 00000000000..3f05d2a8726 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/libunwind/gnu-install-dirs.patch @@ -0,0 +1,65 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e3cc66dd2226..1299b596ce0d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -8,6 +8,8 @@ endif() + + cmake_minimum_required(VERSION 3.13.4) + ++include(GNUInstallDirs) ++ + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") + + # Add path for custom modules +@@ -139,25 +141,27 @@ set(CMAKE_MODULE_PATH + + if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) +- set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH ++ set(LIBUNWIND_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE PATH ++ "Path where built libunwind headers should be installed.") ++ set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH + "Path where built libunwind libraries should be installed.") +- set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBUNWIND_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libunwind runtime libraries should be installed.") + if(LIBCXX_LIBDIR_SUBDIR) + string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) + string(APPEND LIBUNWIND_INSTALL_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) + endif() +-elseif(LLVM_LIBRARY_OUTPUT_INTDIR) +- set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) +- set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH +- "Path where built libunwind libraries should be installed.") +- set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH +- "Path where built libunwind runtime libraries should be installed.") + else() +- set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) +- set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH ++ if(LLVM_LIBRARY_OUTPUT_INTDIR) ++ set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) ++ else() ++ set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) ++ endif() ++ set(LIBUNWIND_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH ++ "Path where built libunwind headers should be installed.") ++ set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH + "Path where built libunwind libraries should be installed.") +- set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBUNWIND_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libunwind runtime libraries should be installed.") + endif() + +diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt +index c3bb1dd0f69f..adf1766c44cb 100644 +--- a/include/CMakeLists.txt ++++ b/include/CMakeLists.txt +@@ -14,7 +14,7 @@ if(LIBUNWIND_INSTALL_HEADERS) + foreach(file ${files}) + get_filename_component(dir ${file} DIRECTORY) + install(FILES ${file} +- DESTINATION "include/${dir}" ++ DESTINATION "${LIBUNWIND_INSTALL_INCLUDE_DIR}/${dir}" + COMPONENT unwind-headers + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + ) diff --git a/pkgs/development/compilers/llvm/14/lld/default.nix b/pkgs/development/compilers/llvm/14/lld/default.nix new file mode 100644 index 00000000000..fe655c76112 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/lld/default.nix @@ -0,0 +1,55 @@ +{ lib, stdenv, llvm_meta +, buildLlvmTools +, monorepoSrc, runCommand +, cmake +, libxml2 +, libllvm +, version +}: + +stdenv.mkDerivation rec { + pname = "lld"; + inherit version; + + # Blank llvm dir just so relative path works + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + mkdir -p "$out/libunwind" + cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" + mkdir -p "$out/llvm" + ''; + + sourceRoot = "${src.name}/${pname}"; + + patches = [ + ./gnu-install-dirs.patch + # On Darwin the llvm-config is perhaps not working fine as the + # LLVM_MAIN_SRC_DIR is not getting set correctly, and the build fails as + # the include path is not correct. + ./fix-root-src-dir.patch + ]; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ libllvm libxml2 ]; + + cmakeFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" + ]; + + outputs = [ "out" "lib" "dev" ]; + + meta = llvm_meta // { + homepage = "https://lld.llvm.org/"; + description = "The LLVM linker"; + longDescription = '' + LLD is a linker from the LLVM project that is a drop-in replacement for + system linkers and runs much faster than them. It also provides features + that are useful for toolchain developers. + The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and + WebAssembly in descending order of completeness. Internally, LLD consists + of several different linkers. + ''; + }; +} diff --git a/pkgs/development/compilers/llvm/14/lld/fix-root-src-dir.patch b/pkgs/development/compilers/llvm/14/lld/fix-root-src-dir.patch new file mode 100644 index 00000000000..26ecef25649 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/lld/fix-root-src-dir.patch @@ -0,0 +1,13 @@ +diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt +index e1a29b884d17..9d542f8fbfc1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -64,7 +64,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + + set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include") + set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") +- set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") ++ set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree") + + find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} + NO_DEFAULT_PATH) diff --git a/pkgs/development/compilers/llvm/14/lld/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/lld/gnu-install-dirs.patch new file mode 100644 index 00000000000..89a5822df49 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/lld/gnu-install-dirs.patch @@ -0,0 +1,22 @@ +diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake +index dd2898ce6236..ebbea040ff54 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) +@@ -62,5 +62,5 @@ endmacro() + macro(add_lld_symlink name dest) + add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE) + # Always generate install targets +- llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE) ++ llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE) + endmacro() diff --git a/pkgs/development/compilers/llvm/14/lldb/default.nix b/pkgs/development/compilers/llvm/14/lldb/default.nix new file mode 100644 index 00000000000..a2c68b22477 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/lldb/default.nix @@ -0,0 +1,144 @@ +{ lib, stdenv, llvm_meta +, runCommand +, monorepoSrc +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, libxml2 +, libllvm +, libclang +, python3 +, version +, libobjc +, xpc +, Foundation +, bootstrap_cmds +, Carbon +, Cocoa +, lit +, makeWrapper +, enableManpages ? false +}: + +stdenv.mkDerivation (rec { + pname = "lldb"; + inherit version; + + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + ''; + + sourceRoot = "${src.name}/${pname}"; + + patches = [ + ./procfs.patch + (runCommand "resource-dir.patch" { + clangLibDir = "${libclang.lib}/lib"; + } '' + substitute '${./resource-dir.patch}' "$out" --subst-var clangLibDir + '') + ./gnu-install-dirs.patch + ]; + + outputs = [ "out" "lib" "dev" ]; + + nativeBuildInputs = [ + cmake python3 which swig lit makeWrapper + ] ++ lib.optionals enableManpages [ + python3.pkgs.sphinx python3.pkgs.recommonmark + ]; + + buildInputs = [ + ncurses + zlib + libedit + libxml2 + libllvm + ] ++ lib.optionals stdenv.isDarwin [ + libobjc + xpc + Foundation + bootstrap_cmds + Carbon + Cocoa + ]; + + hardeningDisable = [ "format" ]; + + cmakeFlags = [ + "-DLLDB_INCLUDE_TESTS=${if doCheck then "YES" else "NO"}" + "-DLLVM_ENABLE_RTTI=OFF" + "-DClang_DIR=${libclang.dev}/lib/cmake" + "-DLLVM_EXTERNAL_LIT=${lit}/bin/lit" + ] ++ lib.optionals stdenv.isDarwin [ + "-DLLDB_USE_SYSTEM_DEBUGSERVER=ON" + ] ++ lib.optionals (!stdenv.isDarwin) [ + "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic + ] ++ lib.optionals enableManpages [ + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + ] ++ lib.optionals doCheck [ + "-DLLDB_TEST_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" + "-DLLDB_TEST_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++" + ]; + + doCheck = false; + + installCheckPhase = '' + if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then + return 1; + fi + ''; + + postInstall = '' + wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ + + # Editor support + # vscode: + install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json + mkdir -p $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin + ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin + ''; + + meta = llvm_meta // { + homepage = "https://lldb.llvm.org/"; + description = "A next-generation high-performance debugger"; + longDescription = '' + LLDB is a next generation, high-performance debugger. It is built as a set + of reusable components which highly leverage existing libraries in the + larger LLVM Project, such as the Clang expression parser and LLVM + disassembler. + ''; + }; +} // lib.optionalAttrs enableManpages { + pname = "lldb-manpages"; + + buildPhase = '' + make docs-lldb-man + ''; + + propagatedBuildInputs = []; + + # manually install lldb man page + installPhase = '' + mkdir -p $out/share/man/man1 + install docs/man/lldb.1 -t $out/share/man/man1/ + ''; + + postPatch = null; + postInstall = null; + + outputs = [ "out" ]; + + doCheck = false; + + meta = llvm_meta // { + description = "man pages for LLDB ${version}"; + }; +}) diff --git a/pkgs/development/compilers/llvm/14/lldb/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/lldb/gnu-install-dirs.patch new file mode 100644 index 00000000000..f69ed9e162f --- /dev/null +++ b/pkgs/development/compilers/llvm/14/lldb/gnu-install-dirs.patch @@ -0,0 +1,36 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 79d451965ed4..78188978d6de 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -12,6 +12,8 @@ set(CMAKE_MODULE_PATH + # If we are not building as part of LLVM, build LLDB as a standalone project, + # using LLVM as an external library. + if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) ++ include(GNUInstallDirs) ++ + project(lldb) + include(LLDBStandalone) + +diff --git a/cmake/modules/AddLLDB.cmake b/cmake/modules/AddLLDB.cmake +index 3291a7c808e1..b27d27ce6a87 100644 +--- a/cmake/modules/AddLLDB.cmake ++++ b/cmake/modules/AddLLDB.cmake +@@ -109,7 +109,7 @@ function(add_lldb_library name) + endif() + + if(PARAM_SHARED) +- set(install_dest lib${LLVM_LIBDIR_SUFFIX}) ++ set(install_dest ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) + if(PARAM_INSTALL_PREFIX) + set(install_dest ${PARAM_INSTALL_PREFIX}) + endif() +diff --git a/tools/intel-features/CMakeLists.txt b/tools/intel-features/CMakeLists.txt +index 7d48491ec89a..c04543585588 100644 +--- a/tools/intel-features/CMakeLists.txt ++++ b/tools/intel-features/CMakeLists.txt +@@ -30,4 +30,4 @@ add_lldb_library(lldbIntelFeatures SHARED + ) + + install(TARGETS lldbIntelFeatures +- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}) ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) diff --git a/pkgs/development/compilers/llvm/14/lldb/procfs.patch b/pkgs/development/compilers/llvm/14/lldb/procfs.patch new file mode 100644 index 00000000000..b075dbaeee0 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/lldb/procfs.patch @@ -0,0 +1,31 @@ +--- a/source/Plugins/Process/Linux/Procfs.h ++++ b/source/Plugins/Process/Linux/Procfs.h +@@ -11,21 +11,12 @@ + // sys/procfs.h on Android/Linux for all supported architectures. + + #include <sys/ptrace.h> ++#include <asm/ptrace.h> + +-#ifdef __ANDROID__ +-#if defined(__arm64__) || defined(__aarch64__) +-typedef unsigned long elf_greg_t; +-typedef elf_greg_t +- elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))]; +-typedef struct user_fpsimd_state elf_fpregset_t; +-#ifndef NT_FPREGSET +-#define NT_FPREGSET NT_PRFPREG +-#endif // NT_FPREGSET +-#elif defined(__mips__) +-#ifndef NT_FPREGSET +-#define NT_FPREGSET NT_PRFPREG +-#endif // NT_FPREGSET +-#endif +-#else // __ANDROID__ ++#if !defined(__GLIBC__) && defined(__powerpc__) ++#define pt_regs musl_pt_regs ++#include <sys/procfs.h> ++#undef pt_regs ++#else + #include <sys/procfs.h> +-#endif // __ANDROID__ ++#endif diff --git a/pkgs/development/compilers/llvm/14/lldb/resource-dir.patch b/pkgs/development/compilers/llvm/14/lldb/resource-dir.patch new file mode 100644 index 00000000000..e0db80afeb9 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/lldb/resource-dir.patch @@ -0,0 +1,13 @@ +diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake +index 37364341ff8b..7f74c1a3e257 100644 +--- a/cmake/modules/LLDBConfig.cmake ++++ b/cmake/modules/LLDBConfig.cmake +@@ -257,7 +257,7 @@ if (NOT TARGET clang-resource-headers) + # Iterate over the possible places where the external resource directory + # could be and pick the first that exists. + foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}" +- "${LLVM_BUILD_LIBRARY_DIR}" ++ "${LLVM_BUILD_LIBRARY_DIR}" "@clangLibDir@" + "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}") + # Build the resource directory path by appending 'clang/<version number>'. + set(CANDIDATE_RESOURCE_DIR "${CANDIDATE}/clang/${LLDB_CLANG_RESOURCE_DIR_NAME}") diff --git a/pkgs/development/compilers/llvm/14/llvm/default.nix b/pkgs/development/compilers/llvm/14/llvm/default.nix new file mode 100644 index 00000000000..d2059cc66ba --- /dev/null +++ b/pkgs/development/compilers/llvm/14/llvm/default.nix @@ -0,0 +1,254 @@ +{ lib, stdenv, llvm_meta +, pkgsBuildBuild +, monorepoSrc +, runCommand +, fetchpatch +, cmake +, python3 +, libffi +, libbfd +, libpfm +, libxml2 +, ncurses +, version +, release_version +, zlib +, which +, buildLlvmTools +, 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 +) +, enablePolly ? false +} @args: + +let + inherit (lib) optional optionals optionalString; + + # Used when creating a version-suffixed symlink of libLLVM.dylib + shortVersion = with lib; + concatStringsSep "." (take 1 (splitString "." release_version)); + +in stdenv.mkDerivation (rec { + pname = "llvm"; + inherit version; + + src = runCommand "${pname}-src-${version}" {} ('' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + cp -r ${monorepoSrc}/third-party "$out" + '' + lib.optionalString enablePolly '' + cp -r ${monorepoSrc}/polly "$out/llvm/tools" + ''); + + sourceRoot = "${src.name}/${pname}"; + + outputs = [ "out" "lib" "dev" "python" ]; + + nativeBuildInputs = [ cmake python3 ] + ++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ]; + + buildInputs = [ libxml2 libffi ] + ++ optional enablePFM libpfm; # exegesis + + propagatedBuildInputs = [ ncurses zlib ]; + + checkInputs = [ which ]; + + patches = [ + ./gnu-install-dirs.patch + ] ++ lib.optional enablePolly ./gnu-install-dirs-polly.patch; + + postPatch = optionalString stdenv.isDarwin '' + 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})' "" + '' + '' + # FileSystem permissions tests fail with various special bits + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "Path.cpp" "" + rm unittests/Support/Path.cpp + substituteInPlace unittests/IR/CMakeLists.txt \ + --replace "PassBuilderCallbacksTest.cpp" "" + 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} + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "add_subdirectory(DynamicLibrary)" "" + rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp + # valgrind unhappy with musl or glibc, but fails w/musl only + rm test/CodeGen/AArch64/wineh4.mir + '' + optionalString stdenv.hostPlatform.isAarch32 '' + # skip failing X86 test cases on 32-bit ARM + rm test/DebugInfo/X86/convert-debugloc.ll + rm test/DebugInfo/X86/convert-inlined.ll + rm test/DebugInfo/X86/convert-linked.ll + rm test/tools/dsymutil/X86/op-convert.test + '' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") '' + # Seems to require certain floating point hardware (NEON?) + rm test/ExecutionEngine/frem.ll + '' + '' + patchShebangs test/BugPoint/compile-custom.ll.py + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + # E.g. mesa.drivers use the build-id as a cache key (see #93946): + LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; + + 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=${if doCheck then "ON" else "OFF"}" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_ENABLE_DUMP=ON" + ] ++ optionals stdenv.hostPlatform.isStatic [ + # Disables building of shared libs, -fPIC is still injected by cc-wrapper + "-DLLVM_ENABLE_PIC=OFF" + "-DLLVM_BUILD_STATIC=ON" + # 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 + "-DLLVM_ENABLE_LIBXML2=OFF" + ] ++ optionals enableManpages [ + "-DLLVM_BUILD_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] ++ optionals (!isDarwin) [ + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ] ++ optionals isDarwin [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DCAN_TARGET_i386=false" + ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-DCMAKE_CROSSCOMPILING=True" + "-DLLVM_TABLEGEN=${buildLlvmTools.llvm}/bin/llvm-tblgen" + ( + let + nativeCC = pkgsBuildBuild.targetPackages.stdenv.cc; + nativeBintools = nativeCC.bintools.bintools; + nativeToolchainFlags = [ + "-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc" + "-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++" + "-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar" + "-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip" + "-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib" + ]; + # 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 + ]) + ) + ]; + + postBuild = '' + rm -fR $out + ''; + + preCheck = '' + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib + ''; + + postInstall = '' + mkdir -p $python/share + mv $out/share/opt-viewer $python/share/opt-viewer + moveToOutput "bin/llvm-config*" "$dev" + substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \ + --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 "''${LLVM_INSTALL_PREFIX}'"$lib"'")' + '' + + optionalString (stdenv.isDarwin && enableSharedLibraries) '' + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib + 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 + ''; + + doCheck = stdenv.isLinux && (!stdenv.isx86_32) && (!stdenv.hostPlatform.isMusl) + && (stdenv.hostPlatform == stdenv.buildPlatform); + + checkTarget = "check-all"; + + requiredSystemFeatures = [ "big-parallel" ]; + meta = llvm_meta // { + homepage = "https://llvm.org/"; + description = "A collection of modular and reusable compiler and toolchain technologies"; + longDescription = '' + The LLVM Project is a collection of modular and reusable compiler and + toolchain technologies. Despite its name, LLVM has little to do with + traditional virtual machines. The name "LLVM" itself is not an acronym; it + is the full name of the project. + LLVM began as a research project at the University of Illinois, with the + goal of providing a modern, SSA-based compilation strategy capable of + supporting both static and dynamic compilation of arbitrary programming + languages. Since then, LLVM has grown to be an umbrella project consisting + of a number of subprojects, many of which are being used in production by + a wide variety of commercial and open source projects as well as being + widely used in academic research. Code in the LLVM project is licensed + under the "Apache 2.0 License with LLVM exceptions". + ''; + }; +} // lib.optionalAttrs enableManpages { + pname = "llvm-manpages"; + + buildPhase = '' + make docs-llvm-man + ''; + + propagatedBuildInputs = []; + + installPhase = '' + make -C docs install + ''; + + postPatch = null; + postInstall = null; + + outputs = [ "out" ]; + + doCheck = false; + + meta = llvm_meta // { + description = "man pages for LLVM ${version}"; + }; +}) diff --git a/pkgs/development/compilers/llvm/14/llvm/gnu-install-dirs-polly.patch b/pkgs/development/compilers/llvm/14/llvm/gnu-install-dirs-polly.patch new file mode 100644 index 00000000000..98e998e65a9 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/llvm/gnu-install-dirs-polly.patch @@ -0,0 +1,102 @@ +diff --git a/tools/polly/CMakeLists.txt b/tools/polly/CMakeLists.txt +index ca7c04c565bb..6a6155806ffa 100644 +--- a/tools/polly/CMakeLists.txt ++++ b/tools/polly/CMakeLists.txt +@@ -3,6 +3,8 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR) + project(Polly) + cmake_minimum_required(VERSION 3.13.4) + ++ include(GNUInstallDirs) ++ + # Where is LLVM installed? + find_package(LLVM CONFIG REQUIRED) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR}) +@@ -122,13 +124,13 @@ include_directories( + + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + install(DIRECTORY include/ +- DESTINATION include ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING + PATTERN "*.h" + ) + + install(DIRECTORY ${POLLY_BINARY_DIR}/include/ +- DESTINATION include ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING + PATTERN "*.h" + PATTERN "CMakeFiles" EXCLUDE +diff --git a/tools/polly/cmake/CMakeLists.txt b/tools/polly/cmake/CMakeLists.txt +index 7cc129ba2e90..137be25e4b80 100644 +--- a/tools/polly/cmake/CMakeLists.txt ++++ b/tools/polly/cmake/CMakeLists.txt +@@ -79,18 +79,18 @@ file(GENERATE + + # Generate PollyConfig.cmake for the install tree. + unset(POLLY_EXPORTS) +-set(POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") ++set(POLLY_INSTALL_PREFIX "") + set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") +-set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}") +-set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}") ++set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}") ++set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") + if (POLLY_BUNDLED_ISL) + set(POLLY_CONFIG_INCLUDE_DIRS +- "${POLLY_INSTALL_PREFIX}/include" +- "${POLLY_INSTALL_PREFIX}/include/polly" ++ "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}" ++ "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}/polly" + ) + else() + set(POLLY_CONFIG_INCLUDE_DIRS +- "${POLLY_INSTALL_PREFIX}/include" ++ "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_INCLUDEDIR}" + ${ISL_INCLUDE_DIRS} + ) + endif() +@@ -100,12 +100,12 @@ endif() + foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS) + get_target_property(tgt_type ${tgt} TYPE) + if (tgt_type STREQUAL "EXECUTABLE") +- set(tgt_prefix "bin/") ++ set(tgt_prefix "${CMAKE_INSTALL_BINDIR}/") + else() +- set(tgt_prefix "lib/") ++ set(tgt_prefix "${CMAKE_INSTALL_LIBDIR}/") + endif() + +- set(tgt_path "${CMAKE_INSTALL_PREFIX}/${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>") ++ set(tgt_path "${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>") + file(RELATIVE_PATH tgt_path ${POLLY_CONFIG_CMAKE_DIR} ${tgt_path}) + + if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY") +diff --git a/tools/polly/cmake/polly_macros.cmake b/tools/polly/cmake/polly_macros.cmake +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") + install(TARGETS ${name} + EXPORT LLVMExports +- 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}) + endif() + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) + endmacro(add_polly_library) +diff --git a/tools/polly/lib/External/CMakeLists.txt b/tools/polly/lib/External/CMakeLists.txt +index e3a5683fccdc..293b482eb28a 100644 +--- a/tools/polly/lib/External/CMakeLists.txt ++++ b/tools/polly/lib/External/CMakeLists.txt +@@ -290,7 +290,7 @@ if (POLLY_BUNDLED_ISL) + install(DIRECTORY + ${ISL_SOURCE_DIR}/include/ + ${ISL_BINARY_DIR}/include/ +- DESTINATION include/polly ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly + FILES_MATCHING + PATTERN "*.h" + PATTERN "CMakeFiles" EXCLUDE diff --git a/pkgs/development/compilers/llvm/14/llvm/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/llvm/gnu-install-dirs.patch new file mode 100644 index 00000000000..55862ab3930 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/llvm/gnu-install-dirs.patch @@ -0,0 +1,220 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index fec956091cd5..5a766f5c5d7c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -303,6 +303,9 @@ set(LLVM_EXAMPLES_INSTALL_DIR "examples" CACHE STRING + "Path for examples subdirectory (enabled by LLVM_BUILD_EXAMPLES=ON) (defaults to 'examples')") + mark_as_advanced(LLVM_EXAMPLES_INSTALL_DIR) + ++set(LLVM_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/cmake/llvm" CACHE STRING ++ "Path for CMake subdirectory (defaults to lib/cmake/llvm)" ) ++ + # They are used as destination of target generators. + set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) + set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) +diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake +index fed1fec7d72e..4baed19b9e98 100644 +--- a/cmake/modules/AddLLVM.cmake ++++ b/cmake/modules/AddLLVM.cmake +@@ -838,8 +838,8 @@ macro(add_llvm_library name) + get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella}) + install(TARGETS ${name} + ${export_to_llvmexports} +- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} +- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} ++ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" COMPONENT ${name} ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" COMPONENT ${name} + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name}) + + if (NOT LLVM_ENABLE_IDE) +@@ -1056,7 +1056,7 @@ function(process_llvm_pass_plugins) + "set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})") + install(FILES + ${llvm_cmake_builddir}/LLVMConfigExtensions.cmake +- DESTINATION ${LLVM_INSTALL_PACKAGE_DIR} ++ DESTINATION ${LLVM_INSTALL_CMAKE_DIR} + COMPONENT cmake-exports) + + set(ExtensionDef "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def") +@@ -1902,7 +1902,7 @@ function(llvm_install_library_symlink name dest type) + set(full_name ${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX}) + set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX}) + +- set(output_dir lib${LLVM_LIBDIR_SUFFIX}) ++ set(output_dir ${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) + if(WIN32 AND "${type}" STREQUAL "SHARED") + set(output_dir bin) + endif() +@@ -1913,7 +1913,7 @@ function(llvm_install_library_symlink name dest type) + + endfunction() + +-function(llvm_install_symlink name dest) ++function(llvm_install_symlink name dest output_dir) + cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN}) + foreach(path ${CMAKE_MODULE_PATH}) + if(EXISTS ${path}/LLVMInstallSymlink.cmake) +@@ -1936,7 +1936,7 @@ function(llvm_install_symlink name dest) + set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX}) + + install(SCRIPT ${INSTALL_SYMLINK} +- CODE "install_symlink(${full_name} ${full_dest} ${LLVM_TOOLS_INSTALL_DIR})" ++ CODE "install_symlink(${full_name} ${full_dest} ${output_dir})" + COMPONENT ${component}) + + if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE) +@@ -2019,7 +2019,8 @@ function(add_llvm_tool_symlink link_name target) + endif() + + if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS) +- llvm_install_symlink(${link_name} ${target}) ++ GNUInstallDirs_get_absolute_install_dir(output_dir LLVM_TOOLS_INSTALL_DIR) ++ llvm_install_symlink(${link_name} ${target} ${output_dir}) + endif() + endif() + endfunction() +@@ -2148,9 +2149,9 @@ function(llvm_setup_rpath name) + # Since BUILD_SHARED_LIBS is only recommended for use by developers, + # hardcode the rpath to build/install lib dir first in this mode. + # FIXME: update this when there is better solution. +- set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) ++ set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) + elseif(UNIX) +- set(_install_rpath "\$ORIGIN/../lib${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 ") +diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake +index 891c9e6d618c..8d963f3b0069 100644 +--- a/cmake/modules/AddOCaml.cmake ++++ b/cmake/modules/AddOCaml.cmake +@@ -147,9 +147,9 @@ function(add_ocaml_library name) + endforeach() + + 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}") + +diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt +index cea0c1df0a14..eedcd9450312 100644 +--- a/cmake/modules/CMakeLists.txt ++++ b/cmake/modules/CMakeLists.txt +@@ -2,7 +2,7 @@ include(ExtendPath) + include(LLVMDistributionSupport) + include(FindPrefixFromConfig) + +-set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm) ++set(LLVM_INSTALL_PACKAGE_DIR ${LLVM_INSTALL_CMAKE_DIR} CACHE STRING "Path for CMake subdirectory (defaults to 'cmake/llvm')") + set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") + + # First for users who use an installed LLVM, create the LLVMExports.cmake file. +@@ -122,7 +122,7 @@ set(LLVM_CONFIG_INCLUDE_DIRS + ) + list(REMOVE_DUPLICATES LLVM_CONFIG_INCLUDE_DIRS) + +-extend_path(LLVM_CONFIG_LIBRARY_DIR "\${LLVM_INSTALL_PREFIX}" "lib\${LLVM_LIBDIR_SUFFIX}") ++extend_path(LLVM_CONFIG_LIBRARY_DIR "\${LLVM_INSTALL_PREFIX}" "${CMAKE_INSTALL_LIBDIR}\${LLVM_LIBDIR_SUFFIX}") + set(LLVM_CONFIG_LIBRARY_DIRS + "${LLVM_CONFIG_LIBRARY_DIR}" + # FIXME: Should there be other entries here? +diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake +index b5c35f706cb7..9261ab797de6 100644 +--- a/cmake/modules/LLVMInstallSymlink.cmake ++++ b/cmake/modules/LLVMInstallSymlink.cmake +@@ -6,7 +6,7 @@ include(GNUInstallDirs) + + function(install_symlink name target outdir) + set(DESTDIR $ENV{DESTDIR}) +- set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}") ++ set(bindir "${DESTDIR}${outdir}/") + + message(STATUS "Creating ${name}") + +diff --git a/docs/CMake.rst b/docs/CMake.rst +index 044ec8a4d39d..504d0eac3ade 100644 +--- a/docs/CMake.rst ++++ b/docs/CMake.rst +@@ -224,7 +224,7 @@ description is in `LLVM-related variables`_ below. + **LLVM_LIBDIR_SUFFIX**:STRING + Extra suffix to append to the directory where libraries are to be + installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64`` +- to install libraries to ``/usr/lib64``. ++ to install libraries to ``/usr/lib64``. See also ``CMAKE_INSTALL_LIBDIR``. + + **LLVM_PARALLEL_{COMPILE,LINK}_JOBS**:STRING + Building the llvm toolchain can use a lot of resources, particularly +@@ -910,9 +910,11 @@ the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``). + + This file is available in two different locations. + +-* ``<INSTALL_PREFIX>/lib/cmake/llvm/LLVMConfig.cmake`` where +- ``<INSTALL_PREFIX>`` is the install prefix of an installed version of LLVM. +- On Linux typically this is ``/usr/lib/cmake/llvm/LLVMConfig.cmake``. ++* ``<LLVM_INSTALL_PACKAGE_DIR>LLVMConfig.cmake`` where ++ ``<LLVM_INSTALL_PACKAGE_DIR>`` is the location where LLVM CMake modules are ++ installed as part of an installed version of LLVM. This is typically ++ ``cmake/llvm/`` within the lib directory. On Linux, this is typically ++ ``/usr/lib/cmake/llvm/LLVMConfig.cmake``. + + * ``<LLVM_BUILD_ROOT>/lib/cmake/llvm/LLVMConfig.cmake`` where + ``<LLVM_BUILD_ROOT>`` is the root of the LLVM build tree. **Note: this is only +diff --git a/include/llvm/CMakeLists.txt b/include/llvm/CMakeLists.txt +index b46319f24fc8..2feabd1954e4 100644 +--- a/include/llvm/CMakeLists.txt ++++ b/include/llvm/CMakeLists.txt +@@ -5,5 +5,5 @@ add_subdirectory(Frontend) + # If we're doing an out-of-tree build, copy a module map for generated + # header files into the build area. + if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") +- configure_file(module.modulemap.build module.modulemap COPYONLY) ++ configure_file(module.modulemap.build ${LLVM_INCLUDE_DIR}/module.modulemap COPYONLY) + endif (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") +diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in +index abbb8a450da6..70c497be12f5 100644 +--- a/tools/llvm-config/BuildVariables.inc.in ++++ b/tools/llvm-config/BuildVariables.inc.in +@@ -23,7 +23,10 @@ + #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@" + #define LLVM_BUILDMODE "@LLVM_BUILDMODE@" + #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@" ++#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@" ++#define LLVM_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@" + #define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@" ++#define LLVM_INSTALL_CMAKEDIR "@LLVM_INSTALL_CMAKE_DIR@" + #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@" + #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@" + #define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@" +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp +index 8ed88f33ead4..5e7184bab90d 100644 +--- a/tools/llvm-config/llvm-config.cpp ++++ b/tools/llvm-config/llvm-config.cpp +@@ -363,12 +363,20 @@ int main(int argc, char **argv) { + ActiveIncludeDir = std::string(Path.str()); + } + { +- SmallString<256> Path(LLVM_TOOLS_INSTALL_DIR); ++ SmallString<256> Path(LLVM_INSTALL_BINDIR); + sys::fs::make_absolute(ActivePrefix, Path); + ActiveBinDir = std::string(Path.str()); + } +- ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX; +- ActiveCMakeDir = ActiveLibDir + "/cmake/llvm"; ++ { ++ SmallString<256> Path(LLVM_INSTALL_LIBDIR LLVM_LIBDIR_SUFFIX); ++ sys::fs::make_absolute(ActivePrefix, Path); ++ ActiveLibDir = std::string(Path.str()); ++ } ++ { ++ SmallString<256> Path(LLVM_INSTALL_CMAKEDIR); ++ sys::fs::make_absolute(ActivePrefix, Path); ++ ActiveCMakeDir = std::string(Path.str()); ++ } + ActiveIncludeOption = "-I" + ActiveIncludeDir; + } + diff --git a/pkgs/development/compilers/llvm/14/openmp/default.nix b/pkgs/development/compilers/llvm/14/openmp/default.nix new file mode 100644 index 00000000000..7add0c7ed46 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/openmp/default.nix @@ -0,0 +1,54 @@ +{ lib +, stdenv +, llvm_meta +, monorepoSrc +, runCommand +, cmake +, llvm +, clang-unwrapped +, perl +, pkg-config +, version +}: + +stdenv.mkDerivation rec { + pname = "openmp"; + inherit version; + + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + ''; + + sourceRoot = "${src.name}/${pname}"; + + patches = [ + ./gnu-install-dirs.patch + ./fix-find-tool.patch + ]; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ cmake perl pkg-config clang-unwrapped ]; + buildInputs = [ llvm ]; + + cmakeFlags = [ + "-DLIBOMPTARGET_BUILD_AMDGCN_BCLIB=OFF" # Building the AMDGCN device RTL currently fails + ]; + + meta = llvm_meta // { + homepage = "https://openmp.llvm.org/"; + description = "Support for the OpenMP language"; + longDescription = '' + The OpenMP subproject of LLVM contains the components required to build an + executable OpenMP program that are outside the compiler itself. + Contains the code for the runtime library against which code compiled by + "clang -fopenmp" must be linked before it can run and the library that + supports offload to target devices. + ''; + # "All of the code is dual licensed under the MIT license and the UIUC + # License (a BSD-like license)": + license = with lib.licenses; [ mit ncsa ]; + }; +} diff --git a/pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch b/pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch new file mode 100644 index 00000000000..b5d0e7b4177 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch @@ -0,0 +1,54 @@ +diff --git a/libomptarget/DeviceRTL/CMakeLists.txt b/libomptarget/DeviceRTL/CMakeLists.txt +index 242df638f80d..a4654e96371f 100644 +--- a/libomptarget/DeviceRTL/CMakeLists.txt ++++ b/libomptarget/DeviceRTL/CMakeLists.txt +@@ -25,16 +25,16 @@ endif() + + if (LLVM_DIR) + # Builds that use pre-installed LLVM have LLVM_DIR set. +- find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) ++ find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) + find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} +- NO_DEFAULT_PATH) +- find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) ++ REQUIRED) ++ find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) + libomptarget_say("Building DeviceRTL. Using clang: ${CLANG_TOOL}") + elseif (LLVM_TOOL_CLANG_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT OPENMP_STANDALONE_BUILD) + # LLVM in-tree builds may use CMake target names to discover the tools. +- set(CLANG_TOOL $<TARGET_FILE:clang>) +- set(LINK_TOOL $<TARGET_FILE:llvm-link>) +- set(OPT_TOOL $<TARGET_FILE:opt>) ++ set(CLANG_TOOL $<TARGET_FILE:clang> REQUIRED) ++ set(LINK_TOOL $<TARGET_FILE:llvm-link> REQUIRED) ++ set(OPT_TOOL $<TARGET_FILE:opt> REQUIRED) + libomptarget_say("Building DeviceRTL. Using clang from in-tree build") + else() + libomptarget_say("Not building DeviceRTL. No appropriate clang found") +diff --git a/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt b/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt +index 3f4c02671aeb..be9f4677d7b5 100644 +--- a/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt ++++ b/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt +@@ -38,16 +38,16 @@ endif() + + if (LLVM_DIR) + # Builds that use pre-installed LLVM have LLVM_DIR set. +- find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) ++ find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) + find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} +- NO_DEFAULT_PATH) +- find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) ++ REQUIRED) ++ find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) + libomptarget_say("Building AMDGCN device RTL. Using clang: ${CLANG_TOOL}") + elseif (LLVM_TOOL_CLANG_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT OPENMP_STANDALONE_BUILD) + # LLVM in-tree builds may use CMake target names to discover the tools. +- set(CLANG_TOOL $<TARGET_FILE:clang>) +- set(LINK_TOOL $<TARGET_FILE:llvm-link>) +- set(OPT_TOOL $<TARGET_FILE:opt>) ++ set(CLANG_TOOL $<TARGET_FILE:clang> REQUIRED) ++ set(LINK_TOOL $<TARGET_FILE:llvm-link> REQUIRED) ++ set(OPT_TOOL $<TARGET_FILE:opt> REQUIRED) + libomptarget_say("Building AMDGCN device RTL. Using clang from in-tree build") + else() + libomptarget_say("Not building AMDGCN device RTL. No appropriate clang found") diff --git a/pkgs/development/compilers/llvm/14/openmp/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/openmp/gnu-install-dirs.patch new file mode 100644 index 00000000000..352a4692311 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/openmp/gnu-install-dirs.patch @@ -0,0 +1,89 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7f11a05f5622..fb90f8f6a49b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -8,6 +8,8 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S + set(OPENMP_STANDALONE_BUILD TRUE) + project(openmp C CXX) + ++ include(GNUInstallDirs) ++ + # CMAKE_BUILD_TYPE was not set, default to Release. + if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +@@ -19,7 +21,7 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S + 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}") + + # Group test settings. + set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING +@@ -30,7 +32,7 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S + 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}") + + if (NOT MSVC) + set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) +index 0e1ce2afd154..8b3810f83713 100644 +--- a/libomptarget/plugins/amdgpu/CMakeLists.txt ++++ b/libomptarget/plugins/amdgpu/CMakeLists.txt +@@ -80,7 +80,7 @@ add_library(omptarget.rtl.amdgpu SHARED + + # Install plugin under the lib destination folder. + # When we build for debug, OPENMP_LIBDIR_SUFFIX get set to -debug +-install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "lib${OPENMP_LIBDIR_SUFFIX}") ++install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}") + set_property(TARGET omptarget.rtl.amdgpu PROPERTY INSTALL_RPATH_USE_LINK_PATH ON) + + if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") +diff --git a/libomptarget/plugins/ve/CMakeLists.txt b/libomptarget/plugins/ve/CMakeLists.txt +index 16ce0891ca23..db30ee9c769f 100644 +--- a/libomptarget/plugins/ve/CMakeLists.txt ++++ b/libomptarget/plugins/ve/CMakeLists.txt +@@ -32,7 +32,7 @@ if(${LIBOMPTARGET_DEP_VEO_FOUND}) + + # Install plugin under the lib destination folder. + install(TARGETS "omptarget.rtl.${tmachine_libname}" +- LIBRARY DESTINATION lib${OPENMP_LIBDIR_SUFFIX}) ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}) + + target_link_libraries( + "omptarget.rtl.${tmachine_libname}" +diff --git a/runtime/src/CMakeLists.txt b/runtime/src/CMakeLists.txt +index e4f4e6e1e73f..1164b3b22b0e 100644 +--- a/runtime/src/CMakeLists.txt ++++ b/runtime/src/CMakeLists.txt +@@ -346,13 +346,13 @@ add_dependencies(libomp-micro-tests libomp-test-deps) + # We want to install libomp in DESTDIR/CMAKE_INSTALL_PREFIX/lib + # We want to install headers in DESTDIR/CMAKE_INSTALL_PREFIX/include + if(${OPENMP_STANDALONE_BUILD}) +- set(LIBOMP_HEADERS_INSTALL_PATH include) ++ set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}") + else() + string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION}) + set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include") + endif() + if(WIN32) +- install(TARGETS omp RUNTIME DESTINATION bin) ++ install(TARGETS omp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS ${LIBOMP_IMP_LIB_TARGET} ARCHIVE DESTINATION "${OPENMP_INSTALL_LIBDIR}") + # Create aliases (regular copies) of the library for backwards compatibility + set(LIBOMP_ALIASES "libiomp5md") +diff --git a/tools/multiplex/CMakeLists.txt b/tools/multiplex/CMakeLists.txt +index 64317c112176..4002784da736 100644 +--- a/tools/multiplex/CMakeLists.txt ++++ b/tools/multiplex/CMakeLists.txt +@@ -4,7 +4,7 @@ if(LIBOMP_OMPT_SUPPORT) + add_library(ompt-multiplex INTERFACE) + target_include_directories(ompt-multiplex INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + +- install(FILES ompt-multiplex.h DESTINATION include) ++ install(FILES ompt-multiplex.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + add_subdirectory(tests) + endif() diff --git a/pkgs/development/compilers/llvm/git/lld/default.nix b/pkgs/development/compilers/llvm/git/lld/default.nix index cdd2f5f0fa7..fe655c76112 100644 --- a/pkgs/development/compilers/llvm/git/lld/default.nix +++ b/pkgs/development/compilers/llvm/git/lld/default.nix @@ -25,9 +25,9 @@ stdenv.mkDerivation rec { patches = [ ./gnu-install-dirs.patch - # On Darwin the llvm-config is perhaps not working fine as the - # LLVM_MAIN_SRC_DIR is not getting set correctly, and the build fails as - # the include path is not correct. + # On Darwin the llvm-config is perhaps not working fine as the + # LLVM_MAIN_SRC_DIR is not getting set correctly, and the build fails as + # the include path is not correct. ./fix-root-src-dir.patch ]; diff --git a/pkgs/development/compilers/purescript/purescript/default.nix b/pkgs/development/compilers/purescript/purescript/default.nix index 5dd2b6a23b1..cbf36516465 100644 --- a/pkgs/development/compilers/purescript/purescript/default.nix +++ b/pkgs/development/compilers/purescript/purescript/default.nix @@ -18,7 +18,7 @@ let in stdenv.mkDerivation rec { pname = "purescript"; - version = "0.14.6"; + version = "0.14.7"; # These hashes can be updated automatically by running the ./update.sh script. src = @@ -26,12 +26,12 @@ in stdenv.mkDerivation rec { then fetchurl { url = "https://github.com/${pname}/${pname}/releases/download/v${version}/macos.tar.gz"; - sha256 = "0yfl4galaqzbbkql2vfsg4zrc5cv037286764kv8qibdk2yrhap3"; + sha256 = "0pc07xv5h7jgiy04rcrnsjb97nk5zs7jrvcsqggn0izlnrcyi8rc"; } else fetchurl { url = "https://github.com/${pname}/${pname}/releases/download/v${version}/linux64.tar.gz"; - sha256 = "01mf850a9jhqba6a3hsbl9fjxp2khplwnlr15wzp637s5vf7rd79"; + sha256 = "0vcjxb1v76wg4hmisnw0pp6wl0pwp4fa19cw08zdhgy62w06mqfa"; }; |