[lld] [RISCV][LLD] Zcmt RISC-V extension in lld (PR #163142)
Robin Kastberg via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 14 10:49:33 PDT 2025
RobinKastberg wrote:
I tried zephyr with this..
```
user at b7f43aa2a597:/workdir/zephyr/build$ /workdir/llvm/build/bin/clang --target=riscv32-unknown-elf -Oz zephyr/CMakeFiles/zephyr_final.dir/misc/empty_file.c.obj zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj -o zephyr/zephyr.elf zephyr/CMakeFiles/offsets.dir/./arch/riscv/core/offsets/offsets.c.obj -Wl,-T zephyr/linker.cmd -Wl,-Map=/workdir/zephyr/build/zephyr/zephyr_final.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/riscv/core/libarch__riscv__core.a zephyr/lib/libc/picolibc/liblib__libc__picolibc.a zephyr/lib/libc/common/liblib__libc__common.a zephyr/drivers/interrupt_controller/libdrivers__interrupt_controller.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/timer/libdrivers__timer.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a -L/workdir/zephyr/build/zephyr -Wl,--print-memory-usage zephyr/arch/common/libisr_tables.a --config=/workdir/zephyr/cmake/toolchain/llvm/clang_compiler_rt.cfg -fuse-ld=lld -mabi=ilp32 -march=rv32imac_zicsr_zifencei -mcmodel=medlow -Wl,--gc-sections -flto -Wl,--build-id=none -Wl,--relax-gp -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N -Wl,--orphan-handling=warn -Wl,--no-pie -L/w
orkdir/llvm/build/lib/clang/22/lib/riscv32-unknown-unknown-elf /workdir/zephyr/build/modules/picolibc/libc.a -lclang_rt.builtins -Wl,--relax-tbljal
ld.lld: warning: <internal>:(.riscv.jvt) is being placed in '.riscv.jvt'
ld.lld: warning: Code size reduction: 0
Memory region Used Size Region Size %age Used
RAM: 28800 B 256 MB 0.01%
IDT_LIST: 0 GB 4 KB 0.00%
```
It seems with `--gc-sections` we get a code-size reduction of 0 for some reason.
Without `--gc-sections`
```
ld.lld: warning: zephyr/libzephyr.a(last_section_id.c.obj):(.last_section) is being placed in '.last_section'
ld.lld: warning: <internal>:(.riscv.jvt) is being placed in '.riscv.jvt'
ld.lld: warning: Code size reduction: 44
Memory region Used Size Region Size %age Used
RAM: 57552 B 256 MB 0.02%
IDT_LIST: 0 GB 4 KB 0.00%
user at b7f43aa2a597:/workdir/zephyr/build$ python3
Python 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 44 / 57552
0.0007645259938837921
>>> quit()
```
We get a `44 / 57552 = 0.07%` code-size reduction, which is underwhelming, since removing `--gc-sections` doubled the size of the result :(
https://github.com/llvm/llvm-project/pull/163142
More information about the llvm-commits
mailing list