diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 067b047..4923b72 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -47,8 +47,8 @@ jobs: runs-on: linux-arm64 container: ghcr.io/rust-cross/cargo-zigbuild@sha256:82af75c41958c2af2787e8bedd912da7678a9438937e223e9d83d006d747b38b env: - CARGO_TARGET_AARCH64_APPLE_DARWIN_RUSTFLAGS: -C link-arg=-mmacosx-version-min=26.0 -C link-arg=-Wl,-rpath,@executable_path/../Resources -C link-arg=-Wl,-headerpad,0x1000 - CARGO_TARGET_X86_64_APPLE_DARWIN_RUSTFLAGS: -C link-arg=-mmacosx-version-min=26.0 -C link-arg=-Wl,-rpath,@executable_path/../Resources -C link-arg=-Wl,-headerpad,0x1000 + CARGO_TARGET_AARCH64_APPLE_DARWIN_RUSTFLAGS: -Lnative=target/macos-linker -C link-arg=-mmacosx-version-min=26.0 -C link-arg=-Wl,-rpath,@executable_path/../Resources -C link-arg=-Wl,-headerpad,0x1000 + CARGO_TARGET_X86_64_APPLE_DARWIN_RUSTFLAGS: -Lnative=target/macos-linker -C link-arg=-mmacosx-version-min=26.0 -C link-arg=-Wl,-rpath,@executable_path/../Resources -C link-arg=-Wl,-headerpad,0x1000 steps: - name: Check out the tag env: @@ -78,6 +78,8 @@ jobs: RELEASE_ID: ${{ needs.prepare-release.outputs.release_id }} run: | set -eu + cargo +${RUST_TOOLCHAIN} run --locked --package bds-release -- \ + macos-linker-alias target/macos-linker for build in \ 'aarch64-apple-darwin|aarch64-apple-darwin|darwin-arm64' \ 'x86_64-apple-darwin|x86_64-apple-darwin|darwin-x64' diff --git a/crates/bds-release/src/main.rs b/crates/bds-release/src/main.rs index c3c2e5c..5aa4166 100644 --- a/crates/bds-release/src/main.rs +++ b/crates/bds-release/src/main.rs @@ -8,6 +8,9 @@ fn main() -> Result<(), Box> { match args.as_slice() { [command] if command == "prepare" => gitea::prepare(), [command] if command == "publish" => gitea::publish(), + [command, directory] if command == "macos-linker-alias" => { + packaging::prepare_macos_linker_alias(Path::new(directory)) + } [command, paths @ ..] if command == "upload" && !paths.is_empty() => { gitea::upload(paths.iter().map(Path::new)) } @@ -36,7 +39,7 @@ fn main() -> Result<(), Box> { gitea::upload(assets.iter().map(|path| path.as_path())) } _ => Err( - "usage: bds-release prepare|publish|upload ...|package [--upload]" + "usage: bds-release prepare|publish|macos-linker-alias |upload ...|package [--upload]" .into(), ), } diff --git a/crates/bds-release/src/packaging.rs b/crates/bds-release/src/packaging.rs index 5e06c67..365a267 100644 --- a/crates/bds-release/src/packaging.rs +++ b/crates/bds-release/src/packaging.rs @@ -24,6 +24,12 @@ const LC_REEXPORT_DYLIB: u32 = 0x8000_001f; const LC_LAZY_LOAD_DYLIB: u32 = 0x20; const LC_LOAD_UPWARD_DYLIB: u32 = 0x8000_0023; +pub(crate) fn prepare_macos_linker_alias(directory: &Path) -> Result<(), Box> { + fs::create_dir_all(directory)?; + fs::write(directory.join("libclang_rt.osx.a"), b"!\n")?; + Ok(()) +} + #[derive(Clone, Copy, Debug, Eq, PartialEq)] enum Platform { MacOs, @@ -460,6 +466,17 @@ mod tests { assert_eq!(dmg_sectors(1).unwrap(), 131_072); } + #[test] + fn macos_cross_linker_alias_is_an_empty_static_archive() { + let temp = tempdir().unwrap(); + prepare_macos_linker_alias(temp.path()).unwrap(); + + assert_eq!( + fs::read(temp.path().join("libclang_rt.osx.a")).unwrap(), + b"!\n" + ); + } + #[test] fn windows_package_contains_the_app_without_dynamic_std() { let temp = tempdir().unwrap(); diff --git a/crates/bds-ui/tests/packaging_assets.rs b/crates/bds-ui/tests/packaging_assets.rs index 93ad0aa..43c5d08 100644 --- a/crates/bds-ui/tests/packaging_assets.rs +++ b/crates/bds-ui/tests/packaging_assets.rs @@ -119,6 +119,8 @@ fn tagged_releases_are_built_and_packaged_with_rust_tools() { "tags:", "runs-on: linux-arm64", "cargo-zigbuild", + "macos-linker-alias", + "-Lnative=target/macos-linker", "aarch64-apple-darwin", "x86_64-apple-darwin", "aarch64-unknown-linux-gnu",