This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug lto/86490] lto1: fatal error: multiple prevailing defs


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86490

--- Comment #9 from zenith432 at users dot sourceforge.net ---
It is worth studying what gold is doing, because it's not just skipping the
object files in the archives.

If you link with
gcc -flto -save-temps -fuse-ld=gold -o x main.o libfoo.a libbar.a

The res file shows resolutions only for main.o.

Now link with
gcc -flto -save-temps -fuse-ld=gold -u bar -o x main.o libfoo.a libbar.a

The res file shows resolutions for main.o and exactly one of libfoo.a or
libbar.a.

Now add definitions as follows
void f1() {} to foo.c
void f2() {} to bar.c
so you can tell them apart.

Now link with
gcc -flto -save-temps -fuse-ld=gold -u f1 -o x main.o libfoo.a libbar.a
gcc -flto -save-temps -fuse-ld=gold -u f2 -o x main.o libfoo.a libbar.a

each time, the resolution file shows gold resolving just one of the .a files
which was requested with the -u.

Now link with
gcc -flto -save-temps -fuse-ld=gold -u f1 -u f2 -o x main.o libfoo.a libbar.a
to link all in.
This does give an error, but it's a gold error for multiple defs, not an lto1
error for multiple prevailing defs.  Look at the res file you'll see
resolutions for all three input files, but there is just one prevailing def for
symbol bar - the other instance of bar gets resolution PREEMPTED_IR.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]