Skip to content

Commit f100cc7

Browse files
authored
Merge pull request Homebrew#195539 from Homebrew/swift-fixes
swift: use Python 3.13, fix Xcode 16 build
2 parents 6de5470 + b036c0c commit f100cc7

File tree

2 files changed

+55
-19
lines changed

2 files changed

+55
-19
lines changed

Formula/s/swift.rb

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ class Swift < Formula
1717
end
1818

1919
bottle do
20-
sha256 cellar: :any, arm64_sonoma: "b2a5609befa41fda88043dfcbe18f28b10f553952c1761c48f958e10a0b0b4cb"
21-
sha256 cellar: :any, arm64_ventura: "f99fe506177136aa446dc20c7cd1a6a464e0a54ac867a12a89e7f2947e7ab552"
22-
sha256 cellar: :any, sonoma: "9d93e35da28ab6f93542a0ea02d7774d3fba94d13860731af55f40c4f435af7c"
23-
sha256 cellar: :any, ventura: "3371b6dd437a89779900003c7a9978c4e5ba76d8e1851844cb465b44813f52f9"
24-
sha256 cellar: :any_skip_relocation, x86_64_linux: "0e0d8a584a6377ddb83b362fbd2932a4a396f6db8dd30ae4bc519bcb9f182c8c"
20+
rebuild 1
21+
sha256 cellar: :any, arm64_sequoia: "a32040d74979d5364c75b8d630d149ee13cee52b24e683b009d0a2d577e1e298"
22+
sha256 cellar: :any, arm64_sonoma: "e7b49374fd31cb7cb7088b3e9d25a136dd4937c0522e0d62996284be6acf4e95"
23+
sha256 cellar: :any, arm64_ventura: "086917c9bdbed6e152f67aa8c3cdeaee988fcb95ab93cd43057fac1f7de06f52"
24+
sha256 cellar: :any, sonoma: "64a22002bbe10c05e05a49906eb6866ceb6ee9d049fb2b600b7576c9d6a05f8a"
25+
sha256 cellar: :any, ventura: "77083bae180de55072e3a7d0354af8f56ce9cc1d644879ad7a9817ee975995aa"
26+
sha256 cellar: :any_skip_relocation, x86_64_linux: "92ddf888e22eee066d4335770d89fe96f840cc9de79e15dd614bc455f15d0075"
2527
end
2628

2729
keg_only :provided_by_macos
@@ -35,7 +37,7 @@ class Swift < Formula
3537
# is higher then that is likely why.
3638
depends_on xcode: ["14.3", :build]
3739

38-
depends_on "python@3.12"
40+
depends_on "python@3.13"
3941

4042
# HACK: this should not be a test dependency but is due to a limitation with fails_with
4143
uses_from_macos "llvm" => [:build, :test]
@@ -104,6 +106,20 @@ class Swift < Formula
104106
resource "llvm-project" do
105107
url "https://github.com/swiftlang/llvm-project/archive/refs/tags/swift-6.0.1-RELEASE.tar.gz"
106108
sha256 "8f026177a2378e4fc141e9284a5b4567b92cd50070e29a3eab5cabb8252aa72a"
109+
110+
# Fix copmatibility with macOS 15 SDK.
111+
# Remove with Swift 6.0.3.
112+
patch do
113+
url "https://github.com/swiftlang/llvm-project/commit/a566c12aded130264a1e07e6c1718884ab1d9dc8.patch?full_index=1"
114+
sha256 "6f165b41390051098c0b4ea5bd333c49a7fd93740a015b99db72f096283ae434"
115+
end
116+
117+
# Support Python 3.13.
118+
# Remove with Swift 6.1.
119+
patch do
120+
url "https://github.com/swiftlang/llvm-project/commit/b202bacbaf2be144dfd51d083eb2e4fe687a3803.patch?full_index=1"
121+
sha256 "a7368e3b91a3dc4ebfd78f61e865a621eee37c176ac88bea68f1327151e695cc"
122+
end
107123
end
108124

109125
resource "cmark" do
@@ -270,6 +286,13 @@ class Swift < Formula
270286
sha256 "9ab1f0e347fad651ed5ccadc13d54c4306e6f5cd21908a4ba7d1334278a4cd55"
271287
end
272288

289+
# Fix build with Xcode 16.
290+
# Remove with Swift 6.1 (or earlier if it gets cherry-picked).
291+
patch do
292+
url "https://github.com/swiftlang/swift/commit/c8d7e94fdd2c8ceb276a6dc363861872f13104ba.patch?full_index=1"
293+
sha256 "aa012b9522ddbe92da9ab6a491dd43097b723e7807e813c57edd458f4baf3b12"
294+
end
295+
273296
# Homebrew-specific patch to make the default resource directory use opt rather than Cellar.
274297
# This fixes output binaries from `swiftc` having a runpath pointing to the Cellar.
275298
# This should only be removed if an alternative solution is implemented.
@@ -387,7 +410,7 @@ def install
387410
--swift-include-tests=0
388411
--llvm-include-tests=0
389412
--lldb-configure-tests=0
390-
--lldb-extra-cmake-args=-DPython3_EXECUTABLE=#{which("python3.12")}
413+
--lldb-extra-cmake-args=-DPython3_EXECUTABLE=#{which("python3.13")}
391414
--skip-build-benchmarks
392415
--build-swift-private-stdlib=0
393416
--install-swift
@@ -406,6 +429,8 @@ def install
406429
--install-swift-testing-macros
407430
]
408431

432+
extra_cmake_options << "-DSWIFT_INCLUDE_TEST_BINARIES=OFF"
433+
409434
if OS.mac?
410435
args += %W[
411436
--host-target=macosx-#{Hardware::CPU.arch}
@@ -417,10 +442,12 @@ def install
417442
args << "--swift-enable-backtracing=0" if MacOS.version < :sonoma
418443
extra_cmake_options += %W[
419444
-DSWIFT_STANDARD_LIBRARY_SWIFT_FLAGS=-disable-sandbox
420-
-DSWIFT_INCLUDE_TEST_BINARIES=OFF
421445
-DLLDB_FRAMEWORK_COPY_SWIFT_RESOURCES=OFF
422-
-DCMAKE_INSTALL_RPATH=#{loader_path}
446+
-DSWIFT_HOST_LIBRARIES_RPATH=#{loader_path}
423447
]
448+
449+
ENV.remove "HOMEBREW_LIBRARY_PATHS", Formula["sqlite"].opt_lib
450+
ENV.remove "PKG_CONFIG_PATH", Formula["sqlite"].opt_lib/"pkgconfig"
424451
end
425452
if OS.linux?
426453
args += %W[
@@ -437,6 +464,8 @@ def install
437464
--install-libdispatch
438465
--install-xctest
439466
]
467+
468+
# For XCTest (https://github.com/swiftlang/swift-corelibs-xctest/issues/432) and sourcekitd-repl
440469
rpaths = [loader_path, rpath, rpath(target: lib/"swift/linux")]
441470
extra_cmake_options << "-DCMAKE_INSTALL_RPATH=#{rpaths.join(":")}"
442471

@@ -520,8 +549,8 @@ def caveats
520549

521550
# Test compiler
522551
system bin/"swiftc", "-module-cache-path", module_cache, "-v", "foundation-test.swift", "-o", "foundation-test"
523-
output = shell_output("./foundation-test")
524-
assert_match "www.swift.org\n", output
552+
output = shell_output("./foundation-test 2>&1") # check stderr too for dyld errors
553+
assert_equal "www.swift.org\n", output
525554

526555
# Test Swift Package Manager
527556
ENV["SWIFTPM_MODULECACHE_OVERRIDE"] = module_cache

Formula/s/swiftlint.rb

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,32 @@ class Swiftlint < Formula
55
tag: "0.57.0",
66
revision: "168fb98ed1f3e343d703ecceaf518b6cf565207b"
77
license "MIT"
8+
revision 1
89
head "https://github.com/realm/SwiftLint.git", branch: "main"
910

1011
bottle do
11-
sha256 cellar: :any_skip_relocation, arm64_sequoia: "fd8609da0dbf8e9396f9f5697b2650c35217f6d5443310ab8b3aeb095cadc32e"
12-
sha256 cellar: :any_skip_relocation, arm64_sonoma: "cb14bb58a7fa8e390030b9890378c097385ac0d6bd50b1003946d24feb230b72"
13-
sha256 cellar: :any_skip_relocation, arm64_ventura: "52e8789623ac1ec907079762083591e1f21d90ff751da9754b3db52badfe94bc"
14-
sha256 cellar: :any_skip_relocation, sonoma: "30e8f88c492f67ce3d08181044c5849f1b9075ad00aac615551a42aa253cbed9"
15-
sha256 cellar: :any_skip_relocation, ventura: "fe9e50ce478538598d5e85875ea9c0a1d61c24d83352362de02141f1467b5262"
16-
sha256 x86_64_linux: "dec908e0f1cd2b332bcf678edc36e10f7030cfc9414e733629e763283b0ada40"
12+
sha256 cellar: :any_skip_relocation, arm64_sequoia: "29bfd9c9a44b1bdaf6656571d40192c570d6afefbce48a90a923cae6d52875b4"
13+
sha256 cellar: :any_skip_relocation, arm64_sonoma: "c1862b912a0e6d3574761ee710cca00a53e831d92e080f448b8fe286cccc4ab8"
14+
sha256 cellar: :any, arm64_ventura: "08c334c98bbfaa64ee5cda057cb634981e9409249f493b5d40abf02b2cc24f3b"
15+
sha256 cellar: :any_skip_relocation, sonoma: "f46a96f444a1ce89c53a183e5e95d26201276474eff7cb82dd30c3103ae2b11d"
16+
sha256 cellar: :any, ventura: "35fdde7dc00368c3d65f03dc4290190351af844b4296f2e9cc9bfdbcf6bcce2f"
17+
sha256 cellar: :any_skip_relocation, x86_64_linux: "7aa5ef711b796a028a2f1d0b6d3b2d742f33b25738a13ebd884962f5b883abf6"
1718
end
1819

1920
depends_on macos: :ventura
2021
depends_on xcode: "8.0"
2122

2223
uses_from_macos "swift" => :build, since: :sonoma # swift 5.10+
23-
uses_from_macos "swift"
24+
uses_from_macos "curl"
25+
uses_from_macos "libxml2"
2426

2527
def install
26-
system "swift", "build", "--disable-sandbox", "--configuration", "release", "--product", "swiftlint"
28+
args = if OS.mac?
29+
["--disable-sandbox"]
30+
else
31+
["--static-swift-stdlib"]
32+
end
33+
system "swift", "build", *args, "--configuration", "release", "--product", "swiftlint"
2734
bin.install ".build/release/swiftlint"
2835
generate_completions_from_executable(bin/"swiftlint", "--generate-completion-script")
2936
end

0 commit comments

Comments
 (0)