Skip to content

Commit f0a18e6

Browse files
authored
Merge pull request Homebrew#200466 from Homebrew/llvm-older-macos-targets
llvm: fix targeting macOS versions older than the host
2 parents 8b4e11b + 53b20ed commit f0a18e6

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

Formula/l/llvm.rb

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ class Llvm < Formula
2424
end
2525

2626
bottle do
27-
sha256 cellar: :any, arm64_sequoia: "b6493a9057ae767e2aed3ca28415d63cdf434fbf50b1bab8b2288a8fb60ef3c8"
28-
sha256 cellar: :any, arm64_sonoma: "3f5f4564695b9d08b461099a2674eff8b652a943ac838c550b2b3760b916160a"
29-
sha256 cellar: :any, arm64_ventura: "49b60f0530b3d1bc89fa9e4e9de55bdfb35352730890a7fa010383b81bb562b3"
30-
sha256 cellar: :any, sonoma: "15f82c8945c3c5c3b81a7e406307b4e0f5f5edba9da8e57dfcd7c185df795305"
31-
sha256 cellar: :any, ventura: "fcb8d13ba1327569b3a2cfa09a0ea36be2e58503794e42c02186f9d7c87479b4"
32-
sha256 cellar: :any_skip_relocation, x86_64_linux: "9100176d57b910eb87519ba93f8b53d43c222e374b09904abad951a79f3d632d"
27+
rebuild 1
28+
sha256 cellar: :any, arm64_sequoia: "8922c8ee7cb8ad40950327aadbbe0f73c72f91b1690002b8d8d349019d73bef3"
29+
sha256 cellar: :any, arm64_sonoma: "3e45f7c54792dfce7e47387937cb973d497d381c9b4f5765034c3e440b4ef83d"
30+
sha256 cellar: :any, arm64_ventura: "de490ed1fe6c7693baf9e97a8c1678e349d33c537ad4f85f458f125820bc5595"
31+
sha256 cellar: :any, sonoma: "9c714daaab17eae75a56f368621e388505b8bc7db060377698fde250f9706045"
32+
sha256 cellar: :any, ventura: "c0ff84dff6908a6460539f688b1b4f9dde6f1135a3a4302b71bc02de5b3c104d"
33+
sha256 cellar: :any_skip_relocation, x86_64_linux: "eb3c118c29a7e6d8b2527b11529c7c2d340cec6afd4c58513973463e9e9fe458"
3334
end
3435

3536
keg_only :provided_by_macos
@@ -490,7 +491,10 @@ def write_config_files(macos_version, kernel_version, arch)
490491

491492
arches = Set.new([:arm64, :x86_64, :aarch64])
492493
arches << arch
493-
sysroot = if macos_version >= "10.14" || (macos_version.blank? && kernel_version.blank?)
494+
495+
sysroot = if macos_version.blank? || (MacOS.version > macos_version && MacOS::CLT.separate_header_package?)
496+
"#{MacOS::CLT::PKG_PATH}/SDKs/MacOSX.sdk"
497+
elsif macos_version >= "10.14"
494498
"#{MacOS::CLT::PKG_PATH}/SDKs/MacOSX#{macos_version}.sdk"
495499
else
496500
"/"
@@ -627,15 +631,27 @@ def caveats
627631
system bin/"clang", "-v", "test.c", "-o", "testCLT"
628632
assert_equal "Hello World!", shell_output("./testCLT").chomp
629633

630-
target = "#{Hardware::CPU.arch}-apple-macosx#{MacOS.full_version}"
631-
system bin/"clang-cpp", "-v", "--target=#{target}", "test.c"
632-
system bin/"clang-cpp", "-v", "--target=#{target}", "test.cpp"
634+
targets = ["#{Hardware::CPU.arch}-apple-macosx#{MacOS.full_version}"]
635+
636+
# The test tends to time out on Intel, so let's do these only for ARM macOS.
637+
if Hardware::CPU.arm?
638+
old_macos_version = HOMEBREW_MACOS_OLDEST_SUPPORTED.to_i - 1
639+
targets << "#{Hardware::CPU.arch}-apple-macosx#{old_macos_version}"
640+
641+
old_kernel_version = MacOSVersion.kernel_major_version(MacOSVersion.new(old_macos_version.to_s))
642+
targets << "#{Hardware::CPU.arch}-apple-darwin#{old_kernel_version}"
643+
end
644+
645+
targets.each do |target|
646+
system bin/"clang-cpp", "-v", "--target=#{target}", "test.c"
647+
system bin/"clang-cpp", "-v", "--target=#{target}", "test.cpp"
633648

634-
system bin/"clang", "-v", "--target=#{target}", "test.c", "-o", "test-macosx"
635-
assert_equal "Hello World!", shell_output("./test-macosx").chomp
649+
system bin/"clang", "-v", "--target=#{target}", "test.c", "-o", "test-macosx"
650+
assert_equal "Hello World!", shell_output("./test-macosx").chomp
636651

637-
system bin/"clang++", "-v", "--target=#{target}", "-std=c++11", "test.cpp", "-o", "test++-macosx"
638-
assert_equal "Hello World!", shell_output("./test++-macosx").chomp
652+
system bin/"clang++", "-v", "--target=#{target}", "-std=c++11", "test.cpp", "-o", "test++-macosx"
653+
assert_equal "Hello World!", shell_output("./test++-macosx").chomp
654+
end
639655
end
640656

641657
# Testing Xcode

0 commit comments

Comments
 (0)