public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/104707] New: gcc on riscv64 isn't passing entire library path to the linker
@ 2022-02-27  5:34 sterprim at outlook dot com
  2022-02-27  5:41 ` [Bug target/104707] " pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: sterprim at outlook dot com @ 2022-02-27  5:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104707
           Summary: gcc on riscv64 isn't passing entire library path to
                    the linker
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sterprim at outlook dot com
  Target Milestone: ---

I tried to build mold linker (v1.1) for Arch Linux RISC-V, but gcc (11.2.0,
riscv64) filters out essential library paths (/lib and /usr/lib) and mold does
not have the notion of "default search paths" by design. Therefore, mold would
complain something like "mold: library not found: gcc_s" if extra
"-Wl,-L/lib,-L/usr/lib" is not added. Similarly lld fails to work with gcc,
complaining "library not found". But I found that bfd works well with gcc.

Output from gcc when compiling c source files:

$ echo 'int main() { return 0; }' > b.c
$ mold -run gcc -o exe b.c --verbose
  ......
GNU C17 (GCC) version 11.2.0 (riscv64-unknown-linux-gnu)
        compiled by GNU C version 11.2.0, GMP version 6.2.1, MPFR version
4.1.0-p13, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 30030405e2f045a69ffd93f3ffd2fa18
COLLECT_GCC_OPTIONS='-o' 'exe' '-v' '-march=rv64imafdc' '-mabi=lp64d'
'-march=rv64imafdc' '-dumpdir' 'exe-'
 as -v --traditional-format -fpic -march=rv64imafdc -march=rv64imafdc
-mabi=lp64d -o /tmp/ccB31rEk.o /tmp/ccTd7vTJ.s
GNU assembler version 2.38 (riscv64-unknown-linux-gnu) using BFD version (GNU
Binutils) 2.38
COMPILER_PATH=/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/:/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/:/usr/lib/gcc/riscv64-unknown-linux-gnu/:/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/:/usr/lib/gcc/riscv64-unknown-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'exe' '-v' '-march=rv64imafdc' '-mabi=lp64d'
'-march=rv64imafdc' '-dumpdir' 'exe.'
 /usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/collect2 -plugin
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccD5XkR9.res -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id
--eh-frame-hdr --hash-style=gnu -melf64lriscv -dynamic-linker
/lib/ld-linux-riscv64-lp64d.so.1 -pie -o exe /lib/Scrt1.o
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/crti.o
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/crtbeginS.o
-L/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0 /tmp/ccB31rEk.o -lgcc
--push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed
-lgcc_s --pop-state /usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/crtendS.o
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/crtn.o
mold: library not found: gcc_s

Another test, but with -L/lib and -L/usr/lib added:

$ mold -run gcc -o exe b.c --verbose -Wl,-L/lib,-L/usr/lib
  ......
GNU C17 (GCC) version 11.2.0 (riscv64-unknown-linux-gnu)
        compiled by GNU C version 11.2.0, GMP version 6.2.1, MPFR version
4.1.0-p13, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 30030405e2f045a69ffd93f3ffd2fa18
COLLECT_GCC_OPTIONS='-o' 'exe' '-v' '-march=rv64imafdc' '-mabi=lp64d'
'-march=rv64imafdc' '-dumpdir' 'exe-'
 as -v --traditional-format -fpic -march=rv64imafdc -march=rv64imafdc
-mabi=lp64d -o /tmp/ccwQuF3N.o /tmp/cc4kmqtA.s
GNU assembler version 2.38 (riscv64-unknown-linux-gnu) using BFD version (GNU
Binutils) 2.38
COMPILER_PATH=/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/:/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/:/usr/lib/gcc/riscv64-unknown-linux-gnu/:/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/:/usr/lib/gcc/riscv64-unknown-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'exe' '-v' '-march=rv64imafdc' '-mabi=lp64d'
'-march=rv64imafdc' '-dumpdir' 'exe.'
 /usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/collect2 -plugin
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccyg2R0b.res -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id
--eh-frame-hdr --hash-style=gnu -melf64lriscv -dynamic-linker
/lib/ld-linux-riscv64-lp64d.so.1 -pie -o exe /lib/Scrt1.o
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/crti.o
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/crtbeginS.o
-L/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0 /tmp/ccwQuF3N.o -L/lib
-L/usr/lib -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc
--push-state --as-needed -lgcc_s --pop-state
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/crtendS.o
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/crtn.o
COLLECT_GCC_OPTIONS='-o' 'exe' '-v' '-march=rv64imafdc' '-mabi=lp64d'
'-march=rv64imafdc' '-dumpdir' 'exe.'

Log above shows that "/lib/:/usr/lib/" in LIBRARY_PATH seem to be filtered out
by default, but bfd has its own workaround for this issue. This situation
doesn't happen on x86-64 machines.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-04-16 19:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-27  5:34 [Bug target/104707] New: gcc on riscv64 isn't passing entire library path to the linker sterprim at outlook dot com
2022-02-27  5:41 ` [Bug target/104707] " pinskia at gcc dot gnu.org
2022-02-27  8:17 ` pinskia at gcc dot gnu.org
2022-04-19 10:33 ` jpalus+gcc at fastmail dot com
2022-04-19 11:00 ` pinskia at gcc dot gnu.org
2022-04-19 11:36 ` jpalus+gcc at fastmail dot com
2023-04-03  6:32 ` [Bug other/104707] GCC doesn't give default lib path to the linker when multilib is off sterprim at outlook dot com
2023-04-03  6:36 ` pinskia at gcc dot gnu.org
2023-04-03  6:58 ` [Bug driver/104707] " i at rvalue dot moe
2023-04-03  7:01 ` pinskia at gcc dot gnu.org
2024-04-10 11:13 ` pinskia at gcc dot gnu.org
2024-04-16 19:06 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).