From c858c42002313cc5f9c837c10d8b3babddc77b32 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Sun, 8 Aug 2021 13:54:09 +0200 Subject: [PATCH 1/5] llvmPackages_13.clang: fix linker invocation with LLVMgold plugin Ported from 3530837417da13076a2c8412de2c0c385dfbd648. --- pkgs/development/compilers/llvm/13/clang/default.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/llvm/13/clang/default.nix b/pkgs/development/compilers/llvm/13/clang/default.nix index cfafe43c3a5..78c2831a2f3 100644 --- a/pkgs/development/compilers/llvm/13/clang/default.nix +++ b/pkgs/development/compilers/llvm/13/clang/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, llvm_meta, src, cmake, libxml2, libllvm, version, python3 +{ lib, stdenv, llvm_meta, src, substituteAll, cmake, libxml2, libllvm, version, python3 , buildLlvmTools , fixDarwinDylibNames , enableManpages ? false @@ -37,6 +37,10 @@ let ./purity.patch # https://reviews.llvm.org/D51899 ./gnu-install-dirs.patch + (substituteAll { + src = ../../clang-11-12-LLVMgold-path.patch; + libllvmLibdir = "${libllvm.lib}/lib"; + }) ]; postPatch = '' @@ -52,12 +56,7 @@ let outputs = [ "out" "lib" "dev" "python" ]; - # Clang expects to find LLVMgold in its own prefix postInstall = '' - if [ -e ${libllvm.lib}/lib/LLVMgold.so ]; then - ln -sv ${libllvm.lib}/lib/LLVMgold.so $lib/lib - fi - ln -sv $out/bin/clang $out/bin/cpp # Move libclang to 'lib' output From 6a1354b1fc14dfd549bd88f58aede0178f489415 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Sun, 8 Aug 2021 13:54:16 +0200 Subject: [PATCH 2/5] llvmPackages_13.compiler-rt: fix build on darwin Ported from cf4e1b9e62ab987552eb676f7618ea085f12a751. --- .../darwin-targetconditionals.patch | 71 +++++++++++++++++++ .../compilers/llvm/13/compiler-rt/default.nix | 2 + 2 files changed, 73 insertions(+) create mode 100644 pkgs/development/compilers/llvm/13/compiler-rt/darwin-targetconditionals.patch diff --git a/pkgs/development/compilers/llvm/13/compiler-rt/darwin-targetconditionals.patch b/pkgs/development/compilers/llvm/13/compiler-rt/darwin-targetconditionals.patch new file mode 100644 index 00000000000..425dc2af01e --- /dev/null +++ b/pkgs/development/compilers/llvm/13/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/13/compiler-rt/default.nix b/pkgs/development/compilers/llvm/13/compiler-rt/default.nix index 8e258e349b9..eb3446342b4 100644 --- a/pkgs/development/compilers/llvm/13/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/13/compiler-rt/default.nix @@ -60,6 +60,8 @@ stdenv.mkDerivation { # extra `/`. ./normalize-var.patch ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.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 From a6defaf953d4470a9dcf8cae3bef1c2c4d17f296 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Sun, 8 Aug 2021 13:55:23 +0200 Subject: [PATCH 3/5] llvmPackages_13.lldb: fix python lldb library Ported from e097f7efc77726a17acca7be3e6e2346331883f3. --- pkgs/development/compilers/llvm/13/lldb/default.nix | 6 ++++++ .../compilers/llvm/13/lldb/gnu-install-dirs.patch | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/pkgs/development/compilers/llvm/13/lldb/default.nix b/pkgs/development/compilers/llvm/13/lldb/default.nix index 2dd6c46eb82..63a5c828faa 100644 --- a/pkgs/development/compilers/llvm/13/lldb/default.nix +++ b/pkgs/development/compilers/llvm/13/lldb/default.nix @@ -84,6 +84,12 @@ stdenv.mkDerivation (rec { doCheck = false; + installCheckPhase = '' + if [ ! -e "$out/lib/python3.8/site-packages/lldb/_lldb.so" ] ; then + return 1; + fi + ''; + postInstall = '' # Editor support # vscode: diff --git a/pkgs/development/compilers/llvm/13/lldb/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/13/lldb/gnu-install-dirs.patch index 98321f4479e..0435784a247 100644 --- a/pkgs/development/compilers/llvm/13/lldb/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/13/lldb/gnu-install-dirs.patch @@ -63,3 +63,16 @@ index 734167e51bc5..f95761b5df58 100644 install(TARGETS lldbIntelFeatures - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) +diff --git a/cmake/modules/LLDBStandalone.cmake b/cmake/modules/LLDBStandalone.cmake +index 752113b..010f187 100644 +--- a/cmake/modules/LLDBStandalone.cmake ++++ b/cmake/modules/LLDBStandalone.cmake +@@ -62,7 +62,7 @@ endif() + + # They are used as destination of target generators. + set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) +-set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) ++set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) + if(WIN32 OR CYGWIN) + # DLL platform -- put DLLs into bin. + set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) \ No newline at end of file From a5f0733461e6937d0397e2afdef73db15f748c61 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Sun, 8 Aug 2021 13:56:25 +0200 Subject: [PATCH 4/5] llvmPackages_13.lldb: python into lib & wrap binary Ported from cc7740ae770c52ac1f385aa25cfc143fe79c6b6e. --- .../compilers/llvm/13/lldb/default.nix | 7 +++++-- .../compilers/llvm/13/lldb/gnu-install-dirs.patch | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/llvm/13/lldb/default.nix b/pkgs/development/compilers/llvm/13/lldb/default.nix index 63a5c828faa..96d8b19ee41 100644 --- a/pkgs/development/compilers/llvm/13/lldb/default.nix +++ b/pkgs/development/compilers/llvm/13/lldb/default.nix @@ -19,6 +19,7 @@ , Carbon , Cocoa , lit +, makeWrapper , enableManpages ? false }: @@ -42,7 +43,7 @@ stdenv.mkDerivation (rec { outputs = [ "out" "lib" "dev" ]; nativeBuildInputs = [ - cmake python3 which swig lit + cmake python3 which swig lit makeWrapper ] ++ lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ]; @@ -85,12 +86,14 @@ stdenv.mkDerivation (rec { doCheck = false; installCheckPhase = '' - if [ ! -e "$out/lib/python3.8/site-packages/lldb/_lldb.so" ] ; then + 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 diff --git a/pkgs/development/compilers/llvm/13/lldb/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/13/lldb/gnu-install-dirs.patch index 0435784a247..afc945ce261 100644 --- a/pkgs/development/compilers/llvm/13/lldb/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/13/lldb/gnu-install-dirs.patch @@ -75,4 +75,17 @@ index 752113b..010f187 100644 +set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) if(WIN32 OR CYGWIN) # DLL platform -- put DLLs into bin. - set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) \ No newline at end of file + set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b5633e2..86e4738 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -79,7 +79,7 @@ if (LLDB_ENABLE_PYTHON) + if(LLDB_BUILD_FRAMEWORK) + set(lldb_python_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb") + else() +- set(lldb_python_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb") ++ set(lldb_python_target_dir "${CMAKE_INSTALL_LIBDIR}/../${LLDB_PYTHON_RELATIVE_PATH}/lldb") + endif() + get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR) + finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}") From c8db49f0a939ce2219b41f8d3993268ceeef05f1 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Sun, 8 Aug 2021 14:00:59 +0200 Subject: [PATCH 5/5] pkgsi686Linux.llvmPackages_13.compiler-rt: fix build Ported from a7c4537a729929f6670349f67d248ffb6ff800da. --- .../compilers/llvm/13/compiler-rt/X86-support-extension.patch | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/development/compilers/llvm/13/compiler-rt/X86-support-extension.patch b/pkgs/development/compilers/llvm/13/compiler-rt/X86-support-extension.patch index f6f9336ad5a..66742e5b149 100644 --- a/pkgs/development/compilers/llvm/13/compiler-rt/X86-support-extension.patch +++ b/pkgs/development/compilers/llvm/13/compiler-rt/X86-support-extension.patch @@ -2,9 +2,7 @@ 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 -@@ -301,6 +301,10 @@ if (NOT MSVC) - i386/umoddi3.S - ) +@@ -345,4 +345,8 @@ if (NOT MSVC) + set(i486_SOURCES ${i386_SOURCES}) + set(i586_SOURCES ${i386_SOURCES})