Commit graph

46 commits

Author SHA1 Message Date
Martin Kinkelin
e436cb0aad Don't skip MSVC setup in a preset environment if the target arch doesn't match
This doesn't work for VS 2015, but 2017 and 2019. For VS 2015, I haven't
found a suitable env var, and I don't want to parse LIB and/or PATH to
guess the target architecture (LDC_VSDIR_FORCE can still be used).
2020-05-01 01:57:20 +02:00
Martin Kinkelin
18406bcc06 Adopt DMD's MSVC toolchain detection
This reduces the overhead for auto-detecting and setting up an MSVC
toolchain from a very rough 1 second to about 8 milliseconds on my box.
Enabling the auto-detection by default (and so preferring MSVC over the
'internal' toolchain if there's a Visual C++ installation) is now
possible, fixing issues like #3402.

The MSVC setup now consists of the bare minimum - prepending 3
directories to the LIB env var and 1-2 directories to PATH.
2020-04-30 21:45:56 +02:00
Johan Engelen
1aa55f7879
Give user possibility to avoid passing -fuse-ld to cc with --linker=. (#3382) 2020-03-24 00:12:33 +01:00
Martin Kinkelin
3b831968f8 Windows: Only modify & restore *changed* env variables during MSVC setup
Primarily not to spam -v output.
2020-02-26 22:55:59 +01:00
Martin Kinkelin
bab3021f8b Windows: Fix (potential?) console font change during MSVC env setup 2020-02-26 17:05:31 +01:00
Martin Kinkelin
36ebcbafe0 Windows: Support special LDC_VSDIR_FORCE env variable to enforce MSVC env setup
As alternative to clearing VSINSTALLDIR if run in a pre-set environment,
or as alternative to setting LDC_VSDIR to some non-existing dummy dir to
prefer auto-detection and setup of the MSVC toolchain over using the
internal toolchain.
2020-02-26 02:43:23 +01:00
Martin Kinkelin
c8194626d8 Windows: Do not leak MSVC-environment-setup into -run child processes 2020-02-26 00:28:17 +01:00
Martin Kinkelin
639d8bcfb1 Minimally revise -gcc cmdline help 2019-11-17 15:20:34 +01:00
Martin Kinkelin
6e4c389a82 CLI: Unhide -gcc, list under linking options, and revise description
As it's an important option for cross-linking to Posix. It doesn't just
affect linking, but external assembling is probably very exotic
(-no-integrated-as).
2019-10-27 00:12:13 +02:00
Martin Kinkelin
e58316a603 POSIX: Default to cc for linking, not gcc (or clang for FreeBSD 10+) 2019-10-27 00:12:13 +02:00
Martin Kinkelin
ae23a47cdb Tweak usage of LLVM Unicode conversion functions 2019-08-08 22:38:38 +02:00
Martin Kinkelin
42619762e9 Windows: Read environment variables as UTF-8
And use the wide API for pure is-env-variable-set checks too, as the
first call to a narrow env API function would lead to the C runtime
preparing and maintaining both narrow and wide environments.
2019-08-08 22:38:38 +02:00
Martin Kinkelin
64d91629cf Use wide WinAPI functions
There might be more occurrences.
2019-08-08 22:38:38 +02:00
Martin Kinkelin
e52199469f Upgrade front-end & libs to v2.087.0-beta.1 2019-06-21 15:39:45 +02:00
Martin Kinkelin
4a23399236 Aim for consistent #includes (order + dir prefix)
I surely missed a few.
2018-10-20 16:19:46 +02:00
Martin Kinkelin
0e422af0c0
Fix corrupt prefix in integrated LLD's console output (#2781) 2018-07-18 11:38:18 +02:00
Johan Engelen
0c8c0e6a18 Fix build with LLVM trunk. (#2767) 2018-07-09 20:09:44 +02:00
Martin
df4f854dd5 Upgrade to D v2.079.0-beta.1 2018-02-20 02:04:41 +01:00
Martin Kinkelin
6b462b1018
Generalize defaultlibs cmdline help category to linking options (#2496) 2018-01-14 00:03:27 +01:00
kinke
aeaf35c42f
Add -linker command-line option (#2386)
To set the linker executable for MSVC targets (e.g., `lld-link`) or the
`-fuse-ld` arg for the gcc linking command-line for the other targets.
2017-10-28 01:21:24 +02:00
Martin
d7f68dbeb3 Merge branch 'master' into merge-2.075
Conflicts:
	runtime/druntime
2017-10-01 18:28:44 +02:00
Johan Engelen
bc9ead927c Fix LLVM 6.0 compilation.
See https://reviews.llvm.org/D37563
2017-09-18 11:16:23 +01:00
Martin
923e30ec50 Merge branch 'master' into merge-2.075 2017-08-21 01:23:18 +02:00
Martin
acfa2dfb1c [MSVC] CMake: Prepare for LLVM 5.0
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.
2017-08-17 23:49:37 +02:00
Martin
b085be1404 Merge branch 'master' into merge-2.075
Conflicts:
	runtime/druntime
	runtime/phobos
2017-08-12 18:21:21 +02:00
kinke
3b2f6bccdb Don't use -m32/-m64 for external ARM assembler (#2264)
And merge the two out-of-sync copies for adding gcc target flags. The flag
was omitted for gcc as linker already, but not for gcc as external assembler.
2017-08-12 18:17:03 +02:00
Martin
2616261fd2 Revise all LDC-specific errors/warnings/deprecs and insert backticks
For DMD's new syntax highlighting. I grepped in all .{h,cpp} files only.
2017-08-03 22:53:49 +02:00
Martin
1fb269f940 Drop support for LLVM < 3.7 2017-07-16 02:18:00 +02:00
Martin
00d5f9b5b5 Integrate LLD for MSVC targets via experimental CMake option LDC_WITH_LLD
Results in a 7.5% bigger RelWithDebInfo ldc2.exe on Win64 with LLVM 3.9.1.

LLD is currently enforced when building with LDC_WITH_LLD=ON. And LLD
still doesn't support debuginfo (.pdb) generation for MSVC targets.
2017-05-27 21:21:31 +02:00
Martin
ec1a54aade Move static lib generation from driver/linker.cpp to driver/archiver.cpp 2017-05-26 21:55:25 +02:00
Martin
ab85d209ab Don't set up MSVC environment *after* locating tools
And warn if no Visual C++ installation is detected, similar to the now
suppressed warning issued by the batch file.
2017-03-14 00:40:52 +01:00
Martin
1c70b12e4c Slightly refactor module driver/tool
And get rid of redundant cmdline option -archiver.
2017-03-13 23:51:16 +01:00
Martin
95c1d38e2e Integrate module gen/programs into driver/tool 2017-03-13 23:31:32 +01:00
Martin
0842277572 Move MSVC environment setup to driver/tool.cpp [NFC] 2017-03-13 23:03:33 +01:00
Martin
cab165f3d8 Set up the MSVC environment in a more flexible way
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.
2017-03-13 00:36:45 +01:00
David Nadlinger
51afced357 Also clang-tidy driver/ 2015-11-02 11:30:40 +02:00
David Nadlinger
44b0f7b615 driver/gen/ir: clang-format the world
This uses the LLVM style, which makes sense for sharing code
with other LLVM projects. The DMD code we use will soon all
be in D anyway.
2015-11-02 00:28:01 +02:00
Martin
2d959ea540 Make use of C++11 range-based for
Should be available now that support for LLVM < 3.5 has been dropped.
2015-11-01 14:49:04 +01:00
Martin
60d676e2a1 Drop support for LLVM < 3.5
This allows to clean up the code a little.
2015-10-30 22:24:05 +01:00
David Nadlinger
a10ab28912 Remove CRLF line endings in driver/tool.{h, cpp}. 2014-07-08 22:00:19 +02:00
kai
456924116b Merge branch 'merge-2.064' into merge-2.065 2014-04-05 22:37:27 +02:00
Kai Nacke
38ab450c56 Print target information, version identifiers and linker commands in verbose output (-v). 2014-04-05 22:13:39 +02:00
Kai Nacke
fe39da53e3 Merge of 2.065.0-b3.
The new visitor class is used for IR generation. This removes some modifications from DMD source.
2014-02-10 08:47:25 +01:00
kai
cf88271ab9 Replace llvm::sys::Path with std::string.
In many cases this is straightforward. It makes the source LLVM 3.4 compatible without using #idef's.
2013-06-29 14:20:44 +02:00
kai
f1c71e4bac Make ldc compatible with LLVM 3.4
Development of LLVM 3.4 started with a cleanup of the path class (PathV1).
The changes here let ldc compile at least with rev. 184039 of LLVM.
2013-06-15 19:52:29 +02:00
David Nadlinger
243083b88c Factored out tool invocation code into separate file. 2013-02-13 00:07:48 +01:00