Commit Graph

112 Commits

Author SHA1 Message Date
Dylan Baker 1209b8820b compilers: push the compiler id to a class variable
It really is a per class value, and shouldn't be set per instance. It
also allows us to get rid of useless constructors, including those
breaking mypy
2022-01-10 15:53:26 -05:00
Eli Schwartz 9f384e9207
fix type annotations for compiler toolchain rpaths
We pass around a tuple of rpaths, because rpaths *can* be more than one.
But all the annotations said it would be a str instead.
2021-12-30 15:15:25 -05:00
Denis Feklushkin 1b1ecec920 ldc2: invoke -Oz instead of -Os 2021-11-22 12:35:28 -08:00
Christian Clauss a5020857f3 Fix typos discovered by codespell 2021-10-10 16:12:25 -04:00
Dylan Baker 9795323b86 pylint: check for duplicate imports
I ran into one of these from LGTM, and it would be nice if pylint could
warn me as part of my local development process instead of waiting for
the CI to tell me.
2021-09-24 10:36:05 -07:00
Dylan Baker 4d7031437c pylint: turn on superflous-parens
We have a lot of these. Some of them are harmless, if unidiomatic, such
as `if (condition)`, others are potentially dangerous `assert(...)`, as
`assert(condtion)` works as expected, but `assert(condition, message)`
will result in an assertion that never triggers, as what you're actually
asserting is `bool(tuple[2])`, which will always be true.
2021-08-31 16:28:54 -04:00
Paolo Bonzini 3efed376c3 linkers: remove is_shared_module argument to get_soname_args
The argument is now unused, drop it.
2021-07-14 22:53:04 +02:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Dylan Baker 40e3577a65 split program related classes and functions out of dependencies
Dependencies is already a large and complicated package without adding
programs to the list. This also allows us to untangle a bit of spaghetti
that we have.
2021-03-19 08:47:10 -04:00
Remi Thebault c756d97895 Fix D lib search path translation
This requires quite a complex and messy logic.
As @dcbaker suggested in #8491, this could be replaced by
an abstraction over linker flags instead of having GNU flags
translated.
2021-03-17 10:14:55 -07:00
Dylan Baker 2be074b1d4 ninjabackend: Use rsp_file_syntax method
This also makes us of the new enum value in the backend, for better type
saftey.
2021-03-14 22:05:55 -07:00
Dylan Baker 320412b3bb compilers/linkers: Add a methhod for getting the rspfile syntax 2021-03-14 22:05:55 -07:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Eli Schwartz 4340bf34fa
various python neatness cleanups
All changes were created by running

"pyupgrade --py3-only --keep-percent-format"

and committing the results. I have not touched string formatting for
now.

- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
2021-03-04 17:11:26 -05:00
Remi Thebault 25848fc05f fix missing versions with generated source 2021-03-02 09:31:40 -08:00
Remi Thebault 3bf207ab1b D add build dir to -J switch 2021-03-01 09:51:40 -08:00
Dylan Baker 71db6b04a3 use OptionKey for builtin and base options
I would have prefered to do these seperatately, but they are combined in
some cases, so it was much easier to convert them together.

this eliminates the builtins_per_machine dict, as it's duplicated with
the OptionKey's machine parameter.
2021-01-04 12:20:40 -08:00
Remi Thebault 7a9a9e4a99
Implement support of dlang -makedeps switch (#8119)
* Implement support of dlang -makedeps switch

Fix #8118

* resolve code review comments
2020-12-29 09:56:35 -08:00
Peter Harris 8b8a610ea4 vs: add static_from_buildtype to b_vscrt 2020-10-14 19:35:28 +03:00
Dylan Baker 6a9761a2c0 compilers/d: add type annotations 2020-10-01 15:06:10 -07:00
Dylan Baker d3a059b55f compilers/cuda: make type safe 2020-10-01 15:05:00 -07:00
Dylan Baker 224a752489 compilres: move depfile_for_object to compiler 2020-10-01 15:05:00 -07:00
Dylan Baker e7f0890cb9 compilers: move get_dependency_gen_args to base Compiler
So that every subclass doesn't have to reimplement it. Especially since
the Gnu implementation moved out of the CCompiler and into the
GnuLikeCompiler mixin
2020-10-01 15:05:00 -07:00
Dylan Baker 2c0fbe161d compilers: make is_cross part of the base Compiler class
Every class needs to set this, so it should be part of the base. For
classes that require is_cross, the positional argument remains in their
signature. For those that don't, they just allow the base class to set
their value to it's default of False.
2020-09-24 12:14:13 -07:00
Dylan Baker 98416e7f75 compilers: put name_string method in base compiler
Every language had the exact same implementation
2020-09-24 12:14:13 -07:00
Pierrick Bouvier 1900720353 D: fix include order
Commit 93c3ec7e introduced a new way to handle deduplication with
compiler args. This resulted in D includes to be reversed.
2020-08-30 18:56:24 +03:00
Dylan Baker 93c3ec7e2d compilers: Return CompilerArgs from compiler instance
Since the CompileArgs class already needs to know about the compiler,
and we really need at least per-lanaguage if not per-compiler
CompilerArgs classes, let's get the CompilerArgs instance from the
compiler using a method.
2020-06-22 12:06:10 -07:00
Dylan Baker 9d0ad66c29 compilers: Split CompilerArgs into a separate module
I've also moved this out of the compilers pacakge because we're soon
going to need it in linkers, and that creates some serious spagetti
2020-06-22 12:06:10 -07:00
Dylan Baker 29ef4478df compilers/d: Add b_ndebug support
D lang compilers have an option -release (or similar) which turns off
asserts, contracts, and other runtime type checking. This patch wires
that up to the b_ndebug flag.

Fixes #7082
2020-05-20 14:20:26 -07:00
Jussi Pakkanen 751ea3df72
Merge pull request #7103 from dankegel/bug4027-rpath-remember
Let .pc files and LDFLAGS provide rpaths.
2020-05-18 23:17:34 +03:00
Dylan Baker 6fe68edbf8 compilers/d: Enable pgo for GDC 2020-05-18 19:29:18 +03:00
Dan Kegel d7235c5905 Let .pc files specify rpath.
Fixes #4027
2020-05-16 20:25:58 +00:00
Dylan Baker fe3f7676e9 compilers/d: Add missing method for dmd and ldc
This allows coverage to be generated, although we can't yet do anything
useful with it.
2020-04-10 12:46:55 -07:00
Dylan Baker 0f8d73848a compilers/d: Implement coverage for GDC
Since GDC a GNU compiler, we just need to pass the normal GNU options
and coverage is generated.

Related: ##5669
2020-04-10 12:35:25 -07:00
Dylan Baker e1060f5772 compilers: Link D runtime/libphobs dynamically on !Windows
Fixes: #6786
2020-03-19 19:04:43 +02:00
Dylan Baker 9c9dcbb1a8 compilers/d: Support linker selection with gdc
This should have worked before, but the inheritance order was backwards,
so we got the DCompiler before the GnuCompiler, and the base Compiler
methods overrode the Gnu methods.
2020-03-12 13:21:04 -07:00
Dylan Baker 92e80d54e5 compilers/d: Properly pass -soname args 2020-03-11 09:27:10 -07:00
Dylan Baker f136084609 compilers/d: Fix rpath generation with LDC and DMD 2020-03-11 09:26:20 -07:00
Dylan Baker fe86c594c6 Allow invoking the linker directly through dmd
DMD is awful in a lot of ways. To change the linker you set an
environment variable, which is pretty much impossible for us.
2020-03-09 16:55:08 -07:00
Dylan Baker 1fe153a3a5 Allow invoking link.exe and lld-link.exe through ldc2
Like it wants
2020-03-09 13:19:03 -07:00
Dylan Baker f404c679cf compilers/d: Fix get_allow_undefined_link_args on macOS
DMD and LDC are a real pain to use as linkers. On Unices they invoke the C
compiler as the linker, just like meson does. This means we have to figure out
what C compiler they're using and try to pass valid arguments to that compiler
if the D compiler doesn't understand the linker arguments we want to pass. In
this case that means gcc or clang. We can use-the -Xcc to pass arguments
directly to the C compiler without dmd/ldc getting involved, so we'll use that.
2020-03-06 12:11:26 -08:00
Dylan Baker c0fd20f164 compilers/d: Remove CompilerIsLInkerMixin
This was never really true of the D compilers, it made them more
complicated than necessary and was incorrect in many cases. Removing it
causes no regressions on Linux, at least in our rather limited test
cases).
2020-03-06 12:11:26 -08:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Dylan Baker ee6e249f65 compilers: move language attribute to the class level
We know that if a compiler class inherits CCompiler it's language will
be C, so doing this at the class level makes more sense.
2019-12-12 09:35:30 -08:00
Daniel Mensinger fe853ee516 lgtm: fix Missing call to __init__ during object initialization
Either mark the missing calls as intentional, or explicetly call
the right __init__ method and avoid mixing super() and explicit
base calss calls.
2019-12-05 00:22:10 +02:00
Eric Le Bihan 815563841a Fix cross-compilation of D programs
Since version 9.1, GCC provides support for the D programming language. Thus it
is easy to build a cross-compiler for D, such as aarch64-unknown-linux-gnu-gdc.

However to cross-compile a Meson project using D, using a cross build definition
such as the following is not enough:

```
[binaries]
d = '/path/to/aarch64-unknown-linux-gnu-gdc'
exe_wrapper = '/path/to/qemu-aarch64-static'

[properties]
needs_exe_wrapper = true

[host_machine]
system = 'linux'
cpu_family = 'aarch64'
cpu = 'cortex-a53'
endian = 'little'
```

Indeed, "exe_wrapper" is not be taken into account. Build will fail with:

```
Executables created by D compiler /path/to/aarch64-uknown-linux-gnu-gdc are not runnable.
```

This patch fixes this by reworking:

- detect_d_compiler() to properly get exe_wrapper and D compilers and detect the
one available.
- Dcompiler to properly handle exe_wrapper.
2019-11-19 16:32:12 +02:00
Jussi Pakkanen 4c96aa34cb Add -L= to soname linker argument, too. 2019-11-06 22:12:41 +02:00
GoaLitiuM 31d397187d d: Fix various linking issues on Windows 2019-10-21 16:24:39 +03:00
Andrei Alexeyev 5dfd054c32 Workaround broken get_allow_undefined_link_args in DmdLikeCompilerMixin
Previously it worked by accident because BasicLinkerIsCompilerMixin had
that method misspelled.
2019-10-14 13:04:34 -07:00
Andrei Alexeyev af2c1e4eb7 Revert "Remove BasicLinkerIsCompilerMixin from LDC and DMD"
This reverts commit 04d6a439457d76b9cf4c4f98fce238219366e241.
2019-10-14 13:04:34 -07:00