Fix ORT linking for macOS cross-builds.
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -8,6 +8,9 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
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<dyn Error>> {
|
||||
gitea::upload(assets.iter().map(|path| path.as_path()))
|
||||
}
|
||||
_ => Err(
|
||||
"usage: bds-release prepare|publish|upload <asset>...|package <tag> <release-dir> <rust-lib-dir> <platform> <dist-dir> [--upload]"
|
||||
"usage: bds-release prepare|publish|macos-linker-alias <directory>|upload <asset>...|package <tag> <release-dir> <rust-lib-dir> <platform> <dist-dir> [--upload]"
|
||||
.into(),
|
||||
),
|
||||
}
|
||||
|
||||
@@ -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<dyn Error>> {
|
||||
fs::create_dir_all(directory)?;
|
||||
fs::write(directory.join("libclang_rt.osx.a"), b"!<arch>\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"!<arch>\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_package_contains_the_app_without_dynamic_std() {
|
||||
let temp = tempdir().unwrap();
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user