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 -mcpu=? is pass-thru to clang driver and lists cpu model names incompatible with zig targets #9988

Closed
iacore opened this issue Oct 20, 2021 · 4 comments
Labels
bug Observed behavior contradicts documented or intended behavior zig cc Zig as a drop-in C compiler feature
Milestone

Comments

@iacore
Copy link
Contributor

iacore commented Oct 20, 2021

Zig Version

0.9.0-dev.1433+4a76523b9

Steps to Reproduce

zig cc -o ./pony -O3 -march=x86-64 pony.o

Any object file will work.

Expected Behavior

The program should compile. clang does work with the same arguments.

Actual Behavior

> zig cc -o ./pony -O3 -march=x86-64 pony.o
info: Available CPUs for architecture 'x86_64':
...
 x86_64
 x86_64_v2
 x86_64_v3
 x86_64_v4
...

error: Unknown CPU: 'x86'
@iacore iacore added the bug Observed behavior contradicts documented or intended behavior label Oct 20, 2021
@iacore
Copy link
Contributor Author

iacore commented Oct 20, 2021

Using zig cc "-mcpu=?" does yield the "dash versions" of CPU architectures

        x86-64
        x86-64-v2
        x86-64-v3
        x86-64-v4

This bug seems to be of command line parsing

@mikdusan
Copy link
Member

use -march=x86_64 instead

zig cannot use "hyphenation" in the cpu name because we allow fine-grained feature flags appended after model name using + or -. eg: -march=x86_64-sse2 disables sse2

Unfortunately, the special case -mcpu=? is pass-thru to clang driver, and clang is listing the cpu models according to its own naming. Ideally, we'd want to intercept, and emit zig's cpu model list, ie. the same output as shown by zig cc -c foo.c -mcpu=bogus

@mikdusan mikdusan added bug Observed behavior contradicts documented or intended behavior and removed bug Observed behavior contradicts documented or intended behavior labels Oct 20, 2021
@mikdusan mikdusan changed the title zig cc -mcpu? doesn't match -march zig cc -mcpu=? is pass-thru to clang driver and lists cpu model names incompatible with zig targets Oct 20, 2021
@Deecellar
Copy link
Contributor

Deecellar commented Oct 25, 2021

use -march=x86_64 instead

zig cannot use "hyphenation" in the cpu name because we allow fine-grained feature flags appended after model name using + or -. eg: -march=x86_64-sse2 disables sse2

Unfortunately, the special case -mcpu=? is pass-thru to clang driver, and clang is listing the cpu models according to its own naming. Ideally, we'd want to intercept, and emit zig's cpu model list, ie. the same output as shown by zig cc -c foo.c -mcpu=bogus

This is a non solution for already existing codebases like meson based build. where is not valid to pass as an option x86_64

@andrewrk andrewrk added the zig cc Zig as a drop-in C compiler feature label Nov 20, 2021
@andrewrk andrewrk added this to the 0.9.0 milestone Nov 20, 2021
@andrewrk
Copy link
Member

Duplicate of #4911

@andrewrk andrewrk marked this as a duplicate of #4911 Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

No branches or pull requests

4 participants