[llvm-dev] [lld] Reject some lld specific one-dash long options

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Wed Jul 29 10:21:48 PDT 2020


This email and the review didn't seem to mention a clause included in
the final commit:

"Some changed options are also used by gold, but I haven't seen their
one-dash use cases outside of lld's testsuite."

& I think there's a couple of issues with this particular patch, FWIW
- backwards compatibility with lld is still a thing. Deprecation
might've been more suitable - giving folks time to opt-out (usually
it's easier for a build system to add a flag (such as from global
LD_FLAGS, etc) to turn off warnings temporarily than it is to change
the flags used inside a build) for any existing spellings. While
certainly having a policy for all new flags going forward seems great.

But compatibility with gold seems valuable too & wasn't mentioned &
wasn't in the review - but added post-review. That seems like a
slightly different discussion (I'd say three groups: New flags,
existing lld-only flags, existing cross-linker flags (& I guess you've
split that in two groups - bfd+lld flags and gold+lld flags, which is
a fair point - gold, I believe, has fewer users than bfd))

(just came across this when I went to use a newer lld and had to
change my -Wl,-gdb-index to -Wl,--gdb-index)

On Tue, May 5, 2020 at 4:02 PM Fangrui Song via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> GNU ld supports most long options with either one or two dashes.  For
> compatibility, lld has to support both.
>
> For newer and lld specific options, we don't have such compatibility
> problem.  I'd suggest we reject one-dash long options to avoid collision
> with short options. For example,
>
> * -lto-emit-obj can be read as -l to-emit-obj
> * -thinlto-cache-dir= means -t -h inlto-cache-dir= in GNU ld
>
> I created a patch https://reviews.llvm.org/D79371 to disallow some
> one-dash long options. These options are carefully chosen: I can't find
> anything depending on their one-dash forms.
>
> lld has a spell corrector for option names so a misspelled -lto-emit-obj can be
> identified quickly.
>
>
> Thoughts?
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list