Commit graph

145 commits

Author SHA1 Message Date
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
e52199469f Upgrade front-end & libs to v2.087.0-beta.1 2019-06-21 15:39:45 +02:00
Martin Kinkelin
bdfc0f9b07 MSVC: Default to the internal 'toolchain' (-link-internally + MinGW-w64 libs) 2018-10-29 20:19:14 +01: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
0bd9a10234 Add LDC-specific support for __traits(getTargetInfo) 2018-10-20 16:19:46 +02:00
Martin Kinkelin
5c24f60cf9
Raise min LLVM version to 3.9 (#2872) 2018-10-15 22:31:59 +02:00
Martin Kinkelin
27e4ac0304 Add -link-internally support for MinGW and WebAssembly targets 2018-07-09 20:25:32 +02:00
Martin
82a6ccd293 Refactor default libs linker stuff to driver/linker.cpp 2018-04-21 18:23:59 +02:00
Martin
891234bbe4 Only set rpath when linking against shared default libs 2018-04-21 18:23:59 +02:00
Martin
ca14bc972a Un-hide -link-internally 2018-04-16 22:43:57 +02:00
Martin
fd9c1d1b72 Strip path when inferring exe/lib name from first object file
This is what DMD does and crucial for `ldmd2 -od=objects foo.d` with
relative -od path (and no -of). The object file path will be
`objects/foo.o[bj]`. As it's relative, LDC used to prepend the objects
dir (again) in LDMD mode, resulting in the inferred executable file name
`objects/objects/foo[.exe]`.

So while this is a breaking change, it fixes DMD compatibility of LDMD
and makes a lot of sense for 'pure' LDC too IMO (use the first object's
file name, replace the extension and save it in the working dir, not in
the directory containing the first object file).

This fixes the dmd-testsuite regressions with relative RESULTS_DIR and
a few long-standing non-fatal dmd-testsuite errors (failing file
removals).
2018-01-25 03:34:43 +01:00
Martin
197e65efde Merge branch 'master' into merge-2.078
Conflicts:
	driver/main.cpp
	gen/cl_helpers.h
	gen/declarations.cpp
	runtime/druntime
	tests/d2/dmd-testsuite
2018-01-20 11:20:17 +01:00
Martin Kinkelin
6b462b1018
Generalize defaultlibs cmdline help category to linking options (#2496) 2018-01-14 00:03:27 +01:00
Martin Kinkelin
1572c91fc0
Add -link-defaultlib-shared and rename -link-debuglib (#2443)
... to -link-defaultlib-debug (with alias for backwards compatibility).

-link-defaultlib-shared is to be used for switching between static and
shared default libs to be linked with.

It defaults to true when generating shared libraries (if shared
druntime/Phobos are supported for the target, i.e., not for Windows).
This is a benign breaking change!
2018-01-12 18:26:19 +01:00
Martin
cfad799f48 Merge 2.078.0 front-end and stdlibs 2018-01-06 01:39:18 +01:00
Martin
1fb269f940 Drop support for LLVM < 3.7 2017-07-16 02:18:00 +02:00
Martin
9fd7fa2d90 Add experimental -link-internally switch to enable LLD opt-in
And infer CMake LDC_WITH_LLD automatically based on availability of LLVM
3.9+ with LLD headers & libs.
2017-05-29 22:45:32 +02:00
Martin
ecbfa0e52a Move GCC driver to dedicated driver/linker-gcc.cpp 2017-05-27 02:23:49 +02:00
Martin
cb0c27c3c5 Refactor MSVC link.exe driver into dedicated driver/linker-msvc.cpp 2017-05-26 23:57:21 +02:00
Martin
ec1a54aade Move static lib generation from driver/linker.cpp to driver/archiver.cpp 2017-05-26 21:55:25 +02:00
kinke
151e83dc6b Fix C++ warnings (#2140) 2017-05-26 13:45:15 +02:00
David Nadlinger
747f7a3dfa clang-format files touched in d01a91f7 [nfc]
Some housekeeping on files that recently saw large changes anyway.
2017-05-24 21:35:40 +01:00
Martin
d01a91f755 Allow multiple occurrences for almost all command-line flags
Except for `-sanitize` and `-cache-prune*`.
2017-05-23 20:53:57 +02:00
Adrian Matoga
aafd6541c7 Add switch '-Xcc <ccflag>'. Fix #2093. (#2104) 2017-05-16 20:23:02 +02:00
Martin
a38cae7831 MSVC: Remove useless (and disabled) /LTCG linker flag
`global.params.optimize` is never changed from its initial `false` state.
When experimentally enabling it, the MS linker produces warnings like

LINK : /LTCG specified but no code generation required; remove /LTCG from
the link command line to improve linker performance
2017-05-12 23:40:07 +02:00
kinke
a5139499a3 Add -mscrtlib cmdline option and support -static on Windows (#2041)
The default MS C runtime library doesn't depend on the `LINK_WITH_MSVCRT`
CMake variable anymore.

The user can freely choose among the 4 variants libcmt[d] / msvcrt[d] via
-mscrtlib or choose between static/dynamic release variant via -static.

LDC keeps on defaulting to the static release C runtime, so
`-static=false` or `-mscrtlib=msvcrt[d]` must be used explicitly in order
to link against the runtime DLLs.
2017-04-09 01:17:28 +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
Martin
ad3294b3ae Enable cross-static-lib generation for LLVM 3.9+
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.
2017-03-12 03:56:46 +01:00
Martin
7fc885e59f Append default file extension for LDMD only 2017-03-08 19:47:04 +01:00
Martin
9a1c4adbbc Add hidden -ldmd option when invoking LDC via LDMD
Thus providing a generic way to slightly alter some command-line semantics
in DMD compatibility mode.
2017-03-08 19:47:04 +01:00
Martin
5f8cae7b34 Append default file extension if -of doesn't contain any
Resolves issue #2001.
2017-03-08 19:47:04 +01:00
Martin
505a01b278 Forward -L linker args starting with -Wl, to gcc driver 2016-12-04 17:39:52 +01:00
Johan Engelen
56b62b2208 LTO: add extra search locations for the LLVMgold.so plugin. 2016-11-30 17:30:37 +01:00
Johan Engelen
3b59879a45 Allow user to specify LTO plugin file. 2016-11-28 19:28:20 +01:00
Johan Engelen
788add6155 Revert "Move the LTO plugin to the bin dir."
This reverts commit 23a677d001.
2016-11-28 13:58:09 +01:00
Johan Engelen
23a677d001 Move the LTO plugin to the bin dir. 2016-11-27 19:34:08 +01:00
Johan Engelen
d4f5b8ab6c Suffix the LTO plugin packaged with LDC with "-ldc", to prevent installation conflicts. 2016-11-27 17:42:42 +01:00
Rainer Schuetze
27c395caa9 fix issue 1876: passing /LARGEADDRESSAWARE:NO is a workaround for DWARF debug info, it causes trouble with CodeView debug info 2016-11-13 14:37:38 +01:00
Johan Engelen
bb24fb2816 Add LTO support (full and thin), with -flto=thin|full.
LTO needs linker support: I am only aware of support on OS X and Linux (through the LLVMgold plugin).

Resolves #693
2016-11-09 14:30:13 +01:00
Martin
8276269ab1 Create static libs in -od directory for LDMD only
Let LDC treat relative output paths as relative to the current working
directory again (as it always used to until a few weeks ago). It's more
intuitive and avoids breaking build systems/scripts using LDC directly.

Only LDMD continues to prepend the -od directory to the relative output
path, for DMD compatibility.

Fixes issue #1819.
2016-10-14 21:47:27 +02:00
Martin
a8c6293865 Create output directories recursively
Fixes issue #1819.
2016-10-09 23:21:35 +02:00
Martin
8f2665d7bb Windows: Support .res and .def files in command-line 2016-09-27 01:34:05 +02:00
Martin
b1a6315ee4 Don't reverse order of object file names
Make sure the overall order corresponds to the user's command-line order
of object and source files. The only exception being singleObj builds,
for which the single object file for all source files is always the first
entry in the object files list (which is forwarded to the linker in that
order). This is done so that we can easily get hold of the name when
emitting the single object file later in the `ldc::CodeGenerator` dtor.
It should also clearly define the linking order (affecting comdat
selections etc.) for special singleObj builds.

Also reuse some more code (wrt. output filenames) from DMD's main().
2016-09-27 01:34:05 +02:00
Martin
d85986be3d Infer output names from first object file alone (ignore root module) 2016-09-07 09:53:35 +02:00
Martin
6c03a3d725 Streamline output filenames and -singleObj behavior some more with DMD 2016-09-07 09:53:35 +02:00
Martin
aed881350a Refactor output filename generation/validation 2016-09-07 09:53:35 +02:00