Commit Graph

58 Commits

Author SHA1 Message Date
Dylan Baker 0efab591da compilers: Move the compiler argument to proxy linker flags to the compiler class
Instead of the DynamicLinker returning a hardcoded value like
`-Wl,-foo`, it now is passed a value that could be '-Wl,', or could be
something '-Xlinker='

This makes a few things cleaner, and will make it possible to fix using
clang (not clang-cl) on windows, where it invokes either link.exe or
lld-link.exe instead of a gnu-ld compatible linker.
2019-08-30 00:01:32 +03:00
Dylan Baker 06dcbd50ee compilers: Dispatch to dynamic linker class
Most of the cuda code is from Olexa Bilaniuk.
Most of the PGI code is from Michael Hirsc
2019-08-14 13:13:23 -07:00
Dylan Baker 90e43dbdfe re-architect the D compiler abstractions
We support 3 D compilers, DMD, LDC, and GDC. DMD is the reference
compiler, and LDC attempts to largely mirror it's command line usage.
GDC does not, it instead acts like GCC (which makes sense). The current
abstraction puts DMD behavior in the base D compiler and then overrides
then in the GnuDCompiler class.

This is messy, but it becomes more problematic when splitting the linker
and compiler abstractions apart.

I've opted to instead split the DCompiler class into two separate
classes. The DCompiler implements core D functinoality, and
DmdLikeCompilerMixin, which implements the DMD and LDC command line
arguments. I've then mxed that into the DmdDCompiler and LLVMDCompiler
classes, and mixed the GnuCompiler into the GnuDCompiler class to get
Gnu command line behavior.
2019-08-14 13:13:22 -07:00
Dylan Baker cd5360821a compilers: split gnu and gnulike compilers out of compilers
I debated a bit whether both classes really belong in the same module,
and decided that they do because the share a number of helpers.
2019-07-15 10:59:22 -07:00
myfreeweb efea48788a Ignore -D* and -fstack-protector* args for D compilers
Fixes #5369
2019-07-11 22:32:39 +03:00
John Ericson 07777e15d4 Purge `is_cross` and friends without changing user interfaces
In most cases instead pass `for_machine`, the name of the relevant
machines (what compilers target, what targets run on, etc). This allows
us to use the cross code path in the native case, deduplicating the
code.

As one can see, environment got bigger as more information is kept
structured there, while ninjabackend got a smaller. Overall a few amount
of lines were added, but the hope is what's added is a lot simpler than
what's removed.
2019-06-09 13:13:25 -04:00
Daniel Mensinger c61ae46461
Moved caching into a seperate function 2019-04-28 14:33:22 +02:00
Daniel Mensinger 971dfd664b
Added some cahced values 2019-04-28 14:33:21 +02:00
Daniel Mensinger c9bd84fd25
Cache compile results in coredata 2019-04-28 14:31:49 +02:00
Ari Vuollet 5ee2fb6ede d: Fix linker errors with shared libraries on Windows 2019-04-03 19:59:24 +03:00
jml1795 a9e63568fe Add warning level zero 2019-02-19 00:06:27 +02:00
Matthias Klumpp 2cede4d6c9 d: Translate the -isystem flag for LDC and DMD 2019-02-18 22:11:19 +02:00
Luís Ferreira b90f196f17 d: fix linker due to argument errors
- revert some changes on d2483d4412 commit.

Signed-off-by: Luís Ferreira <lsferreira169@gmail.com>
2019-02-05 11:13:05 +00:00
John Ericson 19f81d3e33 Never access environment.properties downstream
Instead use coredata.compiler_options.<machine>. This brings the cross
and native code paths closer together, since both now use that.

Command line options are interpreted just as before, for backwards
compatibility. This does introduce some funny conditionals. In the
future, I'd like to change the interpretation of command line options so

 - The logic is cross-agnostic, i.e. there are no conditions affected by
   `is_cross_build()`.

 - Compiler args for both the build and host machines can always be
   controlled by the command line.

 - Compiler args for both machines can always be controlled separately.
2019-02-02 13:59:14 -05:00
Daniel Mensinger 9eca2e46a0
Added more compiler option support 2019-01-06 12:19:33 +01:00
Daniel Mensinger 9742927903
Absolute path generation refactoring 2019-01-06 12:19:32 +01:00
Dylan Baker de175aac00 compilers: Use keyword only arguments for compiler interfaces
Because we need to inherit them in some cases, and python's
keyword-or-positional arguments make this really painful, especially
with inheritance. They do this in two ways:

