Skip to content

Commit

Permalink
cmake: use sdk-ng built toolchain for x86_64
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dcpleung authored and nashif committed Jun 27, 2019
1 parent 06a3735 commit 1c5fa6a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion arch/x86_64/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ add_subdirectory(core)

zephyr_compile_options(${X86_64_BASE_CFLAGS} -mx32)

zephyr_link_libraries(-mx32)
zephyr_link_libraries(
-mx32
${LINKERFLAGPREFIX},-melf32_x86_64
)
2 changes: 2 additions & 0 deletions arch/x86_64/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ add_custom_command(
-T ${CMAKE_CURRENT_SOURCE_DIR}/xuk-stub32.ld
${CMAKE_CURRENT_BINARY_DIR}/xuk-stub32.o
-o ${CMAKE_CURRENT_BINARY_DIR}/xuk-stub32.elf
${LINKERFLAGPREFIX},-melf_i386
COMMAND ${CMAKE_OBJCOPY} -O binary
${CMAKE_CURRENT_BINARY_DIR}/xuk-stub32.elf
${incdir}/xuk-stub32.bin
Expand All @@ -70,4 +71,5 @@ add_custom_command(
COMMAND ${CMAKE_C_COMPILER} -m32 -T ${CMAKE_CURRENT_SOURCE_DIR}/xuk64.ld
-Wl,--build-id=none -nostdlib -nodefaultlibs -nostartfiles
-o ${qkernel_file} ${CMAKE_CURRENT_BINARY_DIR}/zephyr-qemu.o
${LINKERFLAGPREFIX},-melf_i386
)
1 change: 1 addition & 0 deletions boards/x86_64/qemu_x86_64/qemu_x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ arch: x86_64
toolchain:
- zephyr
- host
- xtools
testing:
default: true
2 changes: 1 addition & 1 deletion cmake/generic_toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")

# 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")
set(ZEPHYR_TOOLCHAIN_VARIANT "host")
endif()
Expand Down
4 changes: 4 additions & 0 deletions cmake/toolchain/xtools/target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(CROSS_COMPILE_TARGET_riscv32 riscv32-zephyr-elf)
set(CROSS_COMPILE_TARGET_mips mipsel-zephyr-elf)
set(CROSS_COMPILE_TARGET_xtensa xtensa-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(SYSROOT_TARGET ${CROSS_COMPILE_TARGET})
Expand All @@ -29,4 +30,7 @@ if("${ARCH}" STREQUAL "xtensa")

LIST(APPEND TOOLCHAIN_LIBS hal)
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()
4 changes: 4 additions & 0 deletions cmake/toolchain/zephyr/0.10.1/target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(CROSS_COMPILE_TARGET_riscv32 riscv32-zephyr-elf)
set(CROSS_COMPILE_TARGET_mips mipsel-zephyr-elf)
set(CROSS_COMPILE_TARGET_xtensa xtensa-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(SYSROOT_TARGET ${CROSS_COMPILE_TARGET})
Expand All @@ -28,5 +29,8 @@ if("${ARCH}" STREQUAL "xtensa")

LIST(APPEND TOOLCHAIN_LIBS hal)
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()
set(SYSROOT_DIR ${TOOLCHAIN_HOME}/${SYSROOT_TARGET}/${SYSROOT_TARGET})
1 change: 0 additions & 1 deletion lib/libc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ depends on !NATIVE_APPLICATION

config NEWLIB_LIBC
bool "Build with newlib c library"
depends on !X86_64
help
Build with newlib library. The newlib library is expected to be
part of the SDK in this case.
Expand Down

0 comments on commit 1c5fa6a

Please sign in to comment.