2019-04-06 15:08:09 +02:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2018-01-08 17:05:26 +01:00
|
|
|
# Configures CMake for using GCC
|
2017-10-03 16:31:55 +02:00
|
|
|
|
cmake: Toolchain abstraction: Abstraction of binary tools, foundation.
This forms the foundation for the abstraction of the binary tools,
where the following steps are taken:
- Move binary tool resolving, such as objcopy, objdump, readelf and
so forth, out of compiler definitions and place in a dedicated binary
tools folder with the binary tools supplier as subfolder, similar to
the compiler and linker directories.
- Create binary tool sets, gnu, host-gnu and llvm.
- Each toolchain selects the required set of binary tools by setting
BINTOOLS via its generic.cmake as it also does for compiler and linker.
The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.
No functional change expected.
Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-07-18 15:06:51 +02:00
|
|
|
find_program(CMAKE_C_COMPILER gcc)
|
2018-04-17 16:39:52 +02:00
|
|
|
|
2017-10-03 16:31:55 +02:00
|
|
|
if(CONFIG_CPLUSPLUS)
|
|
|
|
set(cplusplus_compiler g++)
|
|
|
|
else()
|
|
|
|
if(EXISTS g++)
|
|
|
|
set(cplusplus_compiler g++)
|
|
|
|
else()
|
|
|
|
# When the toolchain doesn't support C++, and we aren't building
|
|
|
|
# with C++ support just set it to something so CMake doesn't
|
|
|
|
# crash, it won't actually be called
|
|
|
|
set(cplusplus_compiler ${CMAKE_C_COMPILER})
|
|
|
|
endif()
|
|
|
|
endif()
|
2018-04-17 16:39:52 +02:00
|
|
|
find_program(CMAKE_CXX_COMPILER ${cplusplus_compiler} CACHE INTERNAL " " FORCE)
|
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>
2019-01-23 02:54:42 +01:00
|
|
|
|
2019-01-29 01:15:00 +01:00
|
|
|
# The x32 version of libgcc is usually not available (can't trust gcc
|
|
|
|
# -mx32 --print-libgcc-file-name) so don't fail to build for something
|
|
|
|
# that is currently not needed. See comments in compiler/gcc/target.cmake
|
2019-07-03 19:21:40 +02:00
|
|
|
if (CONFIG_X86)
|
2019-03-02 03:39:58 +01:00
|
|
|
# Convert to list as cmake Modules/*.cmake do it
|
2019-12-31 12:01:36 +01:00
|
|
|
STRING(REGEX REPLACE " +" ";" PRINT_LIBGCC_ARGS "${CMAKE_C_FLAGS}")
|
2019-01-29 01:15:00 +01:00
|
|
|
# This libgcc code is partially duplicated in compiler/*/target.cmake
|
|
|
|
execute_process(
|
2019-12-31 12:01:36 +01:00
|
|
|
COMMAND ${CMAKE_C_COMPILER} "${PRINT_LIBGCC_ARGS}" --print-libgcc-file-name
|
2019-01-29 01:15:00 +01:00
|
|
|
OUTPUT_VARIABLE LIBGCC_FILE_NAME
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
assert_exists(LIBGCC_FILE_NAME)
|
|
|
|
endif()
|
2019-01-10 12:07:51 +01:00
|
|
|
|
2019-02-19 23:02:30 +01:00
|
|
|
set(NOSTDINC "")
|
|
|
|
|
|
|
|
# Note that NOSYSDEF_CFLAG may be an empty string, and
|
|
|
|
# set_ifndef() does not work with empty string.
|
|
|
|
if(NOT DEFINED NOSYSDEF_CFLAG)
|
|
|
|
set(NOSYSDEF_CFLAG -undef)
|
|
|
|
endif()
|
|
|
|
|
2019-05-09 07:00:06 +02:00
|
|
|
foreach(file_name include/stddef.h)
|
2019-02-19 23:02:30 +01:00
|
|
|
execute_process(
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
|
|
|
|
OUTPUT_VARIABLE _OUTPUT
|
|
|
|
)
|
2019-05-09 07:00:06 +02:00
|
|
|
get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY)
|
2019-02-19 23:02:30 +01:00
|
|
|
string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}")
|
|
|
|
|
|
|
|
list(APPEND NOSTDINC ${_OUTPUT})
|
|
|
|
endforeach()
|
|
|
|
|
2019-01-10 12:07:51 +01:00
|
|
|
# Load toolchain_cc-family macros
|
|
|
|
# Significant overlap with freestanding gcc compiler so reuse it
|
2019-03-08 11:29:31 +01:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_freestanding.cmake)
|
2019-01-10 12:07:51 +01:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_security_fortify.cmake)
|
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_security_canaries.cmake)
|
2019-01-30 10:12:30 +01:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_optimizations.cmake)
|
2019-02-18 23:54:30 +01:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_cpp.cmake)
|
2019-01-30 21:48:25 +01:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_asm.cmake)
|
2019-02-21 20:13:28 +01:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_baremetal.cmake)
|
2019-05-06 14:34:43 +02:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_warnings.cmake)
|
2019-06-11 13:55:53 +02:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake)
|
2019-06-12 14:56:46 +02:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake)
|
2019-08-24 11:12:38 +02:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_coverage.cmake)
|
2019-08-22 22:03:22 +02:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_sanitizers.cmake)
|