Skip to content

Commit 4df24ad

Browse files
committed
compiler: clang: Don't link libgcc for native_posix
libgcc isn't used by native_posix. Signed-off-by: Oleg Zhurakivskyy <[email protected]>
1 parent 5ced3e3 commit 4df24ad

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

cmake/compiler/clang/target.cmake

+28-24
Original file line numberDiff line numberDiff line change
@@ -28,38 +28,42 @@ find_program(CMAKE_RANLIB llvm-ranlib ${find_program_clang_args})
2828
find_program(CMAKE_OBJCOPY objcopy ${find_program_binutils_args})
2929
find_program(CMAKE_READELF readelf ${find_program_binutils_args})
3030

31-
foreach(file_name include include-fixed)
32-
execute_process(
33-
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
34-
OUTPUT_VARIABLE _OUTPUT
35-
)
36-
string(REGEX REPLACE "\n" "" _OUTPUT ${_OUTPUT})
31+
if(NOT "${ARCH}" STREQUAL "posix")
3732

38-
list(APPEND NOSTDINC ${_OUTPUT})
39-
endforeach()
33+
foreach(file_name include include-fixed)
34+
execute_process(
35+
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
36+
OUTPUT_VARIABLE _OUTPUT
37+
)
38+
string(REGEX REPLACE "\n" "" _OUTPUT ${_OUTPUT})
4039

41-
foreach(isystem_include_dir ${NOSTDINC})
42-
list(APPEND isystem_include_flags -isystem ${isystem_include_dir})
43-
endforeach()
40+
list(APPEND NOSTDINC ${_OUTPUT})
41+
endforeach()
4442

45-
# This libgcc code is partially duplicated in compiler/*/target.cmake
46-
execute_process(
47-
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
48-
OUTPUT_VARIABLE LIBGCC_FILE_NAME
49-
OUTPUT_STRIP_TRAILING_WHITESPACE
50-
)
43+
foreach(isystem_include_dir ${NOSTDINC})
44+
list(APPEND isystem_include_flags -isystem ${isystem_include_dir})
45+
endforeach()
5146

52-
assert_exists(LIBGCC_FILE_NAME)
47+
# This libgcc code is partially duplicated in compiler/*/target.cmake
48+
execute_process(
49+
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
50+
OUTPUT_VARIABLE LIBGCC_FILE_NAME
51+
OUTPUT_STRIP_TRAILING_WHITESPACE
52+
)
5353

54-
get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY)
54+
assert_exists(LIBGCC_FILE_NAME)
5555

56-
assert_exists(LIBGCC_DIR)
56+
get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY)
5757

58-
list(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"")
59-
list(APPEND TOOLCHAIN_LIBS gcc)
58+
assert_exists(LIBGCC_DIR)
6059

61-
set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags} -Wl,--unresolved-symbols=ignore-in-object-files)
62-
string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
60+
list(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"")
61+
list(APPEND TOOLCHAIN_LIBS gcc)
62+
63+
set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags} -Wl,--unresolved-symbols=ignore-in-object-files)
64+
string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
65+
66+
endif()
6367

6468
# Load toolchain_cc-family macros
6569

0 commit comments

Comments
 (0)