diff --git a/Formula/l/llvm.rb b/Formula/l/llvm.rb index 5fa8ca9e552ef..3ad540c614b14 100644 --- a/Formula/l/llvm.rb +++ b/Formula/l/llvm.rb @@ -490,7 +490,10 @@ def write_config_files(macos_version, kernel_version, arch) arches = Set.new([:arm64, :x86_64, :aarch64]) arches << arch - sysroot = if macos_version >= "10.14" || (macos_version.blank? && kernel_version.blank?) + + sysroot = if macos_version.blank? || (MacOS.version > macos_version && MacOS::CLT.separate_header_package?) + "#{MacOS::CLT::PKG_PATH}/SDKs/MacOSX.sdk" + elsif macos_version >= "10.14" "#{MacOS::CLT::PKG_PATH}/SDKs/MacOSX#{macos_version}.sdk" else "/" @@ -627,15 +630,24 @@ def caveats system bin/"clang", "-v", "test.c", "-o", "testCLT" assert_equal "Hello World!", shell_output("./testCLT").chomp - target = "#{Hardware::CPU.arch}-apple-macosx#{MacOS.full_version}" - system bin/"clang-cpp", "-v", "--target=#{target}", "test.c" - system bin/"clang-cpp", "-v", "--target=#{target}", "test.cpp" - - system bin/"clang", "-v", "--target=#{target}", "test.c", "-o", "test-macosx" - assert_equal "Hello World!", shell_output("./test-macosx").chomp - - system bin/"clang++", "-v", "--target=#{target}", "-std=c++11", "test.cpp", "-o", "test++-macosx" - assert_equal "Hello World!", shell_output("./test++-macosx").chomp + old_macos_version = HOMEBREW_MACOS_OLDEST_SUPPORTED.to_i - 1 + old_kernel_version = MacOSVersion.kernel_major_version(MacOSVersion.new(old_macos_version.to_s)) + [ + "#{Hardware::CPU.arch}-apple-macosx#{MacOS.full_version}", + "#{Hardware::CPU.arch}-apple-macosx#{old_macos_version}", + "#{Hardware::CPU.arch}-apple-macosx", + "#{Hardware::CPU.arch}-apple-darwin#{old_kernel_version}", + "#{Hardware::CPU.arch}-apple-darwin", + ].each do |target| + system bin/"clang-cpp", "-v", "--target=#{target}", "test.c" + system bin/"clang-cpp", "-v", "--target=#{target}", "test.cpp" + + system bin/"clang", "-v", "--target=#{target}", "test.c", "-o", "test-macosx" + assert_equal "Hello World!", shell_output("./test-macosx").chomp + + system bin/"clang++", "-v", "--target=#{target}", "-std=c++11", "test.cpp", "-o", "test++-macosx" + assert_equal "Hello World!", shell_output("./test++-macosx").chomp + end end # Testing Xcode