Skip to content

Commit c95476d

Browse files
committed
Fix spurious "dupilcate symbol" error for LTO
Fixes #1421
1 parent 3981f4f commit c95476d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/passes.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,9 @@ void check_duplicate_symbols(Context<E> &ctx) {
10361036
Timer t(ctx, "check_duplicate_symbols");
10371037

10381038
tbb::parallel_for_each(ctx.objs, [&](ObjectFile<E> *file) {
1039+
if (!file->is_reachable)
1040+
return;
1041+
10391042
for (i64 i = file->first_global; i < file->elf_syms.size(); i++) {
10401043
const ElfSym<E> &esym = file->elf_syms[i];
10411044
Symbol<E> &sym = *file->symbols[i];

test/lto-archive3.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
. $(dirname $0)/common.inc
3+
4+
test_cflags -flto=auto || skip
5+
6+
cat <<EOF | $CC -o $t/a.o -c -xc - -flto
7+
void foo() {}
8+
EOF
9+
10+
rm -f $t/b.a
11+
ar rc $t/b.a $t/a.o
12+
ar rc $t/c.a $t/a.o
13+
14+
cat <<EOF | $CC -o $t/c.o -c -xc -
15+
void foo();
16+
int main() { foo(); }
17+
EOF
18+
19+
$CC -B. -o $t/exe -flto $t/c.o $t/b.a $t/c.a

0 commit comments

Comments
 (0)