Skip to content

CPU features are not passed to clang when assembling #10411

Open
@silversquirl

Description

@silversquirl

Zig Version

0.10.0-dev.40+303bad998

Steps to Reproduce

Create an ARM assembly file named test.s with the following contents:

mov r1, #0

Compile that file to an object using zig build-obj --verbose-cc -target arm-freestanding -mcpu cortex_m0plus+thumb2 test.s

Expected Behavior

Zig passes the +thumb2 option to clang, which correctly assembles the thumb2 instruction (though this particular CPU feature won't work until llvm/llvm-project#52878 is fixed).

Actual Behavior

The +thumb2 feature is not passed to zig clang:

$ zig build-obj --verbose-cc -target arm-freestanding -mcpu cortex_m0plus+thumb2 test.s
/home/silver/.opt/zig/zig clang -fno-caret-diagnostics -target arm-unknown-unknown-eabi -mcpu=cortex-m0plus -ffreestanding -c -o /home/silver/.cache/zig/tmp/c60723f3c667529f-test.o test.s
error(compilation): clang failed with stderr: zig: warning: argument unused during compilation: '-fno-caret-diagnostics' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-ffreestanding' [-Wunused-command-line-argument]
test.s:1:1: error: invalid instruction, any one of the following would fix this:
mov r1, #0
^
test.s:1:9: note: operand must be a register in range [r0, r15]
mov r1, #0
        ^
test.s:1:1: note: instruction requires: thumb2
mov r1, #0
^

test.s:1:1: error: unable to build C object: clang exited with code 1

Metadata

Metadata

Assignees

Labels

enhancementSolving this issue will likely involve adding new logic or components to the codebase.upstreamAn issue with a third party project that Zig uses.zig ccZig as a drop-in C compiler feature

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions