Skip to content
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

No backtrace symbols on MacOS w/ Apple Silicon #204

Closed
ramosbugs opened this issue Dec 14, 2023 · 4 comments
Closed

No backtrace symbols on MacOS w/ Apple Silicon #204

ramosbugs opened this issue Dec 14, 2023 · 4 comments

Comments

@ramosbugs
Copy link

I originally filed this issue as cargo-lambda/cargo-lambda#577, but the issue is probably more closely tied to Zig.

I'm building a Lambda function by invoking:

$ RUSTFLAGS="-C strip=none" cargo lambda build --arm64

I'm running on ARM64 MacOS:

$ uname -a
Darwin Ramos-M1 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64

As expected, this produces a binary that appears to contain debug symbols:

$ file ../../target/lambda/bootstrap/bootstrap 
../../target/lambda/bootstrap/bootstrap: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 2.0.0, with debug_info, not stripped

However, all of the backtraces I generate via the backtrace crate look like:

 0: <unknown>    
 1: <unknown>    
...
31: <unknown>    
32: __libc_start_call_main    
33: __libc_start_main_impl

Panics with RUST_BACKTRACE=1 are similarly empty:

thread 'main' panicked at 'not yet implemented', src/lib.rs:173:5
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Interestingly, everything works fine when I directly build the Lambda via the Homebrew musl-cross toolchain:

$ export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc
$ cargo build --target aarch64-unknown-linux-musl --release

Even in release mode, the Lambda built with musl-cross prints backtrace symbols.

Is there a known issue in cargo-zigbuild with debug symbols when cross-compiling from aarch64 Darwin to aarch64 Linux?

@messense
Copy link
Member

messense commented Dec 14, 2023

This has came up before in #6, the underlying problem should have been fixed in ziglang/zig#11207, I don't know if it's a regression from zig.

@ramosbugs
Copy link
Author

The output of the file command on the binary shows with debug_info, not stripped. Are you sure it's the same issue?

@messense
Copy link
Member

messense commented Dec 14, 2023

The output of the file command on the binary shows with debug_info, not stripped.

That's because in #6 we added -g flag.

I'm not saying it's the same issue, just that the missing debuginfo issue was fixed in #6 and zig, so if backtrace is empty, it might be a zig issue/regression assuming you are not using a super old zig version.

@ramosbugs
Copy link
Author

Thanks, I filed this issue as ziglang/zig#18280.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants