[PATCH] D74133: Fix for PR38025
Riyaz V Puthiyapurayil via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 6 08:17:27 PST 2020
RVP created this revision.
RVP added a reviewer: phosek.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.
This patch fixes PR38025: Wrong ABI used when building compiler-rt
https://reviews.llvm.org/D74133
Files:
compiler-rt/CMakeLists.txt
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/cmake/Modules/HandleCompilerRT.cmake
compiler-rt/cmake/config-ix.cmake
Index: compiler-rt/cmake/config-ix.cmake
===================================================================
--- compiler-rt/cmake/config-ix.cmake
+++ compiler-rt/cmake/config-ix.cmake
@@ -16,7 +16,7 @@
check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC)
if (COMPILER_RT_USE_BUILTINS_LIBRARY)
include(HandleCompilerRT)
- find_compiler_rt_library(builtins COMPILER_RT_BUILTINS_LIBRARY)
+ find_compiler_rt_library(builtins "" COMPILER_RT_BUILTINS_LIBRARY)
else()
if (ANDROID)
check_library_exists(gcc __gcc_personality_v0 "" COMPILER_RT_HAS_GCC_LIB)
Index: compiler-rt/cmake/Modules/HandleCompilerRT.cmake
===================================================================
--- compiler-rt/cmake/Modules/HandleCompilerRT.cmake
+++ compiler-rt/cmake/Modules/HandleCompilerRT.cmake
@@ -1,7 +1,9 @@
-function(find_compiler_rt_library name variable)
+function(find_compiler_rt_library name target variable)
set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${SANITIZER_COMMON_CFLAGS}
"--rtlib=compiler-rt" "--print-libgcc-file-name")
- if (CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_CXX_COMPILER_TARGET)
+ if (target)
+ list(APPEND CLANG_COMMAND "--target=${target}")
+ elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_CXX_COMPILER_TARGET)
list(APPEND CLANG_COMMAND "--target=${CMAKE_CXX_COMPILER_TARGET}")
endif()
get_property(SANITIZER_CXX_FLAGS CACHE CMAKE_CXX_FLAGS PROPERTY VALUE)
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===================================================================
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -1,5 +1,6 @@
include(ExternalProject)
include(CompilerRTUtils)
+include(HandleCompilerRT)
function(set_target_output_directories target output_dir)
# For RUNTIME_OUTPUT_DIRECTORY variable, Multi-configuration generators
@@ -220,6 +221,10 @@
set_output_name(output_name_${libname} ${name} ${arch})
endif()
endif()
+ if(COMPILER_RT_USE_BUILTINS_LIBRARY AND NOT type STREQUAL "OBJECT")
+ get_compiler_rt_target(${arch} target)
+ find_compiler_rt_library(builtins ${target} builtins_${libname})
+ endif()
set(sources_${libname} ${LIB_SOURCES})
format_object_libs(sources_${libname} ${arch} ${LIB_OBJECT_LIBS})
set(libnames ${libnames} ${libname})
@@ -313,6 +318,9 @@
if(LIB_LINK_LIBS)
target_link_libraries(${libname} PRIVATE ${LIB_LINK_LIBS})
endif()
+ if(builtins_${libname})
+ target_link_libraries(${libname} PRIVATE ${builtins_${libname}})
+ endif()
if(${type} STREQUAL "SHARED")
if(COMMAND llvm_setup_rpath)
llvm_setup_rpath(${libname})
Index: compiler-rt/CMakeLists.txt
===================================================================
--- compiler-rt/CMakeLists.txt
+++ compiler-rt/CMakeLists.txt
@@ -401,7 +401,6 @@
append_list_if(COMPILER_RT_HAS_Z_TEXT -Wl,-z,text SANITIZER_COMMON_LINK_FLAGS)
if (COMPILER_RT_USE_BUILTINS_LIBRARY)
- list(APPEND SANITIZER_COMMON_LINK_LIBS ${COMPILER_RT_BUILTINS_LIBRARY})
string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else()
if (ANDROID)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74133.242913.patch
Type: text/x-patch
Size: 3212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200206/62b0a7a8/attachment.bin>
More information about the llvm-commits
mailing list