[compiler-rt] ff756f5 - [compiler-rt][Darwin] Fix linker errors for check-asan

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 31 16:45:27 PDT 2020


Author: Julian Lettner
Date: 2020-07-31T16:43:21-07:00
New Revision: ff756f5231cc2ee9457129404e78420fa2791c7b

URL: https://github.com/llvm/llvm-project/commit/ff756f5231cc2ee9457129404e78420fa2791c7b
DIFF: https://github.com/llvm/llvm-project/commit/ff756f5231cc2ee9457129404e78420fa2791c7b.diff

LOG: [compiler-rt][Darwin] Fix linker errors for check-asan

A recent change broke `ninja check-asan` on Darwin by causing an error
during linking of ASan unit tests [1].

Move the addition of `-ObjC` compiler flag outside of the new
`if(COMPILER_RT_STANDALONE_BUILD)` block.  It doesn't add any global
flags (e.g, `${CMAKE_CXX_FLAGS}`) and the decision to add is based
solely on source paths (`${source_rpath}`).

[1] 8b2fcc42b895, https://reviews.llvm.org/D84466

Differential Revision: https://reviews.llvm.org/D85057

Added: 
    

Modified: 
    compiler-rt/cmake/Modules/CompilerRTCompile.cmake

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/Modules/CompilerRTCompile.cmake b/compiler-rt/cmake/Modules/CompilerRTCompile.cmake
index 3330038f8068..0b679dbf68fa 100644
--- a/compiler-rt/cmake/Modules/CompilerRTCompile.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTCompile.cmake
@@ -73,7 +73,6 @@ function(clang_compile object_file source)
   if(COMPILER_RT_STANDALONE_BUILD)
     # Only add global flags in standalone build.
     string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath})
-    string(REGEX MATCH "[.](m|mm)$" is_objc ${source_rpath})
     if(is_cxx)
       string(REPLACE " " ";" global_flags "${CMAKE_CXX_FLAGS}")
     else()
@@ -87,9 +86,6 @@ function(clang_compile object_file source)
     if (APPLE)
       set(global_flags ${OSX_SYSROOT_FLAG} ${global_flags})
     endif()
-    if (is_objc)
-      list(APPEND global_flags -ObjC)
-    endif()
 
     # Ignore unknown warnings. CMAKE_CXX_FLAGS may contain GCC-specific options
     # which are not supported by Clang.
@@ -98,6 +94,12 @@ function(clang_compile object_file source)
   else()
     set(compile_flags ${SOURCE_CFLAGS})
   endif()
+
+  string(REGEX MATCH "[.](m|mm)$" is_objc ${source_rpath})
+  if (is_objc)
+    list(APPEND compile_flags "-ObjC")
+  endif()
+
   add_custom_command(
     OUTPUT ${object_file}
     COMMAND ${COMPILER_RT_TEST_COMPILER} ${compile_flags} -c


        


More information about the llvm-commits mailing list