Commit graph

305 commits

Author SHA1 Message Date
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
Martin
6c6379d534 Fix mistake in object file type autodetection 2017-05-22 22:40:22 +02:00
David Nadlinger
df20e65b1d Merge pull request #2118 from kinke/gh2105
Fix object file type autodetection (issue #2105)
2017-05-20 21:22:48 +01:00
Martin
5becfcf4f1 Fix object file type autodetection (issue #2105) 2017-05-14 14:26:55 +02:00
Johan Engelen
3fd99eb207 Add -fsave-optimization-record option.
Resolves issue #2089
2017-05-04 11:07:16 +02:00
Martin
97188a1a27 Merge branch 'master' into merge-2.073
Conflicts:
	tests/d2/dmd-testsuite
2017-03-09 01:11:03 +01:00
Martin
1c175b76de Darwin: Change default shared-lib extension from .so to .dylib 2017-03-08 19:47:04 +01:00
Martin
162c264450 Merge branch 'master' into merge-2.073
Conflicts:
	runtime/phobos
2017-03-04 23:30:04 +01:00
e-y-e
0d9ab693bf Detect RISC-V architectures and define the correct versions 2017-03-02 20:34:55 +00:00
Martin
1d4c6fa72c Don't pre-define versions D_SIMD and D_AVX
LDC doesn't support DMD's core.simd interface.
2017-02-19 02:37:47 +01:00
Martin
3940f6f1c3 Use upstream's new printPredefinedVersions()
Resolves issue #1962.
2017-02-19 01:40:42 +01:00
Martin
627b35d680 Add DMD-compatible pre-defined versions D_SIMD and D_AVX 2017-02-19 01:24:43 +01:00
Martin
8648b9305a Add new switch -dip1000 2017-02-18 22:59:29 +01:00
Martin
cecb040ff0 Add command-line option -transition=safe
Also fix `ldmd2 -transition=?` regression and don't display an error
message when invoking LDMD without command-line args.
2017-02-12 18:47:53 +01:00
Martin
84e74e3932 Rework LDMD command-line translation and add -verrors-spec
Simplify LDMD quite a bit by translating the few different command-line
options directly in-place. This puts some more stress onto LDC's
command-line parsing, especially due to multiple occurrences of a single
Boolean option (e.g., '-o-') or mixtures of `-m64` and `-m32` etc. for
dmd-testsuite.

Also add new command-line option `-verrors-spec` showing gagged errors
(DMD's equivalent is `-verrors=<spec|limit>`) and sync the usage text with
DMD. LDMD now also recognizes `-h` (and `/?` on Windows).
2017-02-06 01:17:09 +01:00
Martin
dca21939e1 Merge 2.072.2 front-end
The part needing most attention was ddmd.root.ctfloat, ddmd.target (incl.
gen/target.cpp) and ddmd.builtin. The front-end is now prepared for
elaborate compile-time floating-point types to allow for proper cross-
compilation.

This version still uses the host's `real` type for compile-time reals,
except for MSVC hosts, which still use 64-bit doubles (when compiled with
DMD host compiler too).

Some other changes:

* semantic*() of Statements extracted from statement.d to statementsem.d
* mangle() -> mangleToBuffer()
* Identifier::string -> toChars()
* Token::float80value => floatvalue
* Dsymbol::isAggregateMember() => isMember()
* BoolExp is no more
* ddmd.root.ctfloat: LDC-specific CTFE builtins
2017-01-29 15:48:03 +01:00
kinke
b7e576d579 Improve support for response files in command line (#1942)
Fix issue #1941 by expanding response files *before* temptatively parsing
an explicit `-conf` and/or target triple for the config file lookup.
After injecting the switches from the config file right after argv[0],
expand again to catch any response files specified in the config file
switches.
2017-01-04 23:58:15 +01:00
Martin
4f8b4f1b4c Be more forgiving when pre-parsing target triple for config file lookup
Fixes issue #1945 by allowing `-march x86` besides `-march=x86`.
2017-01-03 21:09:35 +01:00
Johan Engelen
cd3ae57d14 Implement -ffast-math.
Resolves #1874.
2016-12-14 12:27:45 +01:00
Johan Engelen
b78f62c533 Refactor the machinery to add commandline options that clash with LLVM's options. This generalizes the piece of code that adds the "enable-color" option, such that it is easier to add other LLVM-clashing options (such as -ffast-math). [NFC] 2016-12-14 12:18:58 +01:00
Johan Engelen
61e99e82d7 Rename "ir2obj-cache" to "cache" (source and filenames) 2016-10-12 18:58:01 +02:00
Johan Engelen
e0c78fa198 Rename -ir2obj-cache-* cmdline flags to -cache-*, because the cache can be used for more things than just ir2obj caching.
Rename "ir2obj" namespace to "cache".
2016-10-12 18:58:01 +02:00
Johan Engelen
f6919e3fb6 ir2obj cache: Add all cmdline args to the hash, unless we are certain they can safely be ignored for ir2obj hashing. 2016-10-06 12:03:44 +02:00
Martin
b9811cef1c Don't append dot to unknown extension for -of filename
I've previously missed this part when moving to the DMD output filenames.
LDC used to enforce the target object file extension for all produced
objects.

So in `compilable/ldc_output_filenames.sh`, we tried to produce the object
file `myObj.myExt.` instead of `myObj.myExt`. The tests passed on Windows,
but failed at least on Linux.
2016-09-27 22:12:54 +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
Johan Engelen
df4cd3fc20 Add ir2obj cache pruning support. 2016-09-14 10:08:48 +02:00
Martin
bfac582294 Enforce backslashes in most paths on Windows
DMD does too, and the front-end's FileName class expects backslashes in
some places.
Due to the import and lib directories in the ldc2.conf file being
specified with forward slashes, most paths produced by LDC used both
slashes, e.g., `C:/LDC/ldc/runtime/druntime/src\object.d`, which looks
unprofessional, is problematic for the front-end and leads to differences
wrt. DMD when outputting module dependencies etc.
2016-09-07 10:03:33 +02:00
Martin
6c03a3d725 Streamline output filenames and -singleObj behavior some more with DMD 2016-09-07 09:53:35 +02:00
Martin
c748eb9ed0 Replace global.params.singleObj by global.params.oneobj
singleObj was LDC-specific.
2016-09-07 09:53:35 +02:00
Martin
aed881350a Refactor output filename generation/validation 2016-09-07 09:53:35 +02:00
David Nadlinger
6f98b63996 driver: Remove some elses for ifs with return statements [nfc]
Also some very minor deduplication.
2016-09-03 00:52:03 +01:00
David Nadlinger
11572489d5 clang-format again some files touched in the next commits [nfc] 2016-09-03 00:52:00 +01:00
Martin
41fb7830df Remove LDC-specific global.obj_ext_alt
No functional changes intended.
2016-08-28 21:41:04 +02:00
Martin
16b2c8942f Support parameterless '-deps' command-line option
In both LDC (undocumented) and LDMD. This should fix issue #1626.
2016-08-28 02:43:48 +02:00
Martin
94d8cad554 Slipstream LDC-specific main() mods directly into ddmd/mars.d 2016-08-28 02:43:48 +02:00
Martin
24cecc268c Streamline main() with DMD's (ddmd/mars.d) 2016-08-27 20:40:26 +02:00
David Nadlinger
d47bdb234a gen: Use single ldc.register_dso function for both module ctor/dtor
This reduces the size of a statically linked Phobos-based
Hello World by 11 kB on Linux x86_64.

Also creates a header file for gen/module.cpp, which has been
renamed to "modules" such as not to conflict with the frontend
header file.
2016-08-18 16:28:41 +02:00
Johan Engelen
7bc6512c65 Early merge front-end fixes for Module.semantic.
This eliminates the hidden-virtuals warning flood.

See
https://github.com/dlang/dmd/pull/6001
60f622ff1b
and
https://github.com/dlang/dmd/pull/6038
2016-08-08 19:24:04 +02:00
Johan Engelen
e95a8472d0 [PGO] For LLVM >= 3.9, let profile-rt set the default filename. This prevents extra stderr messages when overriding the filename using the "LLVM_PROFILE_FILE" environment variable. 2016-08-04 16:35:44 +02:00
Johan Engelen
ae5ffa4c0d Fix LLVM 4.0 build. 2016-07-29 16:57:12 +02:00
Johan Engelen
be54d79966 Revert 4fede9467f 2016-07-29 15:33:41 +02:00
Johan Engelen
4fede9467f Fix LLVM 4.0 build. 2016-07-29 15:32:28 +02:00
Johan Engelen
c3fe8f3fdd Refactor the call to llvm::sys::fs::getMainExecutable.
Taking the address of `main` is UB in C++. Reading LLVM's source, any function address can be used (that's what clang does too).
2016-07-28 14:00:53 +02:00
Martin
436aba77af Fix issue #1621
LLVM's ParseCommandLineOptions() expands response files automatically, but
always uses the TokenizeGNUCommandLine tokenizer, which apparently eats
backslashes.

The solution is to pre-expand the response files into the arguments vector
on the LDC side, and using TokenizeWindowsCommandLine if LDC is built for
Windows.
2016-07-23 15:31:27 +02:00
Johan Engelen
a3f0678283 Fix inlining problem: reverse order in which module array is codegenned. 2016-07-02 17:08:48 +02:00
Johan Engelen
e0d9c58443 [PGO] Add PGO to LDC. Supported for LLVM >= 3.7
Add the commandline options -fprofile-instr-generate[=filename] and -profile-instr-use=filename
-fprofile-instr-generate
-- Add instrumentation on branches, switches, and function entry; uses LLVM's InstrProf pass.
-- Link to profile runtime that writes instrumentation counters to a file.
-fprofile-instr-use
-- Read profile data from a file and apply branch weights to branches and switches, and annotate functions with entrycount in LLVM IR.
-- Functions with low or high entrycount are marked with 'cold' or 'inlinehint'.

The only statement type without PGO yet is "try-finally".

A new pragma, `pragma(LDC_profile_instr, [ true | false ])`, is added to selectively disable/enable instrumentation of functions (granularity = whole functions).

The runtime library ldc-profile-rt is a copy of LLVM compiler-rt lib/profile. It has to be exactly in-sync with the LLVM version, and thus we need a copy for each PGO-supported LLVM (>=3.7).
import ldc.profile for a D interface to ldc-profile-rt (for example to reset execution counts after a program startup phase).

The instrumentation data is mainly passed on to LLVM: function-entry counts and branch counts/probabilities. LDC marks functions as hot when "execution count is 30% of the maximum function execution count", and marks functions as cold if their count is 1% of maximum function execution count.

The source of LLVM's llvm-profdata tool is hereby included in LDCs repository (different source for each LLVM version), and the binary is included in the install bin folder.
The executable is named "ldc-profdata" to avoid clashing with llvm-profdata on the same machine. This is needed because profdata executable has to be in-sync with the LLVM version used to build LDC.

Maintenance burden: for trunk LLVM, we have to keep ldc-profile-rt and llvm-profdata in sync. There is no diff with upstream; but because of active development there are the occasional API changes.
2016-06-20 17:28:22 +02:00
Rainer Schuetze
f9995b1883 fix build against LLVM trunk svn rev 273030 2016-06-18 10:54:23 +02:00
Johan Engelen
0aea0df3a7 Add predefined version identifier D_Coverage.
(test upstreamed)
2016-06-09 15:16:36 +02:00
Johan Engelen
d9b267a4be Accept LLVM bitcode files (*.bc) on the commandline and add the code to the first source file on the cmdline (the first emitted module). 2016-06-05 16:07:14 +02:00