Skip to content

Commit

Permalink
Add libcharset.1.tbd for Apple targets
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Sep 9, 2023
1 parent 91221c4 commit fb2f06f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
25 changes: 25 additions & 0 deletions src/macos/libcharset.1.tbd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--- !tapi-tbd
tbd-version: 4
targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst,
arm64e-macos, arm64e-maccatalyst ]
uuids:
- target: x86_64-macos
value: 5B967C5A-B6AC-322F-B731-4D653B8462B8
- target: x86_64-maccatalyst
value: 5B967C5A-B6AC-322F-B731-4D653B8462B8
- target: arm64-macos
value: 00000000-0000-0000-0000-000000000000
- target: arm64-maccatalyst
value: 00000000-0000-0000-0000-000000000000
- target: arm64e-macos
value: A83762DF-A611-3148-9926-C0874266E926
- target: arm64e-maccatalyst
value: A83762DF-A611-3148-9926-C0874266E926
install-name: '/usr/lib/libcharset.1.dylib'
current-version: 2
compatibility-version: 2
exports:
- targets: [ arm64e-macos, x86_64-macos, x86_64-maccatalyst, arm64e-maccatalyst,
arm64-macos, arm64-maccatalyst ]
symbols: [ _libcharset_set_relocation_prefix, _locale_charset ]
...
2 changes: 2 additions & 0 deletions src/macos/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/// libiconv.tbd
pub static LIBICONV_TBD: &str = include_str!("libiconv.tbd");
/// libcharset.tbd
pub static LIBCHARSET_TBD: &str = include_str!("libcharset.1.tbd");
11 changes: 9 additions & 2 deletions src/zig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use serde::Deserialize;
use target_lexicon::{Architecture, Environment, OperatingSystem, Triple};

use crate::linux::ARM_FEATURES_H;
use crate::macos::LIBICONV_TBD;
use crate::macos::{LIBCHARSET_TBD, LIBICONV_TBD};

/// Zig linker wrapper
#[derive(Clone, Debug, clap::Subcommand)]
Expand Down Expand Up @@ -246,6 +246,11 @@ impl Zig {
new_cmd_args.push("-Wl,-undefined=dynamic_lookup".to_string());
}
if is_macos {
// See https://github.com/apple-oss-distributions/libiconv/blob/a167071feb7a83a01b27ec8d238590c14eb6faff/xcodeconfig/libiconv.xcconfig
if cmd_args.iter().any(|x| x == "-liconv") && !cmd_args.iter().any(|x| x == "-lcharset")
{
new_cmd_args.push("-lcharset".to_string());
}
if let Some(sdkroot) = Self::macos_sdk_root() {
let sdkroot = Path::new(&sdkroot);
new_cmd_args.extend_from_slice(&[
Expand Down Expand Up @@ -560,7 +565,7 @@ impl Zig {
let glibc_minor_ver = if let Some(start) = stderr.find("__GLIBC_MINOR__=") {
let stderr = &stderr[start + 16..];
let end = stderr
.find(|c| !matches!(c, '0'..='9'))
.find(|c: char| !c.is_ascii_digit())
.unwrap_or(stderr.len());
stderr[..end].parse().ok()
} else {
Expand Down Expand Up @@ -776,6 +781,8 @@ impl Zig {
let deps_dir = target_dir.join(profile).join("deps");
fs::create_dir_all(&deps_dir)?;
fs::write(deps_dir.join("libiconv.tbd"), LIBICONV_TBD)?;
fs::write(deps_dir.join("libcharset.1.tbd"), LIBCHARSET_TBD)?;
fs::write(deps_dir.join("libcharset.tbd"), LIBCHARSET_TBD)?;
} else if target.contains("arm") && target.contains("linux") {
// See https://github.com/ziglang/zig/issues/3287
if let Ok(lib_dir) = Zig::lib_dir() {
Expand Down
4 changes: 2 additions & 2 deletions tests/hello-rustls/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fb2f06f

Please sign in to comment.