host-gcc: TOOLCHAIN_LIBS += libgcc (copied from compiler/gcc/)

Add missing -lgcc when compiling with ZEPHYR_TOOLCHAIN_VARIANT=host
merely copying some existing code from
'compiler/{clang,gcc}/target.cmake'.

This fixes compilation for the following boards with an x86
microprocessor:

 galileo, minnowboard, qemu_x86, qemu_x86_nommu, up_squared,
 up_squared_sbl

Compilation of the following boards with an X86_IAMCU microcontroller
still fail with a "cannot find -lgcc" error:

 arduino_101, qemu_x86_iamcu, quark_d2000_crb, quark_se_c1000_devboard,
 tinytile

This is _not_ a regression because these boards _already_ failed with
"undefined reference to __udivdi3" and other libgcc symbols.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2019-01-22 17:54:42 -08:00 committed by Anas Nashif
parent 5ac9cfd131
commit aa4ed2ae8c
3 changed files with 16 additions and 0 deletions

View file

@ -33,6 +33,7 @@ foreach(isystem_include_dir ${NOSTDINC})
list(APPEND isystem_include_flags -isystem ${isystem_include_dir})
endforeach()
# This libgcc code is partially duplicated in compiler/*/target.cmake
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
OUTPUT_VARIABLE LIBGCC_FILE_NAME

View file

@ -109,6 +109,7 @@ else()
endif()
if(NOT no_libgcc)
# This libgcc code is partially duplicated in compiler/*/target.cmake
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
OUTPUT_VARIABLE LIBGCC_FILE_NAME

View file

@ -27,3 +27,17 @@ else()
endif()
endif()
find_program(CMAKE_CXX_COMPILER ${cplusplus_compiler} CACHE INTERNAL " " FORCE)
# This libgcc code is partially duplicated in compiler/*/target.cmake
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} --print-libgcc-file-name
OUTPUT_VARIABLE LIBGCC_FILE_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
assert_exists(LIBGCC_FILE_NAME)
# While most x86_64 Linux distributions implement "multilib" and have
# 32 bits libraries off the shelf, things like
# "/usr/lib/gcc/x86_64-linux-gnu/7/IAMCU/libgcc.a" are unheard of.
# So this does not support CONFIG_X86_IAMCU=y
LIST(APPEND TOOLCHAIN_LIBS gcc)