https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95677
Bug ID: 95677 Summary: undefined reference to `(anonymous namespace)::xx' Product: gcc Version: lto Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: sujian.liu at huawei dot com CC: marxin at gcc dot gnu.org Target Milestone: --- Created attachment 48731 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48731&action=edit dejagnu/testsuite-7.3/g++.old-deja/g++.ns/extern1.C When compile with lto,it will be reported the following error: ./riscv32-unknown-elf-gcc dejagnu/testsuite-7.3/g++.old-deja/g++.ns/extern1.C -o extern1.exe -flto /home/lsj/gits/gcc_10_1_0/build/hcc_riscv32/riscv32_elf_build_dir/hcc_riscv32/bin/../lib/gcc/riscv32-unknown-elf/10.1.0/../../../../riscv32-unknown-elf/bin/ld: /tmp/extern1.exe.m1gfd6.ltrans0.ltrans.o: in function `.L0 ': <artificial>:(.text+0x6): undefined reference to `(anonymous namespace)::xx' /home/lsj/gits/gcc_10_1_0/build/hcc_riscv32/riscv32_elf_build_dir/hcc_riscv32/bin/../lib/gcc/riscv32-unknown-elf/10.1.0/../../../../riscv32-unknown-elf/bin/ld: <artificial>:(.text+0xa): undefined reference to `(anonymous namespace)::xx' collect2: error: ld returned 1 exit status It seems that lto can't deal with the extern variable in the namespace. The testcase which is one of deja in testsuite-7.3 will be attached.