ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.82k stars 2.47k forks source link

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

Open iacore opened 1 year ago

iacore commented 1 year ago

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.

ghost commented 1 year ago

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 commented 1 year ago

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

ghost commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Did we find a bug in clang?

ghost commented 1 year ago

I dunno, seems like it :shrug:

andrewrk commented 1 year ago

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

iacore commented 1 year ago

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

Updated