Skip to content

onig-sys linking error when building a dylib for iOS in Rust 2024 edition #584

@tvanderstad

Description

@tvanderstad

I'm trying to update my project to Rust 2024 edition to take advantage of some libraries already using it. This requires me to update to at least 1.85, when the 2024 edition was stabilized. However, I have an issue compiling comrak on Rust 1.85 because, since 1.83, I am unable to link a dylib for iOS. To reproduce, I setup a minimal dylib with comrak as a dependency. Here's the cargo.toml...

[package]
name = "comrak-test"
version = "0.1.0"
edition = "2024"

[lib]
crate-type = ["dylib"]

[dependencies]
comrak = { version = "0.40.0" }

...here's src/lib.rs...

pub use comrak;

...and here's my experience trying to build it...

# all good on edition 2021, but fails on edition 2024 because it's not stabilized until 1.85
rustup default 1.82
rustup target add aarch64-apple-ios
cargo build --lib --target=aarch64-apple-ios

# fails with a linking error
rustup default 1.85
rustup target add aarch64-apple-ios
cargo build --lib --target=aarch64-apple-ios

The linking error comes from onig-sys, an optional dependency of syntect wrapping a C library, which is an optional depdency of comrak that I need to power syntax highlighting in my app:

error: linking with `cc` failed: exit status: 1
<...>
          Undefined symbols for architecture arm64:
            "___chkstk_darwin", referenced from:
                _match_at in libonig_sys-f5897dda03689817.rlib[4](a445302c6d3dcb51-regexec.o)
                _disable_noname_group_capture in libonig_sys-f5897dda03689817.rlib[8](a445302c6d3dcb51-regcomp.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions