Skip to content

Conversation

@stuartcarnie
Copy link
Contributor

This PR:

  • Updates to the latest Xcode version
  • Installs the swift 6.2 toolchain for macOS and Apple embedded containers
  • Updates to llvm 21

iOS Build Status

  • ✅ iOS successfully builds with Swift source additions

visionOS Build Status

When the swift compiler attempts to compile modules that have the same availability checks as is mentioned in swiftlang/llvm-project/issues/10782, it fails due to the bug in llvm

In order to resolve this, the Swift 6.2 toolchain will need to be compiled with the same patched llvm-project toolchain.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good! I haven't had time to test yet.

echo "=== Copying SDK using tar to preserve special files ==="
cd "$sdk_dir"
tar -cf - "$sdk_name" | (cd "/tmp" && tar -xf -)
tar -cf - "$sdk_name" | tar -xf - -C /tmp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a pre-existing issue, but we should make use mktemp -d instead of just unarchiving in /tmp.

@akien-mga
Copy link
Member

If I understand correctly we'll need this to be able to build iOS templates for 4.6-dev2, so this can likely be merged as is and improved in a follow-up PR. I won't be around next week to work on this.

Comment on lines 13 to 15
ENV OSX_SDKV=
ENV IOS_SDKV=
ENV TVOS_SDKV=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these can be removed.


ENV XCODE_SDKV=26.0.1
ENV APPLE_SDKV=26.0
ENV OSX_SDK=26.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be removed and replaced by APPLE_SDKV below.

@stuartcarnie
Copy link
Contributor Author

I will verify it works from a .xip; I manually extracted Xcode and referenced that, so perhaps there is an issue with that step?

@stuartcarnie
Copy link
Contributor Author

@akien-mga I've pushed up a separate Dockerfile.swift for you to test, that just runs the Swift steps. Can you try that and see what happens, after you have downloaded and prepared the Xcode SDK

img_version=4.6-f42 podman build --build-arg img_version=${img_version} -v $(realpath files):/root/files:z -t godot-swift:${img_version} -f Dockerfile.swift .

Here is the tail of my output from that command:

99%: Downloaded 940.6 MiB of 942.5 MiB
100%: Downloaded 942.5 MiB of 942.5 MiB
Verifying toolchain signature...
Extracting toolchain...
The global default toolchain has been set to `Swift 6.2.0`
Swift 6.2.0 is installed successfully!
--> 0fe45dffc24f
STEP 9/11: RUN /root/files/swift/create-sdk-bundle.sh /root/Xcode.app/Contents/Developer /root/swift-sdk
Creating artifact bundle at /root/swift-sdk/darwin.artifactbundle
Found SDKs:
  iOS: iPhoneOS26.0.sdk
  iOS Sim: iPhoneSimulator26.0.sdk
  macOS: MacOSX26.0.sdk
  tvOS: AppleTVOS26.0.sdk
  tvOS Sim: AppleTVSimulator26.0.sdk
  visionOS: XROS26.0.sdk
  visionOS Sim: XRSimulator26.0.sdk
--> 22bc3c3a7536
STEP 10/11: RUN PATH="/root/.local/share/swiftly/bin:${PATH}" swift sdk install /root/swift-sdk/darwin.artifactbundle
Swift SDK bundle at `/root/swift-sdk/darwin.artifactbundle` successfully installed as darwin.artifactbundle.
--> a14b84bea872
STEP 11/11: CMD /bin/bash
COMMIT godot-swift:4.6-f42
--> b0859dcac840
Successfully tagged localhost/godot-swift:4.6-f42
b0859dcac8403825b1061270ea6b61ee7cf4cee9507990c9cbfce9d0f8f25094

@akien-mga
Copy link
Member

akien-mga commented Oct 13, 2025

Same error with the new dockerfile sadly:

99%: Downloaded 945.7 MiB of 954.4 MiB
100%: Downloaded 954.4 MiB of 954.4 MiB
Verifying toolchain signature...
Extracting toolchain...
The global default toolchain has been set to `Swift 6.2.0`
Swift 6.2.0 is installed successfully!
--> c734eb77d4ca
STEP 9/11: RUN /root/files/swift/create-sdk-bundle.sh /root/Xcode.app/Contents/Developer /root/swift-sdk
Creating artifact bundle at /root/swift-sdk/darwin.artifactbundle
Found SDKs:
  iOS: iPhoneOS26.0.sdk
  iOS Sim: iPhoneSimulator26.0.sdk
  macOS: MacOSX26.0.sdk
  tvOS: AppleTVOS26.0.sdk
  tvOS Sim: AppleTVSimulator26.0.sdk
  visionOS: XROS26.0.sdk
  visionOS Sim: XRSimulator26.0.sdk
--> 6527a06741da
STEP 10/11: RUN PATH="/root/.local/share/swiftly/bin:${PATH}" swift sdk install /root/swift-sdk/darwin.artifactbundle
Error: Error Domain=NSCocoaErrorDomain Code=512 "(null)"UserInfo={NSDestinationFilePath=/root/.swiftpm/swift-sdks/darwin.artifactbundle, NSUserStringVariant=["Copy"], NSSourceFilePathErrorKey=/root/swift-sdk/darwin.artifactbundle, NSURL=file:///root/swift-sdk/darwin.artifactbundle, NSFilePath=/root/swift-sdk/darwin.artifactbundle}
Error: building at STEP "RUN PATH="/root/.local/share/swiftly/bin:${PATH}" swift sdk install /root/swift-sdk/darwin.artifactbundle": while running runtime: exit status 1

I'm running on a Fedora 42 host for the record, and with sudo but I don't expect this to impact the behavior.

@stuartcarnie
Copy link
Contributor Author

stuartcarnie commented Oct 13, 2025

I'm running on a Fedora 42 host for the record, and with sudo but I don't expect this to impact the behavior.

Did some more research, and apparently sudo could be impacting things. One suggestion is to add the --no-same-owner, which I have done when extracting the Xcode tar.gz. Can you try the Dockerfile.swift again?

@Calinou Calinou added the enhancement New feature or request label Oct 14, 2025
@akien-mga
Copy link
Member

Still no luck with the latest commit:

$ export img_version=4.6-f42 
$ sudo podman build --build-arg img_version=${img_version} -v $(realpath files):/root/files:z -t godot-swift:${img_version} -f Dockerfile.swift .
STEP 1/11: FROM godot-fedora:4.6-f42
STEP 2/11: ENV XCODE_SDKV=26.0.1
--> Using cache 4d52f7bd9cef0b35f7f5bdbeca6ff31edf53db6223e8a18265131cb57143678d
--> 4d52f7bd9cef
STEP 3/11: ENV APPLE_SDKV=26.0
--> Using cache 05fbcdc16ef590b9411b45e7dd5dcfa1046fe5bf449f6ab6706d711e6ccae696
--> 05fbcdc16ef5
STEP 4/11: ENV OSX_SDK=26.0
--> Using cache bb7d734c7ea57fe9281b0c4b700a7b2edc336bca6b3eaecf91055731b3c33b76
--> bb7d734c7ea5
STEP 5/11: RUN dnf -y install --setopt=install_weak_deps=False     gpg
--> Using cache 2fd7d8b19404b7a5fd2fb726f39a6e37da787fe1c50341ce3c26be09586f1881
--> 2fd7d8b19404
STEP 6/11: RUN mkdir -p /root/Xcode.app/Contents/Developer
--> Using cache 2dccfda00ec012b7852ec28aae3e719ab88328135418afc34b0b7ee7abcbd18a
--> 2dccfda00ec0
STEP 7/11: RUN cd /root/Xcode.app/Contents/Developer && tar xf /root/files/Xcode-Developer${XCODE_SDKV}.tar.xz --strip-components=1 --no-same-owner
--> Using cache 64182744063c827ef19fb798705809399550687e2223449129723415d851ff9e
--> 64182744063c
STEP 8/11: RUN curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz &&     tar zxf swiftly-$(uname -m).tar.gz &&     ./swiftly init --platform ubi9 --quiet-shell-followup -y &&     . "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh" &&     hash -r
--> Using cache 3dfcc7d4e670cf73773777189e7b343027c8f58aa6818030a6d82e52f1212aec
--> 3dfcc7d4e670
STEP 9/11: RUN /root/files/swift/create-sdk-bundle.sh /root/Xcode.app/Contents/Developer /root/swift-sdk
--> Using cache 898d153f6aae096709b7dabb133a772651f0520d234adef2deaeb4bd7393e1f2
--> 898d153f6aae
STEP 10/11: RUN PATH="/root/.local/share/swiftly/bin:${PATH}" swift sdk install /root/swift-sdk/darwin.artifactbundle
Error: Error Domain=NSCocoaErrorDomain Code=512 "(null)"UserInfo={NSUserStringVariant=["Copy"], NSURL=file:///root/swift-sdk/darwin.artifactbundle, NSDestinationFilePath=/root/.swiftpm/swift-sdks/darwin.artifactbundle, NSSourceFilePathErrorKey=/root/swift-sdk/darwin.artifactbundle, NSFilePath=/root/swift-sdk/darwin.artifactbundle}
Error: building at STEP "RUN PATH="/root/.local/share/swiftly/bin:${PATH}" swift sdk install /root/swift-sdk/darwin.artifactbundle": while running runtime: exit status 1

@stuartcarnie
Copy link
Contributor Author

@akien-mga I am running the podman container under Ubuntu; do you think there are differences between the OSs as to why it is failing for you? The other difference is that your container is running as x86_64 and mine is arm64. I don't see why the architecture should matter, but it is a difference.

It's slightly amusing that we're using containers to avoid conflicts from the local machine, yet here we are…

@akien-mga
Copy link
Member

For the record, I made a test build without sudo and I ran into the same issue.

@akien-mga I am running the podman container under Ubuntu; do you think there are differences between the OSs as to why it is failing for you? The other difference is that your container is running as x86_64 and mine is arm64. I don't see why the architecture should matter, but it is a difference.

It's slightly amusing that we're using containers to avoid conflicts from the local machine, yet here we are…

Yeah there's probably some system configuration difference or some of the underlying stack for podman that may differ between Fedora and Ubuntu. We might need advice from @hpvb to debug this.

@stuartcarnie
Copy link
Contributor Author

stuartcarnie commented Oct 15, 2025

@akien-mga I am going to set up a Fedora 42 x86_64 host VM and run podman inside that to match your environment as closely as possible. I'll also extract Xcode from the 26.0.1 .xip and see how I go.

@stuartcarnie
Copy link
Contributor Author

@akien-mga I'm now at a loss, as I set up an environment that very closely models yours:

  • Fedora 42 x86_64 host machine
  • sudo podman ... invocations

Important

What version of podman are you running, as apparently there are bugs in 4.x regarding symbolic links:

podman --version
podman version 5.6.2
  • Run godot-xcode to extract SDK from 26.0.1 .xip file (using Xcode_26.0.1_Apple_silicon.xip)
sudo podman run -it --rm -v $(realpath files):/root/files:z -v /Volumes/Data:/root/data:z -e XCODE_SDKV=26.0.1 -e XCODE_XIP_PATH=/root/data/Xcode_26.0.1_Apple_silicon.xip -e APPLE_SDKV=26.0 godot-xcode:${img_version}
  • Run Dockerfile.swift to test (which is now running the x86_64 binary)
sudo podman build --build-arg img_version=${img_version} -v $(realpath files):/root/files:z -t godot-swift:${img_version} -f Dockerfile.swift .
97%: Downloaded 935.2 MiB of 954.4 MiB
99%: Downloaded 946.4 MiB of 954.4 MiB
100%: Downloaded 954.4 MiB of 954.4 MiB
Verifying toolchain signature...
Extracting toolchain...
The global default toolchain has been set to `Swift 6.2.0`
Swift 6.2.0 is installed successfully!
--> 7d7ea339863e
STEP 9/11: RUN /root/files/swift/create-sdk-bundle.sh /root/Xcode.app/Contents/Developer /root/swift-sdk
Creating artifact bundle at /root/swift-sdk/darwin.artifactbundle
Found SDKs:
  iOS: iPhoneOS26.0.sdk
  iOS Sim: iPhoneSimulator26.0.sdk
  macOS: MacOSX26.0.sdk
  tvOS: AppleTVOS26.0.sdk
  tvOS Sim: AppleTVSimulator26.0.sdk
  visionOS: XROS26.0.sdk
  visionOS Sim: XRSimulator26.0.sdk
--> e82c6c95e0de
STEP 10/11: RUN PATH="/root/.local/share/swiftly/bin:${PATH}" swift sdk install /root/swift-sdk/darwin.artifactbundle
Swift SDK bundle at `/root/swift-sdk/darwin.artifactbundle` successfully installed as darwin.artifactbundle.
--> 1007cb68dcd6
STEP 11/11: CMD /bin/bash
COMMIT godot-swift:4.6-f42
--> 96828fcea0ef
Successfully tagged localhost/godot-swift:4.6-f42
96828fcea0efd4adfde1670d4257061af46b5dd481b068da8d25b7291d386c73

@stuartcarnie
Copy link
Contributor Author

@akien-mga could I build the Apple containers for you and push them to a repository, so you can pull them down?

@akien-mga
Copy link
Member

@akien-mga could I build the Apple containers for you and push them to a repository, so you can pull them down?

That could work as a stopgap measure, but the purpose of these containers is to be reproducible, and they're not just used by us for our builds but potential other users who want to make their custom builds of Godot. So if this PR only works on some machines we need to figure out why and solve that.

HP started looking into it to see what might cause this difference in behavior.

If we can't find how to make it work quickly, I would likely prefer that we temporarily revert the PR that made Swift a requirement for iOS and visionOS, so we can build 4.6-dev2 (this is currently the main blocker to making new builds). Then we can take our time to ensure that the build pipeline is ready for it before merging it again.

@stuartcarnie
Copy link
Contributor Author

That could work as a stopgap measure, but the purpose of these containers is to be reproducible, and they're not just used by us for our builds but potential other users who want to make their custom builds of Godot. So if this PR only works on some machines we need to figure out why and solve that.

Absolutely agree! It baffles me that I've set up a mostly similar environment to you and still can't reproduce it. The supposed benefit of containers is to avoid host incompatibilities 😅

If we can't find how to make it work quickly, I would likely prefer that we temporarily revert the PR that made Swift a requirement for iOS and visionOS, so we can build 4.6-dev2 (this is currently the main blocker to making new builds). Then we can take our time to ensure that the build pipeline is ready for it before merging it again.

No problem at all and the right decision if we can't resolve it.

@stuartcarnie
Copy link
Contributor Author

HP started looking into it to see what might cause this difference in behavior.

If HP needs anything from me, don't hesitate to ping me.

@hpvb
Copy link
Member

hpvb commented Oct 17, 2025

The error is cosmetic

After a successful run of the script:

# PATH="/root/.local/share/swiftly/bin:${PATH}" swift sdk install /root/swift-sdk/darwin.artifactbundle
Swift SDK bundle at `/root/swift-sdk/darwin.artifactbundle` successfully installed as darwin.artifactbundle.
# find ~/.swiftpm/swift-sdks/ -type f -exec md5sum {} \;
8951d37616b815827c2512116d0fe33f  /root/.swiftpm/swift-sdks/darwin.artifactbundle/info.json
b32fb0e3eea29096e1661992b80f7e7e  /root/.swiftpm/swift-sdks/darwin.artifactbundle/swift-sdk.json
54f0b7f20ec29b9cf09c3cc0a0652ead  /root/.swiftpm/swift-sdks/darwin.artifactbundle/toolset.json

An unsuccessful run:

# PATH="/root/.local/share/swiftly/bin:${PATH}" swift sdk install /root/swift-sdk/darwin.artifactbundle
Error: Error Domain=NSCocoaErrorDomain Code=512 "(null)"UserInfo={NSFilePath=/root/swift-sdk/darwin.artifactbundle, NSDestinationFilePath=/root/.swiftpm/swift-sdks/darwin.artifactbundle, NSURL=file:///root/swift-sdk/darwin.artifactbundle, NSUserStringVariant=["Copy"], NSSourceFilePathErrorKey=/root/swift-sdk/darwin.artifactbundle}
# find ~/.swiftpm/swift-sdks/ -type f -exec md5sum {} \;
8951d37616b815827c2512116d0fe33f  /root/.swiftpm/swift-sdks/darwin.artifactbundle/info.json
b32fb0e3eea29096e1661992b80f7e7e  /root/.swiftpm/swift-sdks/darwin.artifactbundle/swift-sdk.json
54f0b7f20ec29b9cf09c3cc0a0652ead  /root/.swiftpm/swift-sdks/darwin.artifactbundle/toolset.json

The contents are identical (the symbolic link also points to the same place)

The root cause is this:

110   openat(AT_FDCWD, "/root/.swiftpm/swift-sdks/darwin.artifactbundle", O_RDONLY|O_NOFOLLOW|O_DIRECTORY) = 10
....
110   fsetxattr(10, "security.selinux", "system_u:object_r:container_file"..., 48, 0) = -1 EOPNOTSUPP (Operation not supported)

Probably because the buildsystem has selinux enabled (it is, however, in permissive mode), or because we use a different filesystem than you @stuartcarnie the swift installer thinks that it can run fsetxattr on the directory in /root. But because this is an overlayfs this cannot work.

the swift installed will then give up, even though it seems to have done all it is ever going to do.

The 'fix' for this I suppose is to ignore this error, I would suggest doing a grep on stderr to ensure that the error that is being ignored is in fact the error we are 'expecting' in this case.

EDIT: Alternatively, just don't use the script at all, and manually copy /root/swift-sdk/darwin.artifactbundle/ to /root/.swiftpm/swift-sdks/darwin.artifactbundle

This appears all that swift sdk install does in our case. Presumably the step /root/files/swift/create-sdk-bundle.sh /root/Xcode.app/Contents/Developer /root/swift-sdk can also just directly place the sdk files in the correct place, saving an entire step.

@stuartcarnie
Copy link
Contributor Author

@hpvb great – I'll just try copy the files, as you are right, that is probably all it is doing.

@stuartcarnie
Copy link
Contributor Author

@akien-mga I've pushed up the changes and verified I could still build an iOS object file using Swift. No longer uses swift to install the SDK

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work well now.

There are still a few SDK-specific variables like IOS_SDKV/VISIONOS_SDKV/etc. that could be streamlined now that there's only one APPLE_SDKV, but this can be done in a follow-up cleanup. The priority now is to have functional build containers.

Thanks a lot for the great work @stuartcarnie, and thanks @hpvb for the help debugging the copy issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants