clang/llvm: add initial configuration file for clang
Add an LLVM backend and a clang toolchain variant to support building with llvm coming with popular Linux distributions. This has been tested with X86 boards: - quark_d2000_crb - quark_se_c1000_devboard/Arduino 101 Use: export ZEPHYR_TOOLCHAIN_VARIANT=clang Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
7c9a1f0f76
commit
72edc4e15f
|
@ -230,9 +230,17 @@ zephyr_compile_options(${CONFIG_COMPILER_OPT_AS_LIST})
|
|||
|
||||
# TODO: Include arch compiler options at this point.
|
||||
|
||||
# TODO: This Clang check is broken
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
zephyr_cc_option(
|
||||
#FIXME: need to fix all of those
|
||||
-Wno-sometimes-uninitialized
|
||||
-Wno-shift-overflow
|
||||
-Wno-missing-braces
|
||||
-Wno-self-assign
|
||||
-Wno-address-of-packed-member
|
||||
-Wno-unused-function
|
||||
-Wno-initializer-overrides
|
||||
-Wno-section
|
||||
-Wno-unknown-warning-option
|
||||
-Wno-unused-variable
|
||||
-Wno-format-invalid-specifier
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
zephyr_library()
|
||||
|
||||
if (COMPILER STREQUAL "clang")
|
||||
if (CMAKE_LANG_COMPILER_ID STREQUAL "Clang")
|
||||
# We rely on GAS for assembling, so don't use the integrated assembler
|
||||
zephyr_compile_options_ifndef(CONFIG_X86_IAMCU $<$<COMPILE_LANGUAGE:ASM>:-no-integrated-as>)
|
||||
elseif(CMAKE_LANG_COMPILER_ID STREQUAL "GNU")
|
||||
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--divide>)
|
||||
endif()
|
||||
|
||||
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--divide>)
|
||||
|
||||
zephyr_library_sources(
|
||||
cache.c
|
||||
cache_s.S
|
||||
|
|
22
cmake/compiler/llvm.cmake
Normal file
22
cmake/compiler/llvm.cmake
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Configuration for host installed llvm
|
||||
#
|
||||
|
||||
set(NOSTDINC "")
|
||||
|
||||
foreach(file_name include include-fixed)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
|
||||
OUTPUT_VARIABLE _OUTPUT
|
||||
)
|
||||
string(REGEX REPLACE "\n" "" _OUTPUT ${_OUTPUT})
|
||||
|
||||
list(APPEND NOSTDINC ${_OUTPUT})
|
||||
endforeach()
|
||||
|
||||
foreach(isystem_include_dir ${NOSTDINC})
|
||||
list(APPEND isystem_include_flags -isystem ${isystem_include_dir})
|
||||
endforeach()
|
||||
|
||||
set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags} -Wl,--unresolved-symbols=ignore-in-object-files)
|
||||
string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
||||
|
24
cmake/toolchain/clang.cmake
Normal file
24
cmake/toolchain/clang.cmake
Normal file
|
@ -0,0 +1,24 @@
|
|||
set(CLANG_ROOT $ENV{CLANG_ROOT_DIR})
|
||||
set_ifndef(CLANG_ROOT /usr)
|
||||
set(COMPILER clang)
|
||||
|
||||
if(CONFIG_ARM)
|
||||
set(triple arm-none-eabi)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs")
|
||||
elseif(CONFIG_X86)
|
||||
set(triple i686-pc-none-elf)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER ${CLANG_ROOT}/bin/clang)
|
||||
set(CMAKE_C_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_ASM_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_CXX_COMPILER ${CLANG_ROOT}/bin/clang++)
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_AR "${CLANG_ROOT}/bin/llvm-ar" CACHE INTERNAL " " FORCE)
|
||||
set(CMAKE_LINKER "${CLANG_ROOT}/bin/llvm-link" CACHE INTERNAL " " FORCE)
|
||||
SET(CMAKE_NM "${CLANG_ROOT}/bin/llvm-nm" CACHE INTERNAL " " FORCE)
|
||||
SET(CMAKE_OBJDUMP "${CLANG_ROOT}/bin/llvm-objdump" CACHE INTERNAL " " FORCE)
|
||||
SET(CMAKE_RANLIB "${CLANG_ROOT}/bin/llvm-ranlib" CACHE INTERNAL " " FORCE)
|
||||
set(CMAKE_OBJCOPY objcopy CACHE INTERNAL " " FORCE)
|
||||
set(CMAKE_READELF readelf CACHE INTERNAL " " FORCE)
|
||||
|
Loading…
Reference in a new issue