Add initial LLVM toolchain support

This commit is contained in:
Jasper Lowell 2019-03-12 16:05:21 +11:00
parent 7262cb87e6
commit 895726d410
2 changed files with 54 additions and 4 deletions

View file

@ -53,17 +53,21 @@ if(KernelArchX86)
set(build_arch "-march=${KernelX86MicroArch}")
endif()
if(Kernel64)
string(APPEND asm_common_flags " -Wa,--64")
if(NOT LLVM_TOOLCHAIN)
string(APPEND asm_common_flags " -Wa,--64")
endif()
string(APPEND c_common_flags " -m64")
else()
string(APPEND asm_common_flags " -Wa,--32")
if(NOT LLVM_TOOLCHAIN)
string(APPEND asm_common_flags " -Wa,--32")
endif()
string(APPEND c_common_flags " -m32")
endif()
endif()
if(KernelArchARM)
set(arm_march "${KernelArmArmV}${KernelArmMachFeatureModifiers}")
string(APPEND c_common_flags " -march=${arm_march}")
string(APPEND asm_common_flags " -Wa,-march=${arm_march}")
string(APPEND asm_common_flags " -march=${arm_march}")
# Explicitly request ARM instead of THUMB for compilation. This option is not
# relevant on aarch64
if(NOT KernelSel4ArchAarch64)
@ -407,5 +411,5 @@ target_include_directories(kernel.elf PRIVATE ${config_dir})
target_include_directories(kernel.elf PRIVATE include)
target_include_directories(kernel.elf PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
target_link_libraries(kernel.elf PRIVATE kernel_Config kernel_autoconf)
set_property(TARGET kernel.elf APPEND_STRING PROPERTY LINK_FLAGS " -T ${linker_lds_path} ")
set_property(TARGET kernel.elf APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-T ${linker_lds_path} ")
add_dependencies(kernel.elf linker_ld_wrapper kernel_i_wrapper kernel_all_pp_wrapper circular_includes)

46
llvm.cmake Normal file
View file

@ -0,0 +1,46 @@
#
# Copyright 2019, Data61
# Commonwealth Scientific and Industrial Research Organisation (CSIRO)
# ABN 41 687 119 230.
#
# This software may be distributed and modified according to the terms of
# the GNU General Public License version 2. Note that NO WARRANTY is provided.
# See "LICENSE_GPLv2.txt" for details.
#
# @TAG(DATA61_GPL)
#
cmake_minimum_required(VERSION 3.7.2)
set(CMAKE_SYSTEM_NAME Generic)
# For a generic system this is unused, so define it to something that will be
# obvious if someone accidentally uses it
set(CMAKE_SYSTEM_PROCESSOR seL4CPU)
set(LLVM_TOOLCHAIN ON)
set(CMAKE_ASM_COMPILER "clang")
set(CMAKE_ASM_COMPILER_ID Clang)
set(CMAKE_ASM_COMPILER_TARGET ${TRIPLE})
string(APPEND asm_common_flags " -Wno-unused-command-line-argument")
set(CMAKE_C_COMPILER "clang")
set(CMAKE_C_COMPILER_ID Clang)
set(CMAKE_C_COMPILER_TARGET ${TRIPLE})
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_CXX_COMPILER_ID Clang)
set(CMAKE_CXX_COMPILER_TARGET ${TRIPLE})
string(APPEND c_common_flags " -Qunused-arguments")
string(APPEND c_common_flags " -Wno-constant-logical-operand")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
mark_as_advanced(FORCE CMAKE_TOOLCHAIN_FILE)