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

zig cc: No way to pass -mcpu flag #4875

Closed
soulthreads opened this issue Mar 31, 2020 · 1 comment
Closed

zig cc: No way to pass -mcpu flag #4875

soulthreads opened this issue Mar 31, 2020 · 1 comment

Comments

@soulthreads
Copy link

After reading the recent post on zig cc I've got really excited, and decided to try it out to cross-compile some apps for a Raspberry Pi Zero W I have laying around.

zig cc hello.c -target arm-linux-musleabihf and everything seems OK so far.
After scp-ing the executable to the Pi however, I immediately get
Illegal instruction (core dumped).

objdump -f hello reveals that the architecture of the produced binary is armv7, and uname -m on Pi Zero W reports amrv6l,
so I thought that specifying -target armv6l-linux-musleabihf would work, but it doesn't:
invalid target: unrecognized architecture.
Neither does -target armv6-linux-musleabihf or any other combination.

Zig has a command-line option -mcpu, and in fact, if I build a .zig file like so:
zig build-exe hello.zig -target arm-linux -mcpu arm1176jzf_s
I get a binary that works on my Pi Zero W.
(By the way, there doesn't seem to be a way to specify -mcpu when using zig build as well, but that's probably a separate issue)

However, if I try to use that in cc mode:
zig cc hello.c -target arm-linux-musleabihf -mcpu arm1176jzf_s
I get this:
Unknown Clang option: '-mcpu'

Using = instead of gives:
zig: error: the clang compiler does not support '-mcpu=arm1176jzf_s'

So I'm a bit lost here.
What's the proper way to pass -mcpu flag to clang?

@soulthreads
Copy link
Author

Welp, it looks like #4784 and #4584 are exactly about this problem. Sorry for the noise.

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

1 participant