Letting CMake link the executable instead of really invoking the C++
compiler manually. This simplifies cross-compilation with CMake
toolchain files, such as for Android.
This serial step (unless using explicit -DCOMPILE_D_MODULES_SEPARATELY=ON,
which may decrease LDC performance due to missing cross-module
optimizations) used to take more than 4 minutes for Shippable...
This is a breaking ABI change and affects LDC itself as mixed D/C++ code
base. So we now need to check the front-end version of the D host
compiler and adapt the corresponding C++ types accordingly.
Some LLVM libs were missing from the linker flags for current LLVM 5.0.
It was only during troubleshooting that I noticed the MSVC special case in
FindLLVM.cmake. Getting rid of it entirely made the issues disappear. I
checked llvm-config.exe, and it's returning appropriate switches for the
MS toolchain, no need for special processing.
This apparently also leads to LLVM_CXXFLAGS being used for the first time
when building with MSVC. These include /W4, a level further up from
CMake's default /W3, so I disabled a few more frequent warnings.
I also had to link in a lib from Microsoft's Debug Info Access SDK
manually. As the VS command prompt unfortunately doesn't even include the
DIA SDK dir in the LIBPATH environment variable, I even had to specify a
full path, relying on the `VSINSTALLDIR` environment variable.
Since this function is only ever invoked from the base directory of the
LDC source tree, it does not need to recurse in order to get the correct
git revision for LDC. This patch therefore adds a parameter that can be
set to `TRUE` or `FALSE` depending on whether one wants to use recursion
or not, and sets it to false in when calling `get_git_head_revision` in
LDC's own `CMakeLists.txt`.
This should prevent issues that arise when building from source tarballs
that have been extracted into a subdirectory of another git tree (!).
This is unfortunately a real possibility: apart from folks using git to
version their home directory [1], it has also proven an issue when using
source tarballs to build the LDC snap package [2].
[1]42946460
[2]https://github.com/ldc-developers/ldc2.snap/issues/21#issuecomment-287575769
Fixes https://github.com/ldc-developers/ldc/issues/2042.
* Travis: add LLVM 4.0 testing
* CMake: remove the `-Wstring-conversion` cxxflag, added in LLVM 4.0, that is not recognized by gcc-4.9 on Travis.
* CircleCI: With Travis testing 4.0, move CircleCI back to testing LLVM trunk
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.
When LDC_BUILD_WITH_LTO is set, the script adds -flto switch for the C++ compiler and D compiler, but only if they can create an executable with it.
Tested on OSX with ThinLTO (both with and without ThinLTO LLVM build). Some extra work is probably needed on Linux. On Windows, it won't do anything as the cmdline flag checks will fail.
On Linux, we should also enable the thinlto cache if possible.
Quick measurements indicate ~3% percent increased performance for -O0 and -O3 compilation, and a ~20% ldc2 file size reduction. Future step is adding PGO ;-)
This allows us to properly take CMAKE_EXE_LINKER_FLAGS into
account without running into gcc/ld layering issues.
GitHub: Fixes#1494, alternative fix for #1460.
For MSVC each LLVM library was prefixed with the absolute path of the
library location. This leads to problems with the command line length.
This PR uses "-LIBPATH:" as link flag for the LLVM libraries and
only appends the suffix .lib to the library names.
It is important to handle the command line options in the right way.
Otherwise spaces in paths may be lost.
A special problem is the automatic conversion of linker options starting
with "-" to "/". If the linker argument does not start with "-" then the
argument is not considered as a link flag. On the other hand if "-" is
used then the prepending of "-L" for LDC does not generate a valid option.