-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Description
I happened to see something about the "--target" command-line flag in the Clang compiler. Previously, I wanted to run a command that would generate code for a specific target during compilation, but that didn't go smoothly and led me here.
Below are four uses of the flag, half of which fail. Pay particular attention to the use of the number of dashes and the equal signs.
$ clang --target=x86_64-unknown-linux-gnu hello.c
$ ./a.out
Hello, World$ clang --target x86_64-unknown-linux-gnu hello.c
clang: error: unknown argument '--target'; did you mean '-target'?
clang: error: no such file or directory: 'x86_64-unknown-linux-gnu'$ clang -target x86_64-unknown-linux-gnu hello.c
$ ./a.out
Hello, World$ clang -target=x86_64-unknown-linux-gnu hello.c
clang: error: unknown argument '-target=x86_64-unknown-linux-gnu'; did you mean '--target=x86_64-unknown-linux-gnu'?It's striking how the second example suggests using "-target", when the way I used the flag is exactly the documented way, at least as far as the double hyphens are concerned. I also find it striking that "--target" works with an equals sign, but not without, while "-target" works the other way around, because it doesn't work with the equals sign, but does work without it.
For example, the "--config" flag is documented in the same way, but works with and without the equals sign.
I definitely wanted to share this because I'm not sure if this is intentional.