Resolve indirect shared library dependencies inside the target SDK
@@ -44,11 +44,14 @@ fn main() {
4444 }
4545 mut args := ['--sysroot=${root}', '-specs=${specs}']
4646 args << target_search_args(root, os.args[1..])
47- // The released AArch64 kernel maps 16 KiB pages. Some cross GCC
48- // distributions select a 4 KiB linker maximum even with a musl sysroot.
49- if os.is_file(os.join_path(root, 'lib/ld-musl-aarch64.so.1'))
50- && !os.args[1..].any(it in ['-c', '-E', '-S', '-M', '-MM', '-fsyntax-only', '-r']) {
51- args << '-Wl,-z,max-page-size=16384'
47+ if !os.args[1..].any(it in ['-c', '-E', '-S', '-M', '-MM', '-fsyntax-only', '-r']) {
48+ // The build machine's linker also needs to find DT_NEEDED libraries
49+ // named by input shared objects. Keep this path out of the target ELF.
50+ args << ['-Xlinker', '-rpath-link', '-Xlinker', '${root}/usr/lib:${root}/lib']
51+ // The released AArch64 kernel maps 16 KiB pages.
52+ if os.is_file(os.join_path(root, 'lib/ld-musl-aarch64.so.1')) {
53+ args << '-Wl,-z,max-page-size=16384'
54+ }
5255 }
5356 os.execvp(compiler, args) or {
5457 eprintln('${driver}: ${compiler}: ${err}')