llvm-project/clang/lib/Driver/ToolChains
Zachary Turner a0f96be9b1 [clang-cl] Fix cross-compilation with MSVC 2017.
clang-cl works best when the user runs vcvarsall to set up
an environment before running, but even this is not enough
on VC 2017 when cross compiling (e.g. using an x64 toolchain
to target x86, or vice versa).

The reason is that although clang-cl itself will have a
valid environment, it will shell out to other tools (such
as link.exe) which may not.  Generally we solve this through
adding the appropriate linker flags, but this is not enough
in VC 2017.

The cross-linker and the regular linker both link against
some common DLLs, but these DLLs live in the binary directory
of the native linker.  When setting up a cross-compilation
environment through vcvarsall, it will add *both* directories
to %PATH%, so that when cl shells out to any of the associated
tools, those tools will be able to find all of the dependencies
that it links against.  If you don't do this, link.exe will
fail to run because the loader won't be able to find all of
the required DLLs that it links against.

To solve this we teach the driver how to spawn a process with
an explicitly specified environment.  Then we modify the
PATH before shelling out to subtools and run with the modified
PATH.

Patch by Hamza Sood
Differential Revision: https://reviews.llvm.org/D30991

llvm-svn: 298098
2017-03-17 16:24:34 +00:00
..
Arch Test commit. 2017-03-17 15:38:49 +00:00
AMDGPU.cpp
AMDGPU.h
AVR.cpp
AVR.h
Bitrig.cpp
Bitrig.h
Clang.cpp enable -save-temps with -finclude-defult-header 2017-03-15 20:57:11 +00:00
Clang.h
CloudABI.cpp
CloudABI.h
CommonArgs.cpp [Driver] Add flag to request arch-specific-subdir in -rpath 2017-03-14 16:58:07 +00:00
CommonArgs.h
Contiki.cpp
Contiki.h
CrossWindows.cpp
CrossWindows.h
Cuda.cpp
Cuda.h
Darwin.cpp [Driver] Define macro __APPLE_EMBEDDED_SIMULATOR__ when option 2017-03-15 18:04:13 +00:00
Darwin.h
DragonFly.cpp
DragonFly.h
FreeBSD.cpp
FreeBSD.h
Fuchsia.cpp
Fuchsia.h
Gnu.cpp
Gnu.h
Haiku.cpp Driver/ToolChains: Remove extra semicolons. NFC 2017-03-09 00:14:57 +00:00
Haiku.h
Hexagon.cpp
Hexagon.h
Lanai.h
Linux.cpp
Linux.h
MSVC.cpp [clang-cl] Fix cross-compilation with MSVC 2017. 2017-03-17 16:24:34 +00:00
MSVC.h Fix uninitialized value. 2017-03-15 19:54:25 +00:00
MSVCSetupApi.h Update clang-cl driver for MSVC 2017. 2017-03-15 16:07:35 +00:00
MinGW.cpp
MinGW.h
Minix.cpp
Minix.h
MipsLinux.cpp Driver/ToolChains: Mips -> MipsLinux 2017-03-08 22:36:04 +00:00
MipsLinux.h Driver/ToolChains: Mips -> MipsLinux 2017-03-08 22:36:04 +00:00
Myriad.cpp
Myriad.h
NaCl.cpp
NaCl.h
NetBSD.cpp
NetBSD.h
OpenBSD.cpp
OpenBSD.h
PS4CPU.cpp
PS4CPU.h
Solaris.cpp
Solaris.h
TCE.cpp Driver/ToolChains: Remove extra semicolons. NFC 2017-03-09 00:14:57 +00:00
TCE.h
WebAssembly.cpp
WebAssembly.h
XCore.cpp Driver/ToolChains: Remove extra semicolons. NFC 2017-03-09 00:14:57 +00:00
XCore.h