Skip to content

Commit ff0ab5d

Browse files
Andy Rossnashif
authored andcommitted
cmake/compiler/gcc: Fall back to host compiler for x86_64
If we don't have a detected cross compiler for x86_64, use the host compiler instead. Signed-off-by: Andy Ross <[email protected]>
1 parent 9c24867 commit ff0ab5d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

cmake/compiler/gcc/target.cmake

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,29 @@ find_program(CMAKE_READELF ${CROSS_COMPILE}readelf PATH ${TOOLCHAIN_HOME} NO_
1414
find_program(CMAKE_GDB ${CROSS_COMPILE}gdb PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
1515
find_program(CMAKE_NM ${CROSS_COMPILE}nm PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
1616

17+
# x86_64 should pick up a proper cross compiler if one is provided,
18+
# but falling back to using the host toolchain is a very sane behavior
19+
# too.
20+
if(CONFIG_X86_64)
21+
if(CMAKE_C_COMPILER STREQUAL CMAKE_C_COMPILER-NOTFOUND)
22+
find_program(CMAKE_C_COMPILER gcc )
23+
find_program(CMAKE_OBJCOPY objcopy)
24+
find_program(CMAKE_OBJDUMP objdump)
25+
find_program(CMAKE_AR ar )
26+
find_program(CMAKE_RANLILB ranlib )
27+
find_program(CMAKE_READELF readelf)
28+
find_program(CMAKE_GDB gdb )
29+
endif()
30+
31+
# When building in x32 mode with a host compiler, there is no libgcc
32+
# shipped (because it's an x86_64 compiler, not x32). That's
33+
# actually non-fatal, as no known features we hit in existing code
34+
# actually require the library. But I can't find an exaustive list
35+
# of exactly what can break, so this is fragile. Long term we
36+
# really need to be blessing a proper cross toolchain.
37+
set(no_libgcc Y)
38+
endif()
39+
1740
if(CONFIG_CPLUSPLUS)
1841
set(cplusplus_compiler ${CROSS_COMPILE}${C++})
1942
else()

0 commit comments

Comments
 (0)