diff --git a/cmake/compiler/clang.cmake b/cmake/compiler/clang.cmake index 976efd8fb23..c04370147e3 100644 --- a/cmake/compiler/clang.cmake +++ b/cmake/compiler/clang.cmake @@ -33,5 +33,20 @@ foreach(isystem_include_dir ${NOSTDINC}) list(APPEND isystem_include_flags -isystem ${isystem_include_dir}) endforeach() +execute_process( + COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name + OUTPUT_VARIABLE LIBGCC_FILE_NAME + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + +assert_exists(LIBGCC_FILE_NAME) + +get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY) + +assert_exists(LIBGCC_DIR) + +list(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"") +list(APPEND TOOLCHAIN_LIBS gcc) + set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags} -Wl,--unresolved-symbols=ignore-in-object-files) string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")