llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.92k stars 11.52k forks source link

Unused `--target-help` option #102370

Open cor3ntin opened 1 month ago

cor3ntin commented 1 month ago

We declare a --target-help in Driver/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

llvmbot commented 1 month ago

@llvm/issue-subscribers-clang-driver

Author: cor3ntin (cor3ntin)

We declare a `--target-help` in `Driver/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
AaronBallman commented 1 month ago

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.

horenmar commented 1 month ago

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.

insilications commented 2 weeks ago

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.