cmake: use sdk-ng built toolchain for x86_64

This adds the necessary bits to utilize the x86_64 toolchain
built by sdk-ng for x86_64 when toolchain variant is either
zephyr or xtools. This allows decoupling the builds from
the host toolchain.

Newlib is also available with this toolchain so remove
the Kconfig restriction on CONFIG_NEWLIB_LIBC.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2019-05-07 08:37:46 -07:00 committed by Anas Nashif
commit 1c5fa6a128
7 changed files with 16 additions and 3 deletions

View file

@ -11,4 +11,7 @@ add_subdirectory(core)
zephyr_compile_options(${X86_64_BASE_CFLAGS} -mx32) zephyr_compile_options(${X86_64_BASE_CFLAGS} -mx32)
zephyr_link_libraries(-mx32) zephyr_link_libraries(
-mx32
${LINKERFLAGPREFIX},-melf32_x86_64
)

View file

@ -48,6 +48,7 @@ add_custom_command(
-T ${CMAKE_CURRENT_SOURCE_DIR}/xuk-stub32.ld -T ${CMAKE_CURRENT_SOURCE_DIR}/xuk-stub32.ld
${CMAKE_CURRENT_BINARY_DIR}/xuk-stub32.o ${CMAKE_CURRENT_BINARY_DIR}/xuk-stub32.o
-o ${CMAKE_CURRENT_BINARY_DIR}/xuk-stub32.elf -o ${CMAKE_CURRENT_BINARY_DIR}/xuk-stub32.elf
${LINKERFLAGPREFIX},-melf_i386
COMMAND ${CMAKE_OBJCOPY} -O binary COMMAND ${CMAKE_OBJCOPY} -O binary
${CMAKE_CURRENT_BINARY_DIR}/xuk-stub32.elf ${CMAKE_CURRENT_BINARY_DIR}/xuk-stub32.elf
${incdir}/xuk-stub32.bin ${incdir}/xuk-stub32.bin
@ -70,4 +71,5 @@ add_custom_command(
COMMAND ${CMAKE_C_COMPILER} -m32 -T ${CMAKE_CURRENT_SOURCE_DIR}/xuk64.ld COMMAND ${CMAKE_C_COMPILER} -m32 -T ${CMAKE_CURRENT_SOURCE_DIR}/xuk64.ld
-Wl,--build-id=none -nostdlib -nodefaultlibs -nostartfiles -Wl,--build-id=none -nostdlib -nodefaultlibs -nostartfiles
-o ${qkernel_file} ${CMAKE_CURRENT_BINARY_DIR}/zephyr-qemu.o -o ${qkernel_file} ${CMAKE_CURRENT_BINARY_DIR}/zephyr-qemu.o
${LINKERFLAGPREFIX},-melf_i386
) )

View file

@ -6,5 +6,6 @@ arch: x86_64
toolchain: toolchain:
- zephyr - zephyr
- host - host
- xtools
testing: testing:
default: true default: true

View file

@ -54,7 +54,7 @@ set(ZEPHYR_TOOLCHAIN_VARIANT ${ZEPHYR_TOOLCHAIN_VARIANT} CACHE STRING "Zephyr to
assert(ZEPHYR_TOOLCHAIN_VARIANT "Zephyr toolchain variant invalid: please set the ZEPHYR_TOOLCHAIN_VARIANT-variable") assert(ZEPHYR_TOOLCHAIN_VARIANT "Zephyr toolchain variant invalid: please set the ZEPHYR_TOOLCHAIN_VARIANT-variable")
# Pick host system's toolchain if we are targeting posix # Pick host system's toolchain if we are targeting posix
if((${ARCH} STREQUAL "posix") OR (${ARCH} STREQUAL "x86_64")) if(${ARCH} STREQUAL "posix")
if(NOT "${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "llvm") if(NOT "${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "llvm")
set(ZEPHYR_TOOLCHAIN_VARIANT "host") set(ZEPHYR_TOOLCHAIN_VARIANT "host")
endif() endif()

View file

@ -13,6 +13,7 @@ set(CROSS_COMPILE_TARGET_riscv32 riscv32-zephyr-elf)
set(CROSS_COMPILE_TARGET_mips mipsel-zephyr-elf) set(CROSS_COMPILE_TARGET_mips mipsel-zephyr-elf)
set(CROSS_COMPILE_TARGET_xtensa xtensa-zephyr-elf) set(CROSS_COMPILE_TARGET_xtensa xtensa-zephyr-elf)
set(CROSS_COMPILE_TARGET_arc arc-zephyr-elf) set(CROSS_COMPILE_TARGET_arc arc-zephyr-elf)
set(CROSS_COMPILE_TARGET_x86_64 x86_64-zephyr-elf)
set(CROSS_COMPILE_TARGET ${CROSS_COMPILE_TARGET_${ARCH}}) set(CROSS_COMPILE_TARGET ${CROSS_COMPILE_TARGET_${ARCH}})
set(SYSROOT_TARGET ${CROSS_COMPILE_TARGET}) set(SYSROOT_TARGET ${CROSS_COMPILE_TARGET})
@ -29,4 +30,7 @@ if("${ARCH}" STREQUAL "xtensa")
LIST(APPEND TOOLCHAIN_LIBS hal) LIST(APPEND TOOLCHAIN_LIBS hal)
LIST(APPEND LIB_INCLUDE_DIR -L${SYSROOT_DIR}/lib) LIST(APPEND LIB_INCLUDE_DIR -L${SYSROOT_DIR}/lib)
elseif("${ARCH}" STREQUAL "x86_64")
list(APPEND TOOLCHAIN_C_FLAGS -mx32)
list(APPEND TOOLCHAIN_LD_FLAGS -mx32)
endif() endif()

View file

@ -13,6 +13,7 @@ set(CROSS_COMPILE_TARGET_riscv32 riscv32-zephyr-elf)
set(CROSS_COMPILE_TARGET_mips mipsel-zephyr-elf) set(CROSS_COMPILE_TARGET_mips mipsel-zephyr-elf)
set(CROSS_COMPILE_TARGET_xtensa xtensa-zephyr-elf) set(CROSS_COMPILE_TARGET_xtensa xtensa-zephyr-elf)
set(CROSS_COMPILE_TARGET_arc arc-zephyr-elf) set(CROSS_COMPILE_TARGET_arc arc-zephyr-elf)
set(CROSS_COMPILE_TARGET_x86_64 x86_64-zephyr-elf)
set(CROSS_COMPILE_TARGET ${CROSS_COMPILE_TARGET_${ARCH}}) set(CROSS_COMPILE_TARGET ${CROSS_COMPILE_TARGET_${ARCH}})
set(SYSROOT_TARGET ${CROSS_COMPILE_TARGET}) set(SYSROOT_TARGET ${CROSS_COMPILE_TARGET})
@ -28,5 +29,8 @@ if("${ARCH}" STREQUAL "xtensa")
LIST(APPEND TOOLCHAIN_LIBS hal) LIST(APPEND TOOLCHAIN_LIBS hal)
LIST(APPEND LIB_INCLUDE_DIR -L${SYSROOT_DIR}/lib) LIST(APPEND LIB_INCLUDE_DIR -L${SYSROOT_DIR}/lib)
elseif("${ARCH}" STREQUAL "x86_64")
list(APPEND TOOLCHAIN_C_FLAGS -mx32)
list(APPEND TOOLCHAIN_LD_FLAGS -mx32)
endif() endif()
set(SYSROOT_DIR ${TOOLCHAIN_HOME}/${SYSROOT_TARGET}/${SYSROOT_TARGET}) set(SYSROOT_DIR ${TOOLCHAIN_HOME}/${SYSROOT_TARGET}/${SYSROOT_TARGET})

View file

@ -11,7 +11,6 @@ depends on !NATIVE_APPLICATION
config NEWLIB_LIBC config NEWLIB_LIBC
bool "Build with newlib c library" bool "Build with newlib c library"
depends on !X86_64
help help
Build with newlib library. The newlib library is expected to be Build with newlib library. The newlib library is expected to be
part of the SDK in this case. part of the SDK in this case.