Skip to content

Instantly share code, notes, and snippets.

@Kyle-Ye
Created May 11, 2025 09:36
Show Gist options
  • Save Kyle-Ye/4658b5651f93e198f2cef80c00e5a1bf to your computer and use it in GitHub Desktop.
Save Kyle-Ye/4658b5651f93e198f2cef80c00e5a1bf to your computer and use it in GitHub Desktop.
A patch to workaround Swift 6.1 include CoreFoundation issue on Linux
#!/bin/bash
# A temporay workaround for https://github.com/swiftlang/swift-corelibs-foundation/issues/5211
set -e
# Find the path to swift binary
SWIFT_PATH=$(which swift)
echo "Swift binary found at: $SWIFT_PATH"
# Extract the toolchain path from swift binary path
# Remove /usr/bin/swift from the path to get the toolchain root
TOOLCHAIN_ROOT=$(dirname $(dirname "$SWIFT_PATH"))
echo "Toolchain root: $TOOLCHAIN_ROOT"
# Construct the path to CFBase.h
CFBASE_PATH="$TOOLCHAIN_ROOT/lib/swift/CoreFoundation/CFBase.h"
echo "Looking for CFBase.h at: $CFBASE_PATH"
# Check if the file exists
if [ -f "$CFBASE_PATH" ]; then
echo "Found CFBase.h, applying patch..."
# Create a backup of the original file
cp "$CFBASE_PATH" "$CFBASE_PATH.bak"
# Replace the include line
sed -i 's/#include <ptrauth.h>/\/\/ #include <ptrauth.h>/g' "$CFBASE_PATH"
echo "Patch applied successfully."
echo "Original file backed up at $CFBASE_PATH.bak"
else
echo "ERROR: Could not find CFBase.h in expected location."
echo "Toolchain structure may be different than expected."
exit 1
fi
@Kyle-Ye
Copy link
Author

Kyle-Ye commented May 14, 2025

Update: This is only needed for Swift 6.1
The fix has landed on main and will be released with Swift 6.2 toolchain.
swiftlang/swift-corelibs-foundation#5212

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