musllvm

A pure LLVM/Clang cross compiler toolchain targeting musl C
git clone git://git.daat.foo/musllvm.git
Log | Files | Refs | README | LICENSE

0010-compiler-rt-libcxx-abi-libunwind-HACK-force-fno-lto.patch (2892B)


      1 From 223f5481951047fa74a74d57819bb082aa462447 Mon Sep 17 00:00:00 2001
      2 From: q66 <q66@chimera-linux.org>
      3 Date: Sun, 14 Apr 2024 14:42:37 +0200
      4 Subject: [PATCH 10/29] compiler-rt,libcxx(abi),libunwind: HACK: force -fno-lto
      5 
      6 Also do -ftrivial-auto-var-init=unitialized for libunwind, as it appears
      7 to break unwinding in strange ways with C++ on ppc64le, particularly with
      8 LTO; this needs to be investigated properly though.
      9 
     10 https://github.com/llvm/llvm-project/issues/76771
     11 ---
     12  compiler-rt/lib/builtins/CMakeLists.txt | 2 +-
     13  libcxx/CMakeLists.txt                   | 4 ++++
     14  libcxxabi/CMakeLists.txt                | 4 ++++
     15  libunwind/src/CMakeLists.txt            | 3 +++
     16  4 files changed, 12 insertions(+), 1 deletion(-)
     17 
     18 diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
     19 index f89cf87c7..51f59457a 100644
     20 --- a/compiler-rt/lib/builtins/CMakeLists.txt
     21 +++ b/compiler-rt/lib/builtins/CMakeLists.txt
     22 @@ -756,7 +756,7 @@ if (APPLE)
     23    add_subdirectory(macho_embedded)
     24    darwin_add_builtin_libraries(${BUILTIN_SUPPORTED_OS})
     25  else ()
     26 -  set(BUILTIN_CFLAGS "")
     27 +  set(BUILTIN_CFLAGS "-fno-lto")
     28    add_security_warnings(BUILTIN_CFLAGS 0)
     29  
     30    if (COMPILER_RT_HAS_FCF_PROTECTION_FLAG)
     31 diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
     32 index abe12c280..17cf7c7ed 100644
     33 --- a/libcxx/CMakeLists.txt
     34 +++ b/libcxx/CMakeLists.txt
     35 @@ -575,6 +575,10 @@ function(cxx_add_rtti_flags target)
     36        target_add_compile_flags_if_supported(${target} PUBLIC -fno-rtti)
     37      endif()
     38    endif()
     39 +
     40 +  target_add_compile_flags_if_supported(${target} PRIVATE "-fno-lto")
     41 +  target_add_link_flags_if_supported(${target} PRIVATE "-fno-lto")
     42 +  target_add_link_flags_if_supported(${target} PRIVATE "-rtlib=compiler-rt")
     43  endfunction()
     44  
     45  # Modules flags ===============================================================
     46 diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
     47 index 6dcfc51e5..1d03714f5 100644
     48 --- a/libcxxabi/CMakeLists.txt
     49 +++ b/libcxxabi/CMakeLists.txt
     50 @@ -331,6 +331,10 @@ else()
     51    add_compile_flags_if_supported(-EHa-)
     52  endif()
     53  
     54 +add_compile_flags("-fno-lto")
     55 +add_link_flags("-fno-lto")
     56 +add_link_flags("-rtlib=compiler-rt")
     57 +
     58  # Assert
     59  string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
     60  if (LIBCXXABI_ENABLE_ASSERTIONS)
     61 diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
     62 index ecbd019bb..ec4108bd9 100644
     63 --- a/libunwind/src/CMakeLists.txt
     64 +++ b/libunwind/src/CMakeLists.txt
     65 @@ -136,6 +136,9 @@ if (HAIKU)
     66    endif()
     67  endif ()
     68  
     69 +add_compile_flags("-fno-lto -ftrivial-auto-var-init=uninitialized")
     70 +add_link_flags("-fno-lto -ftrivial-auto-var-init=uninitialized")
     71 +
     72  string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")
     73  string(REPLACE ";" " " LIBUNWIND_CXX_FLAGS "${LIBUNWIND_CXX_FLAGS}")
     74  string(REPLACE ";" " " LIBUNWIND_C_FLAGS "${LIBUNWIND_C_FLAGS}")
     75 -- 
     76 2.49.0
     77