Skip to content

Add libcharset.1.tbd for Apple targets #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
13 changes: 11 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,13 @@ 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 (zig_version.major, zig_version.minor) >= (0, 12)
&& 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 +567,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 +783,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.