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

introduce the concept of conflicting CPU features #12227

Open
andrewrk opened this issue Jul 25, 2022 · 1 comment
Open

introduce the concept of conflicting CPU features #12227

andrewrk opened this issue Jul 25, 2022 · 1 comment
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@andrewrk
Copy link
Member

Extracted from #12220.

$ stage3/bin/zig build-exe empty.zig -target x86_64-freestanding-none -mcpu=x86_64+soft_float
thread 427475 panic: Illegal instruction at address 0x5c6d154

As pointed out in llvm/llvm-project#56351 (comment), +x87 and +soft_float is a pair of contradictory options. However, Zig currently has no way to denote such contradictions, meaning that a user might easily run into that problem above, and not realize that they could do this:

$ stage3/bin/zig build-exe empty.zig -target x86_64-freestanding-none -mcpu=x86_64+soft_float-x87-sse2-sse
$

This issue is to introduce a field to std.Target.Cpu.Feature for storing conflicts with other features, and then do one of two things:

  • introduce a new compile error that occurs when conflicting features are activated
  • update the handling of CPU feature sets to automatically remove conflicting features. For example, when +soft_float is encountered, zig would infer to automatically do -x87 -sse -sse2.
@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Jul 25, 2022
@andrewrk andrewrk added this to the 0.12.0 milestone Jul 25, 2022
@ominitay
Copy link
Contributor

Perhaps we should do both? If a feature conflicts with a default feature, then we know to disable the default feature. If two explicitly-provided features are passed, then we throw an error, since we can't know which feature the user actually intends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

2 participants