https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107251
Bug ID: 107251 Summary: RISC-V linux kernel compiled with -mno-relax generates a lot of local symbols Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: xnox at ubuntu dot com Target Milestone: --- Previous reported at https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1036 $ du -h btrfs.ko.* 76M btrfs.ko.riscv64 42M btrfs.ko.x86_64 $ strip --strip-debug btrfs.ko.x86_64 $ riscv64-linux-gnu-strip --strip-debug btrfs.ko.riscv64 $ du -h btrfs.ko.* 17M btrfs.ko.riscv64 2.8M btrfs.ko.x86_64 $ strip --strip-debug --discard-locals btrfs.ko.x86_64 $ riscv64-linux-gnu-strip --strip-debug --discard-locals btrfs.ko.riscv64 $ du -h btrfs.ko.* 4.2M btrfs.ko.riscv64 2.8M btrfs.ko.x86_64 The above demonstrates that RISCV kernel modules are compiled with -mno-relax option, and yet a lot of relocation symbols are emitted and remain in the modules keeping their size very large. Over on github issue it was mentioned that "There is a known problem with GNU as that we still emit extra symbols and relocations when -mno-relax is used. Kernel modules are compiled -mno-relax. So fixing this would help reduce the symtab size." However I was unable to find a bug report pointing this out. Could you please ensure that when compiling code, the extra symbols and relocations are not emitted, or otherwise stripped? Such that calling --discard-locals would have no particular effect on the binary sizes. It is inconvenient for distributions to call --discard-locals on riscv, even when otherwise one is keeping the rest of the debug symbols for example. I have observed this with gcc-10 and upwords, and most recently with gcc-12. I can try newer builds of gcc and/or any patches to confirm behaviour.