Skip to content

Commit 2b8b778

Browse files
committed
WIP
1 parent eac5720 commit 2b8b778

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

Library/Homebrew/extend/ENV/super.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ def determine_optflags
306306
odebug "Building a bottle for custom architecture (#{effective_arch})..."
307307
Hardware::CPU.arch_flag(effective_arch)
308308
end
309+
alias generic_determine_optflags determine_optflags
309310

310311
sig { returns(String) }
311312
def determine_cccfg

Library/Homebrew/extend/os/linux/extend/ENV/super.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,29 @@ def homebrew_extra_paths
4545

4646
def homebrew_extra_isystem_paths
4747
paths = []
48-
# Add paths for GCC headers when building against [email protected] because we have to use -nostdinc.
49-
if deps.any? { |d| d.name == "[email protected]" }
48+
# Add paths for GCC headers when building against [email protected] or [email protected]
49+
# because we have to use -nostdinc.
50+
if deps.any? { |d| d.name == "[email protected]" || d.name == "[email protected]" }
5051
gcc_include_dir = Utils.safe_popen_read(cc, "--print-file-name=include").chomp
5152
gcc_include_fixed_dir = Utils.safe_popen_read(cc, "--print-file-name=include-fixed").chomp
5253
paths << gcc_include_dir << gcc_include_fixed_dir
5354
end
5455
paths
5556
end
5657

58+
sig { returns(String) }
59+
def determine_optflags
60+
if effective_arch == :armv8 &&
61+
compiler.match?(GNU_GCC_REGEXP) &&
62+
DevelopmentTools.gcc_version(compiler.to_s) >= "9.3.1"
63+
# Out-of-line atomics are not supported out-of-the-box on all systems.
64+
# https://learn.arm.com/learning-paths/servers-and-cloud-computing/lse/intro/
65+
"#{generic_determine_optflags} -mno-outline-atomics"
66+
else
67+
generic_determine_optflags
68+
end
69+
end
70+
5771
def determine_rpath_paths(formula)
5872
PATH.new(
5973
*formula&.lib,

Library/Homebrew/shims/super/cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ class Cmd
313313
def cppflags
314314
args = []
315315
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?
318319
# Ideally this would be -ffile-prefix-map, but that requires a minimum of GCC 8, LLVM Clang 10 or Apple Clang 12
319320
# and detecting the version dynamically based on what `HOMEBREW_CC` may have been rewritten to point to is awkward
320321
args << "-fdebug-prefix-map=#{formula_buildpath}=." if formula_buildpath && !debug_symbols?
@@ -340,19 +341,20 @@ class Cmd
340341
end
341342

342343
def ldflags_linux(args)
344+
versioned_glibc_dep = (@deps & ["[email protected]", "[email protected]"]).first
343345
unless mode == :ld
344346
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"
347349
else
348350
args << "-B#{@opt}/glibc/lib"
349351
end
350352
end
351353
args += rpath_flags("#{wl}-rpath=", rpath_paths)
352354
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
354356
# 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
356358
args
357359
end
358360

0 commit comments

Comments
 (0)