https://sourceware.org/bugzilla/show_bug.cgi?id=32014
Bug ID: 32014
Summary: RISC-V: -flto causes .riscv.attributes section to
ignore specified extensions
Product: binutils
Version: 2.44 (HEAD)
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: patrick at rivosinc dot com
Target Milestone: ---
Created attachment 15640
--> https://sourceware.org/bugzilla/attachment.cgi?id=15640&action=edit
Temp files/command outputs
func.c:
extern short a;
void test() { a = a < 0 ? a : 0; }
driver.c:
short a;
void test();
int main() { test(); }
Commands:
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> -march=rv64g_zbkb -O3 -flto -c func.c -o func.o -v > func-flto-log.txt 2>&1
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> -O3 -flto -c driver.c -o driver.o -v > driver-flto-log.txt 2>&1
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> driver.o func.o -o user-config.out -v -save-temps > flto-together-log.txt
> 2>&1
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-readelf
> -a user-config.out > user-config-dump.txt
...
Tag_RISCV_arch:
"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0"
^ This arch string is missing zbkb.
With func-no-lto.o:
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> -march=rv64g_zbkb -O3 -c func.c -o func-no-lto.o -v > func-no-flto-log.txt
> 2>&1
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> driver.o func-no-lto.o -o user-config-mixed.out -v -save-temps >
> flto-mixed-log.txt 2>&1
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-readelf
> -a user-config-mixed.out > user-config-mixed-dump.txt
...
Tag_RISCV_arch:
"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zbkb1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0"
This can also be shown with extensions that modify generated code (eg.
xtheadbb) but I thought it'd be better to use an example without vendor
extensions.
>From poking around the lto/non-lto'd object files there isn't anything
immediately obvious that's causing this issue. func.o and func-no-lto.o both
have the correct .riscv.attribute ISA string.
AFAICT the only difference between the verbose gcc logs are which files get
passed into lto-wrapper.
Tested using binutils a606ff9b090, GCC tip-of-tree (a3f03891065).
--
You are receiving this mail because:
You are on the CC list for the bug.