lld-link: Add a flag /lldignoreenv that makes lld-link ignore env vars.
authorNico Weber <nicolasweber@gmx.de>
Fri, 13 Sep 2019 13:13:52 +0000 (13:13 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 13 Sep 2019 13:13:52 +0000 (13:13 +0000)
commitd48ea5da94165dbaba14b1281b74994fe970a7e0
tree0f6a7804b6c93c6a00939ef6feb34b713ab1d9e8
parent67503ba556cd4008179491db6d024ec0f9d9c9cd
lld-link: Add a flag /lldignoreenv that makes lld-link ignore env vars.

This is useful for enforcing that builds are independent of the
environment; it can be used when all system library paths are added
via /libpath: already. It's similar ot cl.exe's /X flag.

Since it should also affect %LINK% (the other caller of
`Process::GetEnv` in lld/COFF), the early-option-parsing needs
to move around a bit. The options are:

- Add a manual loop over the argv ArrayRef and look for "/lldignoreenv".
  This repeats the name of the flag in both Options.td and in
  DriverUtils.cpp.

- Add yet another table.ParseArgs() call just for /lldignoreenv before
  adding %LINK%.

- Use the existing early ParseArgs() that's there for --rsp-quoting and use
  it for /lldignoreenv for %LINK% as well. This means --rsp-quoting
  and /lldignoreenv can't be passed via %LINK%.

I went with the third approach.

Differential Revision: https://reviews.llvm.org/D67456

llvm-svn: 371852
lld/COFF/Driver.cpp
lld/COFF/Driver.h
lld/COFF/DriverUtils.cpp
lld/COFF/Options.td
lld/docs/ReleaseNotes.rst
lld/test/COFF/libpath.test
lld/test/COFF/linkenv.test