Skip to content
Permalink
Browse files

arch/posix: 64-bit build flags

We need to pass -m64 instead of -m32 when CONFIG_64BIT is set.
This is pretty x86 centric. Many platforms don't have the ability
to select between 32-bits or 64-bits builds and either of those should
be dropped in that case with restriction on the available configuration
done elsewhere. But for the time being this allows for testing both.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
  • Loading branch information...
Nicolas Pitre authored and andrewboie committed Jul 3, 2019
1 parent 74db5ce commit 1f783d92568725a1e4235ee2409cd2391609e155
Showing with 11 additions and 6 deletions.
  1. +9 −2 arch/posix/CMakeLists.txt
  2. +2 −4 cmake/compiler/host-gcc/target.cmake
@@ -1,7 +1,15 @@
# SPDX-License-Identifier: Apache-2.0

if (CONFIG_64BIT)
# some gcc versions fail to build without -fPIC
zephyr_compile_options(-m64 -fPIC)
zephyr_ld_options(-m64)
else ()
zephyr_compile_options(-m32)
zephyr_ld_options(-m32)
endif ()

zephyr_compile_options(
-m32
-MMD
-MP
${ARCH_FLAG}
@@ -33,7 +41,6 @@ zephyr_compile_definitions(_POSIX_C_SOURCE=200809 _XOPEN_SOURCE=600 _XOPEN_SOURC
zephyr_ld_options(
-ldl
-pthread
-m32
)

# About the -include directive: The reason to do it this way, is because in this
@@ -14,11 +14,9 @@ find_program(CMAKE_GDB gdb )
# -march={pentium,lakemont,...} do not automagically imply -m32, so
# adding it here.

# There's only one 64bits ARCH (actually: -mx32). Let's exclude it to
# avoid a confusing game of "who's last on the command line wins".
# Maybe the -m32/-miamcu FLAGS should all be next to -march= in the
# longer term?
if(NOT CONFIG_X86_64)
if (CONFIG_X86)
string(PREPEND CMAKE_ASM_FLAGS "-m32 ")
string(PREPEND CMAKE_C_FLAGS "-m32 ")
string(PREPEND CMAKE_CXX_FLAGS "-m32 ")
@@ -42,7 +40,7 @@ find_program(CMAKE_CXX_COMPILER ${cplusplus_compiler} CACHE INTERNAL " " FOR
# 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
if (NOT CONFIG_X86_64)
if (CONFIG_X86)
# Convert to list as cmake Modules/*.cmake do it
STRING(REGEX REPLACE " +" ";" PRINT_LIBGCC_ARGS ${CMAKE_C_FLAGS})
# This libgcc code is partially duplicated in compiler/*/target.cmake

0 comments on commit 1f783d9

Please sign in to comment.
You can’t perform that action at this time.