HomePhabricator

lld-link: Add a flag /lldignoreenv that makes lld-link ignore env vars.

Authored by thakis on Sep 13 2019, 6:13 AM.

Description

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

Details