You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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 getIllegal instruction (core dumped)
.objdump -f hello
reveals that the architecture of the produced binary isarmv7
, anduname -m
on Pi Zero W reportsamrv6l
,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
gives:
=
instead ofzig: 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?
The text was updated successfully, but these errors were encountered: