Open cor3ntin opened 1 month ago
@llvm/issue-subscribers-clang-driver
Author: cor3ntin (cor3ntin)
This option was introduced before we even had tablegen driven options, which happened 15 years ago: https://github.com/llvm/llvm-project/commit/46fffee081b583a617fa94397b0c758bdf3a4a80
The option is used in the wild: https://sourcegraph.com/search?q=context:global+--target-help+-file:.*clang.*+-file:.*gcc.*+-file:resolve_march_native.*&patternType=keyword&sm=0
Perhaps we could remove the option and let users handle the "unknown option" diagnostic fallout, but we sometimes use noop flags for what GCC implements when it has no impact on program behavior, and this feels similar. However, it would be better for the option to do something rather than silently do nothing.
For context I use --help=target
(slightly less verbose than --target-help) with GCC to query which -m
options are included in march
, e.g.
$ gcc -march=znver3 --target-help -Q | grep 'enabled' | sort
-m128bit-long-double [enabled]
-m64 [enabled]
-m80387 [enabled]
-mabm [enabled]
-madx [enabled]
-maes [enabled]
-malign-stringops [enabled]
-mavx [enabled]
-mavx2 [enabled]
-mbmi [enabled]
-mbmi2 [enabled]
-mclflushopt [enabled]
-mclwb [enabled]
-mclzero [enabled]
-mcrc32 [enabled]
-mcx16 [enabled]
-mf16c [enabled]
-mfancy-math-387 [enabled]
-mfma [enabled]
-mfp-ret-in-387 [enabled]
-mfsgsbase [enabled]
-mfxsr [enabled]
-mglibc [enabled]
-mhard-float [enabled]
-mieee-fp [enabled]
-mlong-double-80 [enabled]
-mlzcnt [enabled]
...
This is how I originally found that the option does nothing with Clang.
Clang would definitely benefit from this. Several times I had to look deep in Clang's source to find out details about specific target options.
We declare a
--target-help
inDriver/Options.td
that is not used anywhere (but of course it shows up in the doc and is not treated as an unknown flag)Note that GCC does have that flag, which does something useful https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-target-help