From 5fb96d9d8adb3f5d13d2d7ea5b6c9ee9c7a1cdab Mon Sep 17 00:00:00 2001 From: Michael Cho Date: Wed, 3 Sep 2025 20:21:59 -0400 Subject: [PATCH] shims/super/cc: rpath-link `glibc` if indirect dep This helps ld.bfd find the correct `glibc` dependency. Needed when using host toolchain which will only search for /etc/ld.so.conf. Also can help unsupported systems that force poured non-relocatable `binutils` bottle. --- Library/Homebrew/shims/super/cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/shims/super/cc b/Library/Homebrew/shims/super/cc index 5ac3ad1981..b5424f4d22 100755 --- a/Library/Homebrew/shims/super/cc +++ b/Library/Homebrew/shims/super/cc @@ -369,9 +369,13 @@ class Cmd end args += rpath_flags("#{wl}-rpath=", rpath_paths) args += ["#{wl}--dynamic-linker=#{dynamic_linker_path}"] if dynamic_linker_path - # Use -rpath-link to make sure linker uses versioned glibc rather than the system glibc for indirect + # Use -rpath-link to make sure linker uses brew glibc rather than the system glibc for indirect # dependencies because -L will only handle direct dependencies. - args << "#{wl}-rpath-link=#{@opt}/#{versioned_glibc_dep}/lib" if versioned_glibc_dep + if versioned_glibc_dep + args << "#{wl}-rpath-link=#{@opt}/#{versioned_glibc_dep}/lib" + else + args << "#{wl}-rpath-link=#{@opt}/glibc/lib" + end args end