Commit Graph

340 Commits

Author SHA1 Message Date
Daniel Mensinger 9c40b33cf6 compilers: Fix missing functions in Compiler base class 2021-06-09 09:46:37 +02:00
Dylan Baker 4d1cbd1b8a compilers: Add cython file suffixes 2021-06-07 09:16:19 -07:00
Dylan Baker 113a159514 use an immutable list for an lru_cached functions
When mutable items are stored in an lru cache, changing the returned
items changes the cached items as well. Therefore we want to ensure that
we're not mutating them. Using the ImmutableListProtocol allows mypy to
find mutations and reject them. This doesn't solve the problem of
mutable values inside the values, so you could have to do things like:

```python
ImmutableListProtocol[ImmutableListProtocol[str]]
```

or equally hacky. It can also be used for input types and acts a bit
like C's const:

```python
def foo(arg: ImmutableListProtocol[str]) -> T.List[str]:
    arg[1] = 'foo'  # works while running, but mypy errors
```
2021-06-02 15:53:17 -07:00
Dylan Baker 156d6160d1 compilers: Add `get_debug_args` to base Compiler
This was missed, there should be an implementation in the base Compiler
class, if for nothing else to help mypy
2021-05-19 23:28:17 +03:00
Volker-Weissmann 4ca9a16288
.C files are now treated as C++ code 2021-05-19 17:10:22 +03:00
Dylan Baker f99ed692c4 environment: get environment variables for both host and build machines
Fixes #8605
2021-04-01 09:54:43 -07:00
Dylan Baker 2cd0723c42 Split environment variable and command line cflags
They are supposed to have different behavior. The environment variables
apply to both the compiler and linker when the compiler acts as a
linker, but the command line ones do not.

Fixes #8345
2021-03-30 18:52:17 +03:00
Dylan Baker 320412b3bb compilers/linkers: Add a methhod for getting the rspfile syntax 2021-03-14 22:05:55 -07:00
Dylan Baker 504ae2dee8
compilers: Use EnvironmentException not EnvironmentError/OSError
The latter is a python built-in exception, the former is a meson
exception.
2021-03-04 22:13:33 -05: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
Dylan Baker 90a7de3f2b Ensure that $lang_args and $lang_link_args are properly parsed
Currently we don't handle things correctly if we get a string we should
split, and the linker and needs compiler arguments. It would result in
two unsplit strings in a list, instead of the split arguments in a list

Fixes: #8348
2021-02-19 17:16:42 +02:00
Dylan Baker 6c1467db27 compilers: Only insert -flto-jobs in clang's link arguments
Clang has a hand `-Wunused-command-line-argument` switch, which when
turned to an error, gets very grump about `-flto-jobs=0` being set in
the compiler arguments (although `-flto=` belongs there). We'll refactor
a bit to put that only in the link arguments.

