@@ -313,8 +313,9 @@ class Cmd
313
313
def cppflags
314
314
args = [ ]
315
315
args += path_flags ( "-isystem" , isystem_paths ) + path_flags ( "-I" , include_paths )
316
- # Add -nostdinc when building against [email protected] to avoid mixing system and brewed glibc headers.
317
- args <<
"-nostdinc" if @deps . include? ( "[email protected] " )
316
+ # Add -nostdinc when building against [email protected] or [email protected] to avoid
317
+ # mixing system and brewed glibc headers.
318
+ args <<
"-nostdinc" if ( @deps &
[ "[email protected] " , "[email protected] " ] ) . any?
318
319
# Ideally this would be -ffile-prefix-map, but that requires a minimum of GCC 8, LLVM Clang 10 or Apple Clang 12
319
320
# and detecting the version dynamically based on what `HOMEBREW_CC` may have been rewritten to point to is awkward
320
321
args << "-fdebug-prefix-map=#{ formula_buildpath } =." if formula_buildpath && !debug_symbols?
@@ -340,19 +341,20 @@ class Cmd
340
341
end
341
342
342
343
def ldflags_linux ( args )
344
+ versioned_glibc_dep = ( @deps &
[ "[email protected] " , "[email protected] " ] ) . first
343
345
unless mode == :ld
344
346
wl = "-Wl,"
345
- if @deps . include? ( "[email protected] " )
346
- args <<
"-B#{ @opt } /[email protected] /lib"
347
+ if versioned_glibc_dep
348
+ args << "-B#{ @opt } /#{ versioned_glibc_dep } /lib"
347
349
else
348
350
args << "-B#{ @opt } /glibc/lib"
349
351
end
350
352
end
351
353
args += rpath_flags ( "#{ wl } -rpath=" , rpath_paths )
352
354
args += [ "#{ wl } --dynamic-linker=#{ dynamic_linker_path } " ] if dynamic_linker_path
353
- # Use -rpath-link to make sure linker uses [email protected] rather than the system glibc for indirect
355
+ # Use -rpath-link to make sure linker uses [email protected] or [email protected] rather than the system glibc for indirect
354
356
# dependencies because -L will only handle direct dependencies.
355
- args <<
"#{ wl } -rpath-link=#{ @opt } /[email protected] /lib" if @deps . include? ( "[email protected] " )
357
+ args << "#{ wl } -rpath-link=#{ @opt } /#{ versioned_glibc_dep } /lib" if versioned_glibc_dep
356
358
args
357
359
end
358
360
0 commit comments