Default GCC LIBRARY_PATH differs on riscv64
This is a follow up to 04d4e07a (comment 199694)
For utmps, dynamic libraries are placed in /lib (libutmps.so) and static ones are placed in /usr/lib (libutmps.a) (see 085b827f). The underlying assumption being that /usr/lib is searched before /lib.
While this is the case on x86_64:
$ gcc -v hello_world.c -Wl,--no-as-needed -lutmps -lskarnet 2>&1 | grep '^LIBRARY_PATH='
LIBRARY_PATH=/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/:/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/lib/../lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../:/lib/:/usr/lib/
This assumption does not hold on riscv64:
$ gcc -v hello_world.c -Wl,--no-as-needed -lutmps -lskarnet 2>&1 | grep '^LIBRARY_PATH='
LIBRARY_PATH=/usr/lib/gcc/riscv64-alpine-linux-musl/11.2.1/:/usr/lib/gcc/riscv64-alpine-linux-musl/11.2.1/../../../../riscv64-alpine-linux-musl/lib/:/lib/:/usr/lib/
On riscv64, a path analog to /usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../lib/
(which expands to /usr/lib) is missing in the library search path. While debugging this I also noticed that gcc -print-multi-os-directory
prints .
on riscv64, on all other architectures we support it prints ../lib
which lead me to investigate the GCC configuration file for riscv64. This file seems to assume that lib32/lib64 exist which we don't have on Alpine, this is contrary to other GCC architecture configuration files. Furthermore, I noticed that riscv64 is missing in our 0024-use-pure-64-bit-configuration-where-appropriate.patch
GCC patch. Maybe this is why a directory analog to /usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../lib/
is missing in the default library search path on riscv64?
Potentially related: