Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOOLCHAIN_LD_FLAGS setting of -mabi/-march aren't propagated to linker invocation on RISC-V #28456

Closed
galak opened this issue Sep 17, 2020 · 0 comments · Fixed by #28500
Closed
Assignees
Labels
area: RISCV RISCV Architecture (32-bit & 64-bit) bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@galak
Copy link
Collaborator

galak commented Sep 17, 2020

The setting of TOOLCHAIN_LD_FLAGS in cmake/compiler/gcc/target_riscv.cmake has -mabi and -march set. These flags don't show up in the link invocation.

For example for building hello_world on qemu_riscv64 we have: -mabi=lp64 -march=rv64imac

and the link looks like:

riscv64-zephyr-elf/bin/riscv64-zephyr-elf-gcc CMakeFiles/zephyr_final.dir/misc/empty_file.c.obj CMakeFiles/zephyr_final.dir/isr_tables.c.obj  -o zephyr.elf  -Wl,-T linker_pass_final.cmd -Wl,-Map=/home/galak/git/zephyr/samples/hello_world/build/zephyr/zephyr_final.map -Wl,--whole-archive ../app/libapp.a libzephyr.a arch/common/libarch__common.a arch/arch/riscv/core/libarch__riscv__core.a lib/libc/minimal/liblib__libc__minimal.a lib/posix/liblib__posix.a drivers/gpio/libdrivers__gpio.a drivers/serial/libdrivers__serial.a -Wl,--no-whole-archive kernel/libkernel.a CMakeFiles/offsets.dir/arch/riscv/core/offsets/offsets.c.obj -L"riscv64-zephyr-elf/bin/../lib/gcc/riscv64-zephyr-elf/10.2.0/rv64imac/lp64/medany" -L/home/galak/git/zephyr/samples/hello_world/build/zephyr -lgcc arch/common/libisr_tables.a -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -no-pie -Wl,-X -Wl,-N -Wl,--orphan-handling=warn 
@galak galak added bug The issue is a bug, or the PR is fixing a bug area: RISCV RISCV Architecture (32-bit & 64-bit) priority: low Low impact/importance bug labels Sep 17, 2020
@galak galak self-assigned this Sep 17, 2020
@galak galak added the has-pr label Sep 17, 2020
galak added a commit to galak/zephyr that referenced this issue Sep 17, 2020
TOOLCHAIN_LD_FLAGS gets passed to zephyr_ld_options() that will call
zephyr_check_compiler_flag().  Current zephyr_check_compiler_flag()
fails on RISC-V for -mabi/-march as the compiler expects them to be
set together.  To make this work we quote them together so they'll
get treated as a single option rather than two distinct options.

Doing the same for TOOLCHAIN_C_FLAGS isn't required and actually
doesn't work because target_compile_options will end up keeping
the quoting.

Fixes zephyrproject-rtos#28456

Signed-off-by: Kumar Gala <[email protected]>
tejlmand added a commit to tejlmand/zephyr that referenced this issue Sep 18, 2020
Fixes zephyrproject-rtos#28456

This commit extends `target_ld_options()` with a NO_SPLIT flag.

Specifying `NO_SPLIT` will ensure that all linker flags will be applied
together when testing the compiler and linker.
This allows a caller to ensure that flags are tested together.

This fixes the RISC-V case where the flags `-mabi` and `-march` were
omitted because they were tested individually.

Note, the update of `target_ld_options()` will allow the same flag on
`zephyr_ld_options()`

Signed-off-by: Torsten Rasmussen <[email protected]>
carlescufi pushed a commit that referenced this issue Oct 27, 2020
Fixes #28456

This commit extends `target_ld_options()` with a NO_SPLIT flag.

Specifying `NO_SPLIT` will ensure that all linker flags will be applied
together when testing the compiler and linker.
This allows a caller to ensure that flags are tested together.

This fixes the RISC-V case where the flags `-mabi` and `-march` were
omitted because they were tested individually.

Note, the update of `target_ld_options()` will allow the same flag on
`zephyr_ld_options()`

Signed-off-by: Torsten Rasmussen <[email protected]>
pdgendt added a commit to pdgendt/zephyr that referenced this issue Mar 19, 2021
Similar to zephyrproject-rtos#28456 but for arm, make sure that linker flags
`-mfpu` and `-mfloat-abi` are not tested individually.

Signed-off-by: Pieter De Gendt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: RISCV RISCV Architecture (32-bit & 64-bit) bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
1 participant