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

[MacOS] Rosetta 2 refuses to run Virgil x86-64-darwin binaries #60

Open
titzer opened this issue Jul 2, 2022 · 3 comments
Open

[MacOS] Rosetta 2 refuses to run Virgil x86-64-darwin binaries #60

titzer opened this issue Jul 2, 2022 · 3 comments

Comments

@titzer
Copy link
Owner

titzer commented Jul 2, 2022

I recently ported Virgil to x86-64-darwin, i.e. 64-bit MacOS on Intel. I expected that the binaries generated would work automatically under Rosetta 2, but they apparently do not.

I could some help debugging some issues.

% aeneas bootstrap
% cd apps/HelloWorld/
% v3c-x86-64-darwin -output=/tmp HelloWorld.v3 
% /tmp/HelloWorld 
rosetta error: /tmp/HelloWorld: overlapping Mach-O segments
Trace/BPT trap: 5
%

Tinkering with the segment layouts in aeneas/src/x86-64/X86_64Darwin.v3 can get past that, but other errors remain. I am not sure what the rules are for Rosetta.

@bjorn3
Copy link

bjorn3 commented Jul 2, 2022

I believe Rosetta 2 requires executables to use PIC (position independent code). PIE and fixed addresses are not supported I think. At least when linking a non-PIC executable you get the following warning: ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in ... from ...o. To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie

@titzer
Copy link
Owner Author

titzer commented Jul 2, 2022

Thanks for that info! That makes sense. It's a bit of work to figure out how to emit linker tables and such on MacOS.

@titzer
Copy link
Owner Author

titzer commented Jul 14, 2022

Steps to reproduce:

  1. clone the repo
  2. Run bin/dev/aeneas bootstrap
  3. Run bin/dev/v3c-x86-64-darwin -output=/tmp apps/HelloWorld/*.v3
  4. Run /tmp/HelloWord

The current error I get is "overlapping segments" but even rearranging the segments in the binary, I cannot get the program to start.

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

No branches or pull requests

2 participants