Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

zig cc can't accept -- in args #14837

Open
iacore opened this issue Mar 8, 2023 · 10 comments
Open

zig cc can't accept -- in args #14837

iacore opened this issue Mar 8, 2023 · 10 comments
Labels
bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig cc Zig as a drop-in C compiler feature
Milestone

Comments

@iacore
Copy link
Contributor

iacore commented Mar 8, 2023

Zig Version

0.11.0-dev.1898+36d47dd19

Steps to Reproduce and Observed Behavior

> echo "int main() {}" > program.c

> zig cc -- program.c
error: Unknown Clang option: '--'

> clang -- program.c
# success

Expected Behavior

It should parse like clang. args after -- are not flags.

@iacore iacore added the bug Observed behavior contradicts documented or intended behavior label Mar 8, 2023
@ghost
Copy link

ghost commented Mar 8, 2023

Are you sure that's actually how clang works? I ran clang -- -program.c where -program.c exists and it said:

error: unknown argument: '-program.c'

@iacore
Copy link
Contributor Author

iacore commented Mar 8, 2023

-program.c should be a file name, if your C file starts with -.

@ghost
Copy link

ghost commented Mar 8, 2023

Yes, clang for me shows that error message when -program.c is the name of a C source file. My clang version is 15.0.7, what version are you on?

@iacore
Copy link
Contributor Author

iacore commented Mar 8, 2023

Yes, clang for me shows that error message when -program.c is the name of a C source file. My clang version is 15.0.7, what version are you on?

I gave a bad example. What about clang -- program.c

@ghost
Copy link

ghost commented Mar 9, 2023

Strange, I've found that actually clang for me does process the -- as expected, even with -program.c... but only if -program.c doesn't exist.

clang -- -program.c where -program.c doesn't exist:

clang-15: error: no such file or directory: '-program.c'
clang-15: error: no input files

clang -- -program.c where it does exist:

error: unknown argument: '-program.c'

@iacore
Copy link
Contributor Author

iacore commented Mar 9, 2023

Did we find a bug in clang?

@ghost
Copy link

ghost commented Mar 10, 2023

I dunno, seems like it 🤷

@andrewrk
Copy link
Member

This is not demonstrated to be a bug yet. Please improve the bug report

@andrewrk andrewrk closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2023
@andrewrk andrewrk removed the bug Observed behavior contradicts documented or intended behavior label Apr 10, 2023
@iacore
Copy link
Contributor Author

iacore commented Apr 11, 2023

This is not demonstrated to be a bug yet. Please improve the bug report

Updated

@andrewrk andrewrk reopened this Apr 11, 2023
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig cc Zig as a drop-in C compiler feature labels Jul 23, 2023
@andrewrk andrewrk added this to the 0.12.0 milestone Jul 23, 2023
@andrewrk andrewrk modified the milestones: 0.14.0, 0.16.0 Aug 8, 2024
@hadeutscher
Copy link

Hey,

Why doesn't zigcc accept the -- delimiter?

While this isn't technically a bug, it does cause quite a lot of trouble for the rest of the community - for example, the Rust cc crate has special-case handling for the zig compiler which removes the -- delimiter, which breaks every once in a while, such as yesterday, and wreaks havoc on projects built using the dist framework (which uses zigcc internally for cross-compiling aarch64 targets).

Also, clang accepts this delimiter, so if zigcc aims to be a drop-in replacement for clang, it really is a bug.

Seeing as you already wrote the pull request that fixes this, maybe we can just get that one merged and be over with this?

Thanks

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants