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

Compilation fails on macOS #200

Closed
Philanatidae opened this issue Jan 3, 2021 · 2 comments · Fixed by #201
Closed

Compilation fails on macOS #200

Philanatidae opened this issue Jan 3, 2021 · 2 comments · Fixed by #201

Comments

@Philanatidae
Copy link
Contributor

When attempting to add Backward to my C++ project on macOS, compilation fails with this error:

In file included from ../backward-cpp/backward.cpp:36:
../backward-cpp/backward.hpp:4160:60: error: member reference type 'struct __darwin_mcontext64 *' is a pointer; did you mean to use '->'?
    error_addr = reinterpret_cast<void *>(uctx->uc_mcontext.pc);
                                          ~~~~~~~~~~~~~~~~~^
                                                           ->
../backward-cpp/backward.hpp:4160:61: error: no member named 'pc' in '__darwin_mcontext64'
    error_addr = reinterpret_cast<void *>(uctx->uc_mcontext.pc);
                                          ~~~~~~~~~~~~~~~~~ ^

I'm able to reproduce this with a simple "Hello World" project. I'm unsure if this is caused by compiling on Big Sur or an issue compiling for the M1 chip (I'm running a 2020 Mac mini). I haven't dived too deep into this but wanted to report an issue to see if anybody has run into the same problem or knows of a solution. I pulled the latest from master.

@Philanatidae
Copy link
Contributor Author

It appears this is an issue when building for arm64 for M1 chips. In backward.hpp, with the population of the error address (if-else chain beginning on line 4153), __aarch64__ is defined since an ARM chip is being compiled. However, the error address is not uctx->uc_mcontext.pc for macOS. It is instead uctx->uc_mcontext->__ss.__pc. Adding a conditional for __APPLE__ and using uctx->uc_mcontext->__ss.__pc fixes the issue.

I've only tested compiling for Apple Silicon currently, I'll verify that this works in a Universal 2 binary and then I'll make a pull request.

@bombela
Copy link
Owner

bombela commented Jan 3, 2021 via email

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

Successfully merging a pull request may close this issue.

2 participants