This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by thakis on Sep 11 2019, 12:12 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

thakis created this revision.Sep 11 2019, 12:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 11 2019, 12:12 PM
ruiu accepted this revision.Sep 13 2019, 3:38 AM

LGTM

This revision is now accepted and ready to land.Sep 13 2019, 3:38 AM
This revision was automatically updated to reflect the committed changes.