Enable cross-static-lib generation for LLVM 3.9+#2030
Enable cross-static-lib generation for LLVM 3.9+#2030kinke merged 7 commits intoldc-developers:masterfrom
Conversation
237ecf3 to
eeb0c80
Compare
|
Replacing objects in existing libs (and keeping old non-replaced members) re-added. |
By directly integrating LLVM's `llvm-lib.exe` driver to generate static libs for MSVC targets and a stripped-down version of the `llvm-ar` tool for the other targets. Introduce command-line option `-archiver=<file>` to allow the user to specify an external archiver to be invoked.
|
|
For invoking MS tools such as link.exe and lib.exe, which require compatible PATH, LIB, LIBPATH etc. We previously wrapped the invokation of the tool with a batch file taking care of setting up the environment and then calling the actual tool. I changed this to first invoke another batch file setting up its environment and then dumping all environment variables to a file. LDC then parses this file and updates its own environment variables. Later spawned child processes then inherit the updated environment, and the tools will be located by LLVM in updated PATH. This allows LDC to keep track of the used Visual C++ installation (and could so set up additional runtime libs required since VS 2015, something we would have needed some time back when we still supported VS 2013). It's also required as a prerequisite for integrating LLD as in-process linker on Windows. I quickly looked into the option of setting up the environment manually, but the MS batch files are full of quirks, mixtures of registry and file-system lookups, checking for existence of misc. headers to filter out bogus installations etc. With VS 2017, there's nothing in the registry at all anymore (at least for the Build Tools); MS expose a COM interface for querying the VS installer... But at least they still provide the batch files.
|
The 3rd commit seems to work fine (has to be tested manually, AppVeyor uses a preset environment) and paves the way for integrating LLD. Enough for tonight though. ;) |
And get rid of redundant cmdline option -archiver.
And warn if no Visual C++ installation is detected, similar to the now suppressed warning issued by the batch file.
|
Interesting - this time the spurious OSX failure/segfault wasn't |
|
Any concerns? To me, this is currently mostly a shortcut for guys having to cross-link externally. Handling a single static lib instead of a multitude of objects is just more convenient. And for MSVC targets, I noticed that the static lib file size for a Phobos-hello-world is reduced by a very rough 10% [IIRC] compared to VS 2015 |
By directly integrating LLVM's
llvm-lib.exedriver to generate static libs for MSVC targets and a heavily stripped-down version of thellvm-artool for the other targets.For the moment, just testing if it basically works on Linux and OSX too (works fine here on Win64; able to produce libs for x86 and x86_64 Linux...) and which older LLVM versions aren't supported. I removed the
llvm-arlogic for modifying an existing lib (insertion order...), I guess it'll have to be put in again for the final implementation. :/