GCC doesn't have this probably because, a) it doesn't have an equivalent
warning, and b) it uses `-flto=<$numthreads.

Fixes: #8347
2021-02-17 18:06:52 +02:00
Olexa Bilaniuk a2530373c7 Add default debug flags for two configurations to NVCC. 2021-02-16 14:46:17 -05:00
Jussi Pakkanen 6a75d6c233 Add custom entyr to cuda buildtype dict. Closes #8336. 2021-02-14 18:41:07 +02:00
Dylan Baker 6f532b72c8 Add support for LLVM's thinLTO
This uses a separate option, b_lto_mode. It works in conjunction with
b_lto_threads.

Fixes #7493
2021-02-02 12:42:48 -08:00
Dylan Baker bffc94b08f compilers: Add support for using multiple threads with lto
Both Clang and GCC support using multiple threads for preforming link
time optimizaions, and they can now be configured using the
`-Db_lto_threads` option.

Fixes #7820
2021-02-02 12:42:48 -08:00
Antonin Décimo 39ede12aa5 Fix misspells
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-13 12:53:10 -05:00
Dylan Baker 4b0b44afac move handling of CFLAGS and friends to environment
This has a bunch of nice features. It obviously centralizes everything,
which is nice. It also means that env is only re-read at `meson --wipe`,
not `meson --reconfigure`. And it's going to allow more cleanups.
2021-01-11 11:15:06 -08:00
Dylan Baker f202da0689 use PEP8 style naming for LANGUAGES_USING_* as well 2021-01-11 11:15:06 -08:00
Dylan Baker 4580433b82 rename cflags_mapping to CFLAGS_MAPPING
This is PEP8 convention for a const variable. Also, make the type
Mapping, which doesn't have mutation methods. This means mypy will warn
us if someone tries to change this.
2021-01-11 11:15:06 -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
Dylan Baker f9b19e73a5 move OptionKey to mesonlib
There's starting to be a lot of things including coredata that coredata
needs to itself include. putting it in mesonlib makes more sense
2021-01-04 12:20:40 -08:00
Dylan Baker fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Laurin-Luis Lehning 4164efceca Propagate Windows target checks up 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 919278e3e1 Give get_gui_app_args access to the Environment 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 4053babf9c Slight consistency changes to get_gui_app_args 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 9de09e9aa6 Give get_win_subsystem_args access to env 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 2fb4d1f751 Make win_subsystem a linker property 2020-12-14 11:23:53 -08:00
Jussi Pakkanen 5bd1276d20 Create unit test for C++ modules and accept ixx as C++ source extension. 2020-12-11 19:21:02 +00:00
Jussi Pakkanen c21b04ba08 Add prelinking support for static libraries. 2020-12-03 22:58:07 +02:00
Christoph Reiter abc7e6af01 Add a variant of TemporaryDirectory that uses windows_proof_rmtree()
Adds TemporaryDirectoryWinProof which calls windows_proof_rmtree() on
error.

Use instead of hacky error handling (which might shadow other OSError)
in Compiler.compile().
2020-11-23 09:26:41 -08:00
Jussi Pakkanen c8af3c8d29 Revert "Add thinlto support. Closes #7493."
This reverts commit 3e6fbde94c.
2020-11-17 17:51:23 +02:00
Christoph Reiter 5dd174c60b Fix "generator doesn't stop" on Windows
When TemporaryDirectory() cleans up on __exit__ it sometimes throws
OSError noting that the dir isn't empty. This happens after the
first yield in this generator and leads to the exception being handled
which leads to a second yield.

contextlib.contextmanager() fails then since the function it wraps is only
allowed to yield once.

Fix this by not yielding again in the error case.

Fixes #7947
2020-11-08 19:10:48 +02:00
Jussi Pakkanen 3e6fbde94c Add thinlto support. Closes #7493. 2020-11-08 16:00:05 +02:00
Xavier Claessens 7902d2032d Refactor handling of machine file options
It is much easier to not try to parse options into complicated
structures until we actually collected all options: machine files,
command line, project()'s default_options, environment.
2020-10-16 17:42:24 -04:00
Peter Harris 8b8a610ea4 vs: add static_from_buildtype to b_vscrt 2020-10-14 19:35:28 +03:00
Jussi Pakkanen 1a0603835e Add win_subsystem kwarg. Closes #7765. 2020-10-07 18:55:25 +03:00
Dylan Baker 135f5d5838 compilers: make get_optimization_args abstract 2020-10-01 15:06:10 -07:00
Dylan Baker 6a9761a2c0 compilers/d: add type annotations 2020-10-01 15:06:10 -07:00
Dylan Baker 738e343860 compilers: move _build_wrapper out of clike into Compiler
This abstraction is really useful, and most compilers could use it
(including D). It also will allow the Gnu mixins to work properly
without the CLikeCompiler in their mro.
2020-10-01 15:05:01 -07:00
Dylan Baker 8291e947f5 compilers: move get_compile_check_args() to Compiler
This is groundwork to put _build_wrapper in the base Compiler, which is
needed to make the D compilers truly type safe.
2020-10-01 15:05:01 -07:00
Dylan Baker e039727e63 compilers/fortran: add type annotations 2020-10-01 15:05:01 -07:00
Dylan Baker efceec9615 Compilers/vala: Add type annotations 2020-10-01 15:05:00 -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 413f4d87e9 compilers/cs: Add type annotations 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 1513aa437d compilers: move split_shlib_to_parts to the base compiler
Only the GnuLikeCompiler overrides this, and it's implemented multiple
places
2020-10-01 15:05:00 -07:00
Dylan Baker fe97977b00 compilers/cpp: Add type annotations 2020-10-01 15:05:00 -07:00