mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2024-12-28 04:23:36 +01:00
meta: build with -ffreestanding
As of now (fxSDK 2.11), this flag is set globally by the fxSDK, so this change doesn't have an immediate effect. However, I've been experimenting with removing -ffreestanding at the global level to allow applications to build with the hosted C++ library (which isn't fully supported by has many supported features, like containers, that aren't available in free-standing mode). Without -ffreestanding, LTO makes weird decisions and ends up pruning way too many symbols from libraries, leading to undefined references for symbols provided by the standard library. Here is a minimal example. --- % cat abort.c void abort(void) { __builtin_unreachable(); } % cat main.c extern void abort(void); int start(void) { abort(); return 0; } % cat sh-min.x ENTRY(_start) OUTPUT_FORMAT(elf32-sh) SECTIONS { . = 0x1000; .text : { *(.text) } .data : { *(.data) } .bss : { *(.bss) } } % sh-elf-gcc -flto -nostdlib -ffreestanding -c abort.c -o abort.o % sh-elf-gcc-ar rcs abort.a abort.o % sh-elf-gcc -flto -nostdlib -c main.c -o main.o % sh-elf-gcc -flto -nostdlib -save-temps main.o -o main -T ./sh-min.x abort.a -lgcc ld: ./main.ltrans0.ltrans.o: in function `_start': <artificial>:(.text+0xc): undefined reference to `_abort' --- To solve the bug in this example, add -ffreestanding when making main.o. I haven't been able to sufficiently dump/introspect intermediate files to understand what's happening yet. It's also unclear whether the fix is clean since LTO normally requires all files to be built with the same settings, so adding -ffreestanding to gint but not the add-in seems suspicious. There is, however, an inherent incompatibility in the conjunction of (1) building kernels with -ffreestanding, (2) building add-ins that use the C++ library thus require -fhosted, and (3) only linking objects files built with the same options.
This commit is contained in:
parent
ae3250edd0
commit
b0c4e6fd2f
1 changed files with 1 additions and 1 deletions
|
@ -261,7 +261,7 @@ fxconv_declare_assets(${ASSETS_FX} ${ASSETS_CG})
|
|||
include_directories(
|
||||
"${PROJECT_SOURCE_DIR}/include"
|
||||
"${PROJECT_BINARY_DIR}/include")
|
||||
add_compile_options(-Wall -Wextra -std=c11 -Os -g -fstrict-volatile-bitfields -mtas -flto)
|
||||
add_compile_options(-Wall -Wextra -std=c11 -Os -g -fstrict-volatile-bitfields -mtas -ffreestanding -flto)
|
||||
|
||||
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
|
||||
add_compile_definitions(FX9860G)
|
||||
|
|
Loading…
Reference in a new issue