1) If you want to intercept the arguments you need to check for both a
   keyword and a positional argument, because you could get either. Then
   you need to make sure that you only pass one of those down to the
   next layer.

2) After you do that, if the layer below you decides to do the same
   thing, but uses the other form (you used keyword by the lower level
   uses positional or vice versa), then you'll get a TypeError since two
   layers down got the argument as both a positional and a keyword.

All of this is bad. Fortunately python 3.x provides a mechanism to solve
this, keyword only arguments. These arguments cannot be based
positionally, the interpreter will give us an error in that case.

I have made a best effort to do this correctly, and I've verified it
with GCC, Clang, ICC, and MSVC, but there are other compilers like Arm
and Elbrus that I don't have access to.
2018-11-13 00:40:13 +02:00
Jon Turney bb31a8c1c7
Only add link arguments when needed in Compiler object methods
Currently, ComplierHolder.determine_args() unconditionally adds the link
arguments to the commmand, even if we aren't linking, because it doesn't
have access to the mode (preprocess, compile, link) that
_get_compiler_check_args() will use.

This leads to command lines like:

'cl testfile.c /nologo /showIncludes /c /Fooutput.obj /Od kernel32.lib
user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib
uuid.lib comdlg32.lib advapi32.lib'

which clang-cl considers invalid; MSVS cl accepts this, ignoring the
unneeded libraries

Change from passing extra_args down to _get_compiler_check_args(), to
passing down a callback to CompilerHolder.determine_args() (with a bound
kwargs argument), so it can consult mode and kwargs to determine the args to
use.
2018-11-04 15:42:06 +00:00
Matthias Klumpp ce2eed32bc d: Allow static library to be passed with -L to dmd/ldc 2018-10-07 23:42:01 +03:00
GoaLitiuM 8776dac773 Add conditional debug identifiers for D compilers, and enable for debug builds
Also includes parsing the highest integer level for debug and version.
2018-09-27 17:49:48 +03:00
Mihails Strasuns c352434a7a Implement thread linker args for D compilers
D compilers are configured to have highest priority when chosing linker
for targets mixing C/C++/D code and before this change meson would fail
to configure gtest target that uses D library as a dependency.
2018-09-16 20:31:04 +03:00
GoaLitiuM 43268bfb79 D: Fix some compiler arguments not getting passed through properly 2018-09-16 14:58:50 +03:00
Jussi Pakkanen b9f229a494
Merge pull request #4175 from GoaLitiuM/d-archfixes
D: Improve target architecture handling
2018-09-16 14:40:55 +03:00
David Seifert 69ec001b06 Use enum instead of `int` for compiler variants
* Enums are strongly typed and make the whole
  `gcc_type`/`clang_type`/`icc_type` distinction
  redundant.
* Enums also allow extending via member functions,
  which makes the code more generalisable.
2018-09-16 00:47:32 +03:00
GoaLitiuM 5b0ad0f8ad Refactor D target architecture handling
The stored architecture matches the same format accepted by dub.
2018-09-14 05:18:50 +03:00
Jon Turney de7c3cbbc5 Fix flake8 'imported but unused' reports
$ flake8 | grep F401
./mesonbuild/compilers/d.py:19:1: F401 '.compilers.GCC_CYGWIN' imported but unused
./test cases/unit/35 dist script/replacer.py:3:1: F401 'sys' imported but unused
2018-09-13 20:33:17 +03:00
GoaLitiuM 644809fe59 Make sure static library files are passed properly to the linker 2018-09-06 05:18:08 +03:00
GoaLitiuM 040dd03a7a Fix remaining soname and rpath issues on OSX 2018-09-06 05:18:08 +03:00
GoaLitiuM fd4c996a67 Remove translation of file paths
This would also pass all the source and object files to linker, which is not desirable.
2018-09-06 05:18:07 +03:00
GoaLitiuM d2483d4412 Refactor D argument translation function 2018-09-06 05:18:00 +03:00
GoaLitiuM 6e160995b0 Improve D link argument handling 2018-09-06 03:57:45 +03:00
GoaLitiuM 289c1bf919 D: Fix linking errors with static D libraries on Windows 2018-09-05 20:27:47 +03:00
GoaLitiuM 5240b26fb8 D: Use the documented syntax for various arguments 2018-09-05 20:26:11 +03:00
Jussi Pakkanen 9bcd498a2f
Merge pull request #4084 from FFY00/pr-fix-dub-dependencies
dub: enhance dependency handling
2018-09-03 19:30:52 +03:00
Nirbheek Chauhan bead8287a5 Improve support for macOS dylib versioning
We now use the soversion to set compatibility_version and
current_version by default. This is the only sane thing we can do by
default because of the restrictions on the values that can be used for
compatibility and current version.

Users can override this value with the `darwin_versions:` kwarg, which
can be a single value or a two-element list of values. The first one
is the compatibility version and the second is the current version.

Fixes https://github.com/mesonbuild/meson/issues/3555
Fixes https://github.com/mesonbuild/meson/issues/1451
2018-08-29 15:51:23 -07:00
FFY00 124cedde38
dub: enhance dependency handling
fixes #4032: meson now checks properly for the compiler used to compile dub dependencies

fixes #3568: applied the following patch https://paste.debian.net/1039317/

meson now adds flags for native dependencies required by dub modules

meson now checks for the D version implemented by the compiler used to build dub dependencies (execpt gdc which doesn't support this)
2018-08-29 20:22:01 +01:00
Jussi Pakkanen 1ffc8de5e8
Merge pull request #3981 from GoaLitiuM/d-win-fixes
Fix D support on Windows
2018-08-27 22:30:23 +03:00
Jussi Pakkanen 23e6200c14 My bad. 2018-08-23 21:16:28 -07:00
GoaLitiuM fd2c3b4c77 Handle proper linking of MSVC runtime libraries
DMD expects mscrtlib arguments while compiling, whereas LDC2 expects these while linking.
2018-08-20 22:27:31 +03:00
GoaLitiuM 4a1d64cb6c Fix import libraries and static library naming 2018-08-20 22:27:31 +03:00
GoaLitiuM 7ab938d9af Ignore unix related compiler arguments on Windows 2018-08-20 22:27:31 +03:00
GoaLitiuM 79f05b189a Follow target platform defined in MSVC environment for Windows D compilation 2018-08-20 22:27:31 +03:00
GoaLitiuM e677f2f552 Pass -install-name arguments to linker 2018-08-20 20:25:25 +03:00
GoaLitiuM c2a872c4fc Fix D soname arguments for Windows and OSX 2018-08-20 20:25:25 +03:00
GoaLitiuM 12d5c6114e Fix wrong DMD optimization levels 2018-08-20 19:20:29 +03:00
Jussi Pakkanen d83f77109a
Convert buildtype to optimization and debug options (#3489) 2018-08-18 20:39:47 +03:00
Matthias Klumpp 7618fa81d3 d: Don't fail if -link-defaultlib is manually added to the LDC link args 2018-06-30 00:28:39 +03:00
Nirbheek Chauhan 96b7fdb723 macos: Rewrite install_name for dependent built libraries on install
On macOS, we set the install_name for built libraries to
@rpath/libfoo.dylib, and when linking to the library, we set the RPATH
to its path in the build directory. This allows all built binaries to
be run as-is from the build directory (uninstalled).

However, on install, we have to strip all the RPATHs because they
point to the build directory, and we change the install_name of all
built libraries to the absolute path to the library. This causes the
install name in binaries to be out of date.

We now change that install name to point to the absolute path to each
built library after installation.

Fixes https://github.com/mesonbuild/meson/issues/3038
Fixes https://github.com/mesonbuild/meson/issues/3077

With this, the default workflow on macOS matches what everyone seems
to do, including Autotools and CMake. The next step is providing a way
for build files to override the install_name that is used after
installation for use with, f.ex., private libraries when combined with
the install_rpath: kwarg on targets.
2018-06-18 06:33:23 +00:00
Xavier Claessens b7d442150d Move <lang>_args to coredata.compiler_options 2018-06-06 20:02:37 +00:00
Nirbheek Chauhan ed701b5cb0 Revert "Add macOS linker versioning information"
This reverts commit fa6ca16054.

Closes https://github.com/mesonbuild/meson/issues/3550
2018-05-09 23:11:15 +02:00