Fix ORT linking for macOS cross-builds.

This commit is contained in:
Hermes Agent
2026-08-14 11:14:49 +00:00
parent 0d1f63e77f
commit 7fa37ddf6e
4 changed files with 27 additions and 3 deletions

View File

@@ -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(),
),
}

View File

@@ -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();