Fix ORT linking for macOS cross-builds.
This commit is contained in:
@@ -47,8 +47,8 @@ jobs:
|
|||||||
runs-on: linux-arm64
|
runs-on: linux-arm64
|
||||||
container: ghcr.io/rust-cross/cargo-zigbuild@sha256:82af75c41958c2af2787e8bedd912da7678a9438937e223e9d83d006d747b38b
|
container: ghcr.io/rust-cross/cargo-zigbuild@sha256:82af75c41958c2af2787e8bedd912da7678a9438937e223e9d83d006d747b38b
|
||||||
env:
|
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_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: -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:
|
steps:
|
||||||
- name: Check out the tag
|
- name: Check out the tag
|
||||||
env:
|
env:
|
||||||
@@ -78,6 +78,8 @@ jobs:
|
|||||||
RELEASE_ID: ${{ needs.prepare-release.outputs.release_id }}
|
RELEASE_ID: ${{ needs.prepare-release.outputs.release_id }}
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
|
cargo +${RUST_TOOLCHAIN} run --locked --package bds-release -- \
|
||||||
|
macos-linker-alias target/macos-linker
|
||||||
for build in \
|
for build in \
|
||||||
'aarch64-apple-darwin|aarch64-apple-darwin|darwin-arm64' \
|
'aarch64-apple-darwin|aarch64-apple-darwin|darwin-arm64' \
|
||||||
'x86_64-apple-darwin|x86_64-apple-darwin|darwin-x64'
|
'x86_64-apple-darwin|x86_64-apple-darwin|darwin-x64'
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
match args.as_slice() {
|
match args.as_slice() {
|
||||||
[command] if command == "prepare" => gitea::prepare(),
|
[command] if command == "prepare" => gitea::prepare(),
|
||||||
[command] if command == "publish" => gitea::publish(),
|
[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() => {
|
[command, paths @ ..] if command == "upload" && !paths.is_empty() => {
|
||||||
gitea::upload(paths.iter().map(Path::new))
|
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()))
|
gitea::upload(assets.iter().map(|path| path.as_path()))
|
||||||
}
|
}
|
||||||
_ => Err(
|
_ => 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(),
|
.into(),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,12 @@ const LC_REEXPORT_DYLIB: u32 = 0x8000_001f;
|
|||||||
const LC_LAZY_LOAD_DYLIB: u32 = 0x20;
|
const LC_LAZY_LOAD_DYLIB: u32 = 0x20;
|
||||||
const LC_LOAD_UPWARD_DYLIB: u32 = 0x8000_0023;
|
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)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
enum Platform {
|
enum Platform {
|
||||||
MacOs,
|
MacOs,
|
||||||
@@ -460,6 +466,17 @@ mod tests {
|
|||||||
assert_eq!(dmg_sectors(1).unwrap(), 131_072);
|
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]
|
#[test]
|
||||||
fn windows_package_contains_the_app_without_dynamic_std() {
|
fn windows_package_contains_the_app_without_dynamic_std() {
|
||||||
let temp = tempdir().unwrap();
|
let temp = tempdir().unwrap();
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ fn tagged_releases_are_built_and_packaged_with_rust_tools() {
|
|||||||
"tags:",
|
"tags:",
|
||||||
"runs-on: linux-arm64",
|
"runs-on: linux-arm64",
|
||||||
"cargo-zigbuild",
|
"cargo-zigbuild",
|
||||||
|
"macos-linker-alias",
|
||||||
|
"-Lnative=target/macos-linker",
|
||||||
"aarch64-apple-darwin",
|
"aarch64-apple-darwin",
|
||||||
"x86_64-apple-darwin",
|
"x86_64-apple-darwin",
|
||||||
"aarch64-unknown-linux-gnu",
|
"aarch64-unknown-linux-gnu",
|
||||||
|
|||||||
Reference in New Issue
Block a user