[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] 8b2fcc42b8, https://reviews.llvm.org/D84466

Differential Revision: https://reviews.llvm.org/D85057
This commit is contained in:
Julian Lettner
2020-07-31 16:09:13 -07:00
parent 721d93fc5a
commit ff756f5231

View File

@@ -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