Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 01 Sep 2020 11:16:21 +0000
From:      bugzilla-noreply@freebsd.org
To:        ports-bugs@FreeBSD.org
Subject:   [Bug 249049] amd64-binutils: ld.bfd searches amd64 paths when linking i386
Message-ID:  <bug-249049-7788@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D249049

            Bug ID: 249049
           Summary: amd64-binutils: ld.bfd searches amd64 paths when
                    linking i386
           Product: Ports & Packages
           Version: Latest
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: ports-bugs@FreeBSD.org
          Reporter: arichardson@FreeBSD.org

I was trying to run the llvm compiler-rt testsuite and noticed that I was
getting lots of linker failures like this:=20

/usr/local/bin/x86_64-unknown-freebsd12.1-ld.bfd: warning: libelf.so.2, nee=
ded
by /usr/lib32/libexecinfo.so, not found (try using -rpath or -rpath-link)
/usr/local/bin/x86_64-unknown-freebsd12.1-ld.bfd: /usr/lib32/libexecinfo.so:
undefined reference to `gelf_getshdr@R1.0'
/usr/local/bin/x86_64-unknown-freebsd12.1-ld.bfd: /usr/lib32/libexecinfo.so:
undefined reference to `gelf_getsym@R1.0'
/usr/local/bin/x86_64-unknown-freebsd12.1-ld.bfd: /usr/lib32/libexecinfo.so:
undefined reference to `elf_errmsg@R1.0'
/usr/local/bin/x86_64-unknown-freebsd12.1-ld.bfd: /usr/lib32/libexecinfo.so:
undefined reference to `elf_nextscn@R1.0'
/usr/local/bin/x86_64-unknown-freebsd12.1-ld.bfd: /usr/lib32/libexecinfo.so:
undefined reference to `elf_end@R1.0'
/usr/local/bin/x86_64-unknown-freebsd12.1-ld.bfd: /usr/lib32/libexecinfo.so:
undefined reference to `elf_strptr@R1.0'
/usr/local/bin/x86_64-unknown-freebsd12.1-ld.bfd: /usr/lib32/libexecinfo.so:
undefined reference to `elf_begin@R1.0'
/usr/local/bin/x86_64-unknown-freebsd12.1-ld.bfd: /usr/lib32/libexecinfo.so:
undefined reference to `elf_errno@R1.0'
/usr/local/bin/x86_64-unknown-freebsd12.1-ld.bfd: /usr/lib32/libexecinfo.so:
undefined reference to `elf_version@R1.0'
/usr/local/bin/x86_64-unknown-freebsd12.1-ld.bfd: /usr/lib32/libexecinfo.so:
undefined reference to `elf_getdata@R1.0'



Linking with --verbose gives the following interesting output:
attempt to open /usr/lib32/crtn.o succeeded
/usr/lib32/crtn.o
libelf.so.2 needed by /usr/lib32/libexecinfo.so
attempt to open /usr/lib/libelf.so.2 failed
attempt to open /usr/lib/compat/libelf.so.2 failed
attempt to open /usr/local/lib/libelf.so.2 failed
attempt to open /usr/local/lib/compat/pkg/libelf.so.2 failed
attempt to open /usr/local/lib/compat/libelf.so.2 failed
attempt to open /usr/local/lib/gcc9/libelf.so.2 failed
attempt to open /usr/local/lib/perl5/5.28/mach/CORE/libelf.so.2 failed
attempt to open /usr/local/lib/perl5/5.32/mach/CORE/libelf.so.2 failed
attempt to open /usr/local/lib/samba4/libelf.so.2 failed
attempt to open /usr/local/llvm-devel/lib/libelf.so.2 failed
attempt to open /usr/local/llvm10/lib/libelf.so.2 failed
attempt to open /usr/local/llvm80/lib/libelf.so.2 failed
attempt to open /usr/local/llvm90/lib/libelf.so.2 failed
attempt to open /usr/local/i386-unknown-freebsd12.1/lib/libelf.so.2 failed
attempt to open /usr/lib/libelf.so.2 failed
attempt to open /usr/local/lib/libelf.so.2 failed
attempt to open /usr/lib/libelf.so.2 failed
attempt to open /usr/lib/compat/libelf.so.2 failed
attempt to open /usr/local/lib/libelf.so.2 failed
attempt to open /usr/local/lib/compat/pkg/libelf.so.2 failed
attempt to open /usr/local/lib/compat/libelf.so.2 failed
attempt to open /usr/local/lib/gcc9/libelf.so.2 failed
attempt to open /usr/local/lib/perl5/5.28/mach/CORE/libelf.so.2 failed
attempt to open /usr/local/lib/perl5/5.32/mach/CORE/libelf.so.2 failed
attempt to open /usr/local/lib/samba4/libelf.so.2 failed
attempt to open /usr/local/llvm-devel/lib/libelf.so.2 failed
attempt to open /usr/local/llvm10/lib/libelf.so.2 failed
attempt to open /usr/local/llvm80/lib/libelf.so.2 failed
attempt to open /usr/local/llvm90/lib/libelf.so.2 failed
attempt to open /usr/local/i386-unknown-freebsd12.1/lib/libelf.so.2 failed
attempt to open /usr/lib/libelf.so.2 failed
attempt to open /usr/local/lib/libelf.so.2 failed

Running ktrace+kdump showed me that ld.bfd was reading /var/run/ld-elf.so.h=
ints
instead of /var/run/ld-elf32.so.hints when resolving DT_NEEDED entries, whi=
ch
explains this rather odd path list that does not include the -L directories.
Adding -lelf works around this linker error but is IMO not the correct fix
since it also affects all other implicit dependencies.

BFD should be reading /var/run/ld-elf32.so.hints for i386 targets on amd64
and/or also looking in the SEARCH_DIR() entries.

Example command:
/home/alr48/obj/build/upstream-llvm-project-build/./bin/clang
-gline-tables-only -fsanitize=3Dundefined -m32
/exports/users/alr48/sources/upstream-llvm-project/compiler-rt/test/sanitiz=
er_common/TestCases/wcrtomb.c
-o
/home/alr48/obj/build/upstream-llvm-project-build/projects/compiler-rt/test=
/sanitizer_common/ubsan-i386-FreeBSD/Output/wcrtomb.c.tmp
-v

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-249049-7788>