From c8674dc338288645a5a98dbec501bec801353806 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Thu, 24 Apr 2025 23:31:34 +0200 Subject: [PATCH 1/2] build all variations in CI to keep track of what works --- .github/workflows/rust.yml | 73 ++++++++++++++++++++++++++++++-------- example/Makefile | 6 ++-- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9089694..fcd39ad 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,32 +13,77 @@ env: RUSTFLAGS: "-Dwarnings" jobs: - build: - + build-gnu-apt: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - name: Update repos run: sudo apt-get update -qq - - name: Install rust toolchain - run: sudo apt-get install -qy cargo rust-clippy - - name: install lzma - run: sudo apt-get install -qy liblzma-dev - - name: install gcc - run: sudo apt-get install -qy gcc make + - name: Install toolchain + run: sudo apt-get install -qy cargo rust-clippy liblzma-dev gcc make pkgconf - name: Run Clippy run: cargo clippy + - name: build + run: cargo build + - name: generate bindings run: ./generate-binding.sh - name: check that generated files did not change run: output=$(git status --porcelain) && [ -z "$output" ] - - - name: build - run: cargo build - - name: build example - run: cd example && make + - name: build example -- glibc release + run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=release + - name: build example -- glibc debug + run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=debug + + # this _should_ have been -stable, but there is a bug when running in the container ("Invalid cross-device link") + build-musl-beta: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Update repos + run: sudo apt-get update -qq + - name: Install toolchain + run: sudo apt-get install -qy liblzma-dev gcc make pkgconf musl-dev musl-tools rustup + - name: install rust target + run: rustup default beta && rustup target add aarch64-unknown-linux-musl && rustup component add rust-src && rustup update + + - name: build example -- musl release + run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=release MUSL=1 CARGO="rustup run beta cargo" + - name: build example -- musl debug + run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=debug MUSL=1 CARGO="rustup run beta cargo" + + build-size-gnu-unstable: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Update repos + run: sudo apt-get update -qq + - name: Install toolchain + run: sudo apt-get install -qy liblzma-dev gcc make pkgconf rustup + - name: install rust targets + run: rustup toolchain install nightly -t aarch64-unknown-linux-gnu -c rust-src --no-self-update + + - name: build example -- glibc size-optimized + run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=size-optimized CARGO="rustup run nightly cargo" + + + build-size-musl-unstable: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Update repos + run: sudo apt-get update -qq + - name: Install toolchain + run: sudo apt-get install -qy liblzma-dev gcc make pkgconf musl-dev musl-tools rustup + - name: install rust targets + run: rustup toolchain install nightly -t aarch64-unknown-linux-musl -c rust-src --no-self-update + + - name: build example -- musl size-optimized + run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=size-optimized MUSL=1 LTO=1 CARGO="rustup run nightly cargo" diff --git a/example/Makefile b/example/Makefile index a35aa5c..353e298 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,7 +1,7 @@ CARGO ?= cargo STRIP ?= strip -FEATURES := +FEATURES := "" THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) REPO_ROOT := $(realpath $(THIS_DIR)/..) @@ -10,7 +10,7 @@ export SERVICEPOINT_HEADER_OUT := $(REPO_ROOT)/include override CFG_MUSL := $(if $(CFG_MUSL),$(CFG_MUSL),$(if $(MUSL),$(MUSL),0)) override CFG_PROFILE := $(if $(CFG_PROFILE),$(CFG_PROFILE),$(if $(PROFILE),$(PROFILE),release)) -CCFLAGS += -Wall -fwhole-program +CCFLAGS += -Wall -fwhole-program -fPIE -pie STRIPFLAGS := -s --strip-unneeded -R .comment -R .gnu.version -R .note -R .note.gnu.build-id -R .note.ABI-tag @@ -18,7 +18,7 @@ ifeq ($(CFG_MUSL), 1) TARGET ?= x86_64-unknown-linux-musl CC ?= musl-gcc CCFLAGS += -static -lservicepoint_binding_c - RUSTFLAGS += --crate-type=staticlib + RUSTFLAGS += --crate-type=staticlib -Ctarget-feature=-crt-static else TARGET ?= x86_64-unknown-linux-gnu CC ?= gcc From 5ee324d8c1588cbab9c598b754de28b84dbb68b7 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sun, 4 May 2025 12:22:27 +0200 Subject: [PATCH 2/2] remove musl builds --- .github/workflows/rust.yml | 35 +---------------------------------- example/Makefile | 5 ++--- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fcd39ad..32bae5e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,6 +13,7 @@ env: RUSTFLAGS: "-Dwarnings" jobs: + build-gnu-apt: runs-on: ubuntu-latest steps: @@ -39,24 +40,6 @@ jobs: - name: build example -- glibc debug run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=debug - # this _should_ have been -stable, but there is a bug when running in the container ("Invalid cross-device link") - build-musl-beta: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Update repos - run: sudo apt-get update -qq - - name: Install toolchain - run: sudo apt-get install -qy liblzma-dev gcc make pkgconf musl-dev musl-tools rustup - - name: install rust target - run: rustup default beta && rustup target add aarch64-unknown-linux-musl && rustup component add rust-src && rustup update - - - name: build example -- musl release - run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=release MUSL=1 CARGO="rustup run beta cargo" - - name: build example -- musl debug - run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=debug MUSL=1 CARGO="rustup run beta cargo" - build-size-gnu-unstable: runs-on: ubuntu-latest steps: @@ -71,19 +54,3 @@ jobs: - name: build example -- glibc size-optimized run: cd example && make clean && make TARGET=aarch64-unknown-linux-gnu PROFILE=size-optimized CARGO="rustup run nightly cargo" - - - build-size-musl-unstable: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Update repos - run: sudo apt-get update -qq - - name: Install toolchain - run: sudo apt-get install -qy liblzma-dev gcc make pkgconf musl-dev musl-tools rustup - - name: install rust targets - run: rustup toolchain install nightly -t aarch64-unknown-linux-musl -c rust-src --no-self-update - - - name: build example -- musl size-optimized - run: cd example && make clean && make TARGET=aarch64-unknown-linux-musl PROFILE=size-optimized MUSL=1 LTO=1 CARGO="rustup run nightly cargo" diff --git a/example/Makefile b/example/Makefile index 353e298..f7111b1 100644 --- a/example/Makefile +++ b/example/Makefile @@ -31,7 +31,6 @@ endif #endif RUST_TARGET_DIR := $(REPO_ROOT)/target/$(TARGET)/$(CFG_PROFILE) -OUT_DIR := $(realpath $(THIS_DIR)/out/) ifeq ($(CFG_PROFILE), size-optimized) CARGO_PROFILE := size-optimized @@ -92,7 +91,7 @@ all: $(_bins) clean: clean-c clean-rust clean-c: - rm -r $(OUT_DIR) || true + rm -r out || true clean-rust: rm $(SERVICEPOINT_HEADER_OUT)/servicepoint.h || true @@ -123,7 +122,7 @@ sizes: $(_bins) ls -lB out analyze-size: out/$(BIN)_unstripped - nm --print-size --size-sort --reverse-sort --radix=d --demangle $(OUT_DIR)/$(BIN)_unstripped \ + nm --print-size --size-sort --reverse-sort --radix=d --demangle out/$(BIN)_unstripped \ | awk '{size=$$2+0; print size "\t" $$4}' \ | less