Skip to content
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

cargo zigbuild #799

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
135896a
zig-release
phoepsilonix Jan 23, 2024
0c71660
Merge branch 'raphlinus:master' into zig-release
phoepsilonix Jan 28, 2024
24f9fb1
Merge branch 'raphlinus:master' into zig-release
phoepsilonix Jan 31, 2024
ee2fdda
Merge branch 'raphlinus:master' into zig-release
phoepsilonix Feb 2, 2024
11dc325
branch_0.9.3 v0.9.6
phoepsilonix Feb 2, 2024
f6008ac
Merge branch 'raphlinus:master' into zig-release
phoepsilonix Feb 3, 2024
41f3c6a
v0.10.0
phoepsilonix Feb 3, 2024
fc1269e
git pull upstream --tags
phoepsilonix Feb 3, 2024
a5b17ec
workflow
phoepsilonix Feb 3, 2024
16a2b16
v0.9.6
phoepsilonix Feb 3, 2024
aba1f68
release
phoepsilonix Feb 4, 2024
b5c8f9a
Merge branch 'raphlinus:master' into zig-release
phoepsilonix Feb 8, 2024
caca086
tag and commit
phoepsilonix Feb 8, 2024
13b3ff0
tag and commit
phoepsilonix Feb 8, 2024
686906a
Merge branch 'zig-release' of github.com:phoepsilonix/pulldown-cmark …
phoepsilonix Feb 28, 2024
11e3ead
ziglang update dev.3076
phoepsilonix Feb 29, 2024
deaa2cd
remove cargo update
phoepsilonix Feb 29, 2024
b170516
install binutils-mingw-w64
phoepsilonix Feb 29, 2024
ae550c3
update zigland 0.11.0
phoepsilonix Feb 29, 2024
602a44f
modified version
phoepsilonix Feb 29, 2024
561a517
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Mar 3, 2024
ae42808
fix version.txt
phoepsilonix Mar 3, 2024
b3ab681
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Mar 3, 2024
d15af09
tag -> version
phoepsilonix Mar 3, 2024
5c573db
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Mar 3, 2024
9d9f734
mold 2.4.1,sccache 0.7.7
phoepsilonix Mar 4, 2024
f77d6c2
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Mar 6, 2024
8e4e0df
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Mar 16, 2024
baffc5e
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Mar 17, 2024
b4841a3
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Apr 1, 2024
7c42e35
mold update
phoepsilonix Apr 1, 2024
b0adc4e
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Apr 4, 2024
3327b72
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Apr 5, 2024
119fc64
tag fix
phoepsilonix Apr 5, 2024
79094b0
Fine-tuning tags
phoepsilonix Apr 12, 2024
3c69820
sccache update
phoepsilonix Apr 12, 2024
e8fd7bf
submodule is no needed
phoepsilonix Apr 13, 2024
17cbb2b
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Apr 16, 2024
a5c0f2e
tag flow
phoepsilonix Apr 16, 2024
7c1c390
disable rust workflow
phoepsilonix Apr 16, 2024
b168d71
.gitignore
phoepsilonix Apr 16, 2024
83885d4
tag flow fix
phoepsilonix Apr 16, 2024
e955c1e
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Apr 20, 2024
460c50f
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix Apr 23, 2024
ae118e9
version tag fix
phoepsilonix Apr 23, 2024
48d00b0
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
95 changes: 95 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
release:
name: Release
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_CACHE_SIZE: 1G
SCCACHE_DIR: /home/runner/.cache/sccache
# SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment
steps:
- uses: actions/checkout@v4
with:
lfs: true
submodules: 'recursive'
path: zig-release
- uses: actions/checkout@v4
with:
ref: master
lft: true
submodule: 'recursive'
commit: 42bff71ea497c493d740324ebe4b3799dc273b8a
path: pulldown-cmark
- name: copy Makefile for zig-release
run: |
mkdir -p source
cd zig-release
git describe --tags | sed -e 's/^v//g' -e 's/-g.*$//g' -e 's/-/./g' > version.txt
git describe --tags | sed -e 's/^v//g' -e 's/-g.*$//g' -e 's/-/./g'
cat version.txt
cp Makefile archive.sh target.txt version.txt ../pulldown-cmark/
cp config.toml target.txt ../
- name: install zig and tools (Linux)
run: |
#pacman -Sy sudo rustup clang llvm lld make git --noconfirm
sudo apt-get install build-essential make git clang
rm -f ~/.cargo/config*
mkdir -p zig
curl -LZ https://ziglang.org/builds/zig-linux-x86_64-0.12.0-dev.2302+b729a3f00.tar.xz|tar xJ --strip-component=1 -C zig
sudo mv zig /usr/local/
echo "/usr/local/zig" >> $GITHUB_PATH
- name: Install sccache
env:
LINK: https://github.com/mozilla/sccache/releases/download
SCCACHE_VERSION: 0.7.6
run: |
SCCACHE_FILE=sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl
mkdir -p $HOME/.local/bin
curl -L "$LINK/v$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
chmod +x $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install mold linker
uses: rui314/setup-mold@staging
with:
mold-version: 2.4.0
make-default: true
- name: Cache toolchain
uses: Swatinem/rust-cache@v2
- name: Update toolchain
run: |
rustup update nightly
rustup default nightly
rustup component add rust-src
rustup target add $(cat target.txt)
rustup +stable target add $(cat target.txt)
- name: Install cargo-zigbuild
run: |
cargo install cargo-zigbuild --target x86_64-unknown-linux-gnu
- name: config.toml
run: |
mkdir -p ~/.cargo/
rm -f ~/.cargo/config*
cp config.toml ~/.cargo/config.toml
- name: fix duplicate symbol
run: |
sudo sed -e "s|\(void __cdecl _tzset(void)\)|/*\n\1|" -e "s|\(void __cdecl tzset(void)\)|*/\n\1|" -i /usr/local/zig/lib/libc/mingw/crt/ucrtbase_compat.c
- name: Build and archive
shell: bash
run: |
cd pulldown-cmark
cargo update
make target-archive
- name: Create release
uses: ncipollo/release-action@v1
with:
omitBody: true
artifacts: 'pulldown-cmark/release/*'
token: ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
TARGET=$(shell cat target.txt)

.PHONY: lint
lint:
@cargo +nightly clippy

.PHONY: fix
fix:
@cargo +nightly clippy --fix

.PHONY: test
test:
@cargo +nightly test

.PHONY: shellspec
shellspec:
@shellspec

.PHONY: install
install:
@cargo +nightly install --path .
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not quite sure what the goal is there but none of this smell right. As someone packaging this for distros and using it myself, this whole pile of changes would just confuse me about how the project was expected to be used. It doesn't need +nightly. This Makefile is a thin wrapper around other commands and doesn't support any of the tooling I'd expect an actual Makefile to handle. Most of this feels more like it should go in a Justfile or something for developer jobs, but most of it isn't even build stuff, and the bits that are don't seem to be general purpose.


.PHONY: check
check:
@cargo +nightly check

.PHONY: target-add
target-add:
@rustup override set nightly
@rustup target add $(TARGET)

.PHONY: target-build
target-build: target-add
@for target in $(TARGET); do echo $$target; cargo +nightly zigbuild --release --target $$target || cargo +stable zigbuild --release --target $$target; done

.PHONY: target-archive
target-archive: target-build
@bash archive.sh $(TARGET)
22 changes: 22 additions & 0 deletions archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
version=$(cat version.txt)
if [[ "${version}" == "" ]]; then
echo "cannot get version tag from HEAD commit"
exit 1
fi
bin=$(basename "$(git rev-parse --show-toplevel)")
target="$*"

if [[ ! -d "release" ]]; then
mkdir "release"
fi

for target in "$@"; do
archive="${bin}_${version}_${target}"
echo "## make archive ${archive}"
if [[ "$target" == *"windows"* ]]; then
( cd "target/${target}/release/" && zip "../../../release/${archive}.zip" "${bin}.exe" )
else
( cd "target/${target}/release/" && tar -Jcvf "../../../release/${archive}.tar.xz" "${bin}" )
fi
done
64 changes: 64 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[build]
target = "x86_64-unknown-linux-musl"
rustc-wrapper = "sccache"

[unstable]
build-std = ["core", "compiler_builtins", "alloc", "std", "panic_abort"]
build-std-features = ["llvm-libunwind"]

[target.x86_64-unknown-linux-musl]
linker = "clang"
rustflags = [
"-Clink-self-contained=on",
"-C", "strip=symbols",
"-C", "no-redzone=y",
"-C", "overflow-checks=y",
"-C", "lto=fat",
"-C", "embed-bitcode=y",
"-C", "codegen-units=1",
"-C", "opt-level=z",
"-C", "control-flow-guard=y",
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now",
]

[target.x86_64-pc-windows-gnu]
linker = "clang"
rustflags = [
"-C", "strip=symbols",
"-C", "no-redzone=y",
"-C", "overflow-checks=y",
"-C", "lto=fat",
"-C", "embed-bitcode=y",
"-C", "codegen-units=1",
"-C", "opt-level=z",
"-C", "control-flow-guard=y",
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now",
]

[target.x86_64-apple-darwin]
linker = "clang"
rustflags = [
"-C", "strip=symbols",
"-C", "no-redzone=y",
"-C", "overflow-checks=y",
"-C", "lto=fat",
"-C", "embed-bitcode=y",
"-C", "codegen-units=1",
"-C", "opt-level=z",
"-C", "control-flow-guard=y",
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now",
]

[target.aarch64-apple-darwin]
linker = "clang"
rustflags = [
"-C", "strip=symbols",
"-C", "no-redzone=y",
"-C", "overflow-checks=y",
"-C", "lto=fat",
"-C", "embed-bitcode=y",
"-C", "codegen-units=1",
"-C", "opt-level=z",
"-C", "control-flow-guard=y",
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now",
]
4 changes: 4 additions & 0 deletions target.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
x86_64-unknown-linux-musl
x86_64-pc-windows-gnu
x86_64-apple-darwin
aarch64-apple-darwin