-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Linux: static libc + arm64 build #6015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Linux: static libc + arm64 build #6015
Conversation
This should be fully backwards compatible, so that existing amd64 binaries, including paths etc. are not affected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking forward to this!
To test the build you could make the docker.yml
workflow trigger in pull requests.
strip artifacts/linux_amd64/usr/bin/swiftformat | ||
mv artifacts/linux_amd64/usr/bin/swiftlint artifacts/usr/bin/swiftlint_linux_amd64 | ||
aarch64-linux-gnu-strip artifacts/linux_arm64/usr/bin/swiftformat | ||
mv artifacts/linux_arm64/usr/bin/swiftlint artifacts/usr/bin/swiftlint_linux_arm64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refers to swiftformat
. Not sure if the paths to the binaries are correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! I'll double check all these
if: contains(env.OUTPUT_TYPE, 'local') | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: swiftlint_linux_amd64 | ||
path: artifacts/usr/bin/swiftlint_linux_amd64 | ||
if-no-files-found: error | ||
retention-days: 2 | ||
- name: Upload ARM64 binary artifact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can upload both files at once in only a single step.
COPY --from=builder /usr/lib/swift/linux/libswiftDispatch.so /usr/lib | ||
COPY --from=builder /usr/lib/swift/linux/libswiftGlibc.so /usr/lib | ||
COPY --from=builder /usr/lib/swift/linux/libswiftSynchronization.so /usr/lib | ||
COPY --from=builder /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so /usr/lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These runtime dependencies are not copied anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still playing around here, most of these likely will need to still get copied into the container.
cp -f "$(LICENSE_PATH)" "$(ARTIFACT_BUNDLE_PATH)" | ||
(cd "$(TEMPORARY_FOLDER)"; zip -yr - "SwiftLintBinary.artifactbundle") > "./SwiftLintBinary.artifactbundle.zip" | ||
|
||
zip_linux: docker_image $(SWIFTLINT_EXECUTABLE_LINUX_AMD64) | ||
zip_linux: docker_image $(SWIFTLINT_EXECUTABLE_LINUX_AMD64) $(SWIFTLINT_EXECUTABLE_LINUX_ARM64) | ||
$(eval TMP_FOLDER := $(shell mktemp -d)) | ||
cp -f $(SWIFTLINT_EXECUTABLE_LINUX_AMD64) "$(TMP_FOLDER)/swiftlint" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably rename this to swiftlint_amd64
once everything works.
--product swiftlint | ||
--configuration release | ||
-Xlinker -S | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the other linker options not needed anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also still playing around here. The main issue I'm having at the moment is getting libc statically linked while keeping the other dependencies dynamically linked. --swift-sdk
is seemingly always producing a fully statically linked binary.
swiftlint
binary.libc
(reducing the burden on the host environment to have exactly the correct glibc version).swiftlint_arm64
, located in the same directory as the amd64 binary.