Skip to content

Build script binaries crash with "dyld: malformed mach-o image: missing LC_DYSYMTAB" on macOS 10.15 when "strip = true" #119793

Closed
@RandomInsano

Description

@RandomInsano

It seems that on macOS 10.15, when enabling symbol stripping in Cargo.toml with strip = true the build scripts fail to execute with the following:

error: failed to run custom build command for `libc v0.2.152`

Caused by:
  process didn't exit successfully: `/Users/me/Documents/Code/rust/others/repro/target/problem/build/libc-0c18316fbaf15a0a/build-script-build` (signal: 6, SIGABRT: process abort signal)
  --- stderr
  dyld: malformed mach-o image: missing LC_DYSYMTAB

Here's the minimal reproducible test case

cargo new --bin repro
cd repro
cat >> Cargo.toml <<EOF
[profile.problem]
inherits = "release"
strip = true
EOF
cargo add libc
cargo build --profile problem # Fails
cargo build --release # Works fine

I expected to see this happen: I expected proper compilation and execution of stripped binaries.

Instead, this happened: It dun when kaboom.

Meta

I tested these versions:

$ cargo +nightly --version --verbose
cargo 1.77.0-nightly (2ce45605d 2024-01-04)
release: 1.77.0-nightly
commit-hash: 2ce45605d9db521b5fd6c1211ce8de6055fdb24e
commit-date: 2024-01-04
host: x86_64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 7.64.1 (sys:0.4.70+curl-8.5.0 system ssl:(SecureTransport) LibreSSL/2.8.3)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 10.15.7 [64-bit]

$ cargo +stable --version --verbose
cargo 1.75.0 (1d8b05cdd 2023-11-20)
release: 1.75.0
commit-hash: 1d8b05cdd1287c64467306cf3ca2c8ac60c11eb0
commit-date: 2023-11-20
host: x86_64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 7.64.1 (sys:0.4.68+curl-8.4.0 system ssl:(SecureTransport) LibreSSL/2.8.3)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Mac OS 10.15.7 [64-bit]

Backtrace wasn't helpful as this is a lower-level problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)O-macosOperating system: macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions