From aa4ed2ae8c9834f627674620a296f77d89adade6 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 22 Jan 2019 17:54:42 -0800 Subject: [PATCH] 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 --- cmake/compiler/clang/target.cmake | 1 + cmake/compiler/gcc/target.cmake | 1 + cmake/compiler/host-gcc/target.cmake | 14 ++++++++++++++ 3 files changed, 16 insertions(+) diff --git a/cmake/compiler/clang/target.cmake b/cmake/compiler/clang/target.cmake index afc061541f2..db7e85a1795 100644 --- a/cmake/compiler/clang/target.cmake +++ b/cmake/compiler/clang/target.cmake @@ -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 diff --git a/cmake/compiler/gcc/target.cmake b/cmake/compiler/gcc/target.cmake index de3d19728c2..afbdaa118e7 100644 --- a/cmake/compiler/gcc/target.cmake +++ b/cmake/compiler/gcc/target.cmake @@ -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 diff --git a/cmake/compiler/host-gcc/target.cmake b/cmake/compiler/host-gcc/target.cmake index 922da85eb53..88da79a11a2 100644 --- a/cmake/compiler/host-gcc/target.cmake +++ b/cmake/compiler/host-gcc/target.cmake @@ -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)