-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
.github, config: use Zig to cross compile arm64 Linux asset #460
Merged
Merged
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0546176
config: support zigcc locally
ee7 4dae1da
.github: support zigcc in CI
ee7 bc75361
nimble: strip zig-built binary via `after build` hook
ee7 ceef0c0
nimble: strip comment section from binary
ee7 c3254b7
nimble: remove `-s` flag from `strip` command
ee7 c4cf6be
configlet: improve status message
ee7 0fd7591
.github, config: cross-compile an arm64 asset
ee7 abb70ab
nimble: comment-out stripping
ee7 8df0f9b
.github(cross-compile): fix path
ee7 f6aaed8
.github(cross-compile): add arm64 macos target
ee7 d4403d3
.github(cross-compile): try --os:macosx
ee7 97893f7
config: disable LTO for zig + macos
ee7 62ed28c
.github(cross-compile): disable aarch-macos target for now
ee7 83796fe
.github(cross-compile): try aarch64-windows-gnu
ee7 3f8c8df
.github(cross-compile): comment out aarch64-windows-gnu
ee7 21bf654
.github(cross-compile): fix macos arm64 asset name
ee7 67dbdd5
.github(cross-compile): remove some blank lines
ee7 eea45c8
.github(cross-compile), nimble: prepare to strip with llvm-strip
ee7 3e97a25
.github(cross-compile): format with shfmt
ee7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
artifacts_dir='artifacts' | ||
build_tag="${GITHUB_REF_NAME}" | ||
|
||
cross_compile() { | ||
local target="$1" | ||
local arch='arm64' | ||
local os | ||
case "$(cut -d'-' -f2 <<<"${target}")" in | ||
macos) os='macosx' ;; | ||
*) os='linux' ;; | ||
esac | ||
|
||
nimble --verbose build --cpu:"${arch}" --os:"${os}" -d:release -d:zig -d:target:"${target}" | ||
|
||
mkdir -p "${artifacts_dir}" | ||
|
||
local binary_name='configlet' | ||
|
||
local artifact_file="${artifacts_dir}/${binary_name}_${build_tag}_${os}_${arch}.tar.gz" | ||
tar -cvzf "${artifact_file}" "${binary_name}" | ||
} | ||
|
||
main() { | ||
nimble --accept install --depsOnly | ||
|
||
local targets=( | ||
aarch64-linux-musl | ||
# aarch64-macos-none | ||
) | ||
|
||
for target in "${targets[@]}"; do | ||
cross_compile "${target}" | ||
done | ||
|
||
gh release upload "${build_tag}" "${artifacts_dir}"/* | ||
} | ||
|
||
main |
2 changes: 0 additions & 2 deletions
2
.github/bin/linux-install-build-tools → .github/bin/linux-install-musl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Install musl | ||
sudo apt-get install musl-dev musl-tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
version='0.11.0' # 2023-08-04 | ||
release_name="zig-linux-x86_64-${version}" | ||
archive="${release_name}.tar.xz" | ||
url="https://ziglang.org/download/${version}/${archive}" | ||
|
||
curlopts=( | ||
--silent | ||
--show-error | ||
--fail | ||
--location | ||
--retry 3 | ||
) | ||
|
||
# Download the release archive. | ||
echo "Downloading Zig release archive..." >&2 | ||
curl "${curlopts[@]}" --output "${archive}" "${url}" | ||
|
||
# Check that the archive has the expected hash. | ||
echo "Verifying archive..." >&2 | ||
archive_sha256='2d00e789fec4f71790a6e7bf83ff91d564943c5ee843c5fd966efc474b423047' | ||
echo "${archive_sha256} ${archive}" | sha256sum -c - | ||
|
||
# Extract the archive, then remove it. | ||
echo "Extracting archive..." >&2 | ||
tar xJf "${archive}" | ||
rm "${archive}" | ||
|
||
# Add zig directory to `GITHUB_PATH`. | ||
zig_dir="$(pwd)/${release_name}" | ||
echo "${zig_dir}" >> "${GITHUB_PATH}" | ||
|
||
# Install `zigcc`, which is just a wrapper for `zig cc`. We need this because | ||
# the value of e.g. `--clang.exe` cannot contain a space (Nim requires the value | ||
# to be an executable, not a command). | ||
zigcc_path="${zig_dir}/zigcc" | ||
printf '#!/usr/bin/env sh\nzig cc $@\n' > "${zigcc_path}" | ||
chmod +x "${zigcc_path}" | ||
|
||
# Print the versions of Zig and Clang. | ||
"${zig_dir}"/zig version | ||
"${zig_dir}"/zig cc --version | ||
echo "Successfully installed Zig ${version}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 duplicates some logic from the existing:
.github/bin/build
.github/bin/create-artifact
.github/bin/publish-release
because they're difficult to adapt for cross-compilation with their current factoring.
I think this will be easier to clean up when we've improved the build process to resolve #551.