Commit Graph

1078 Commits

Author SHA1 Message Date
Arsen Arsenović 57ce83b396 compilers/c_function_attributes: add retain
retain is a relatively young attribute which has proven itself useful
for working with --gc-sections -z start-stop-gc.
2022-01-26 19:22:17 -05:00
Gatgat f3a8e5d3b2 Fix system include arguments for clang-cl 2022-01-15 22:00:05 +05:30
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
Jussi Pakkanen 251d6f0f5d
Merge pull request #9739 from mathstuf/armclang-support
Armclang support
2022-01-10 19:01:11 +02:00
Ben Boeckel f30e83efd6 armltdclang: add support for ARM Ltd.'s `armclang` toolchain
This is another toolchain also called `armclang`, but it is not a cross
compiler like Keil's `armclang`. It is essentially the same as `clang`
based on its interface and CMake's support of the toolchain.

Use an `armltd` prefix for the compiler ID.

Fixes: #7255
2022-01-03 12:49:04 -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
Tristan Partin 269337ceb2 Fix mypy 0.930 issues
Removed errant "type: ignore".

Fixed issue with "fetch" call. This issue was the following:

Dict::get() and Dict::pop() have the following signature:

T.Callable[[_T, _U], _U | None] OR T.Callable[[_T], _U | None]

Note how the return type is _U here. When the fetch() function was
actually being called, it had the following signature:

T.Callable[[_T, T.List[_U]], T.Union[T.List[_U], _U]]

This is incompatible with the previous definitions. The solution is
simply to move where the default value is introduced if fetch() produces
None.
2021-12-30 00:53:58 -05:00
Ben Boeckel 28de74c994 armclang: clarify that this is support for the Keil cross-compiler 2021-12-16 17:08:10 -05:00
Sahnvour d9c73a6a7b clang-cl: add a translation pass for `-isystem` args to work 2021-12-08 00:53:29 +02:00
Luke Elliott d014ccf8d7 Fix _calculate_toolset_version for VS2022. 2021-11-27 21:46:16 +02:00
Nathanael Gray c2956269f5 Add -g for debug builds. 2021-11-27 20:08:14 +02:00
Nathanael Gray 2bc3117408 Fix more code which appears copied from CcrxCompiler. 2021-11-27 20:08:14 +02:00
Denis Feklushkin 1b1ecec920 ldc2: invoke -Oz instead of -Os 2021-11-22 12:35:28 -08:00
William Toohey 679adc7bf5 Support ancient (<3.4.0) gcc versions 2021-11-16 06:45:33 -05:00
Eli Schwartz ee5428d64f only pass clang LTO arguments when they are needed
If the LTO threads == 0 clang will default to the same argument we
manually pass, which meant we dropped support for admittedly ancient
versions of clang that didn't yet add that option.

Drop the extraneous argument, and add a specific error condition when
too old versions of clang are detected.

Fixes #9569
2021-11-15 22:00:53 +02:00
Nathanael Gray ae3d495c37 Remove incorrect arguments for C2000 C++ compiler. Add correct form for output and include args. 2021-11-14 21:59:59 +02:00
Dylan Baker f48d75dcae compilers/java: Add no_warn_args and debug_args methods 2021-11-08 23:33:14 +02:00
Eli Schwartz 038b31e72b
various manual conversion of percent-formatted strings to f-strings 2021-11-01 20:26:18 -04:00
William D. Jones 94a5ffabf3 Add 64-bit paths to check for unsupported Watcom cl.exe clones. 2021-10-31 21:38:53 -04:00
Eli Schwartz 384151c541 migrate python 3.5 compatible superclass variable annotations to 3.6
As we now require python 3.6, we can declare their types without
initializing them.
2021-11-01 00:46:51 +02:00
Eli Schwartz f36c01ede9 Revert "known Python 3.5 on windows workaround for subprocess(cwd=str(Path))"
This reverts commit c89aa20941.

We no longer support 3.5 so this can go.
2021-11-01 00:46:51 +02:00
Xavier Claessens 7a12c911bf Remove duplicated CEXE_MAPPING table 2021-10-29 22:42:21 +03:00
Eli Schwartz 8947352889 fix various flake8 whitespace errors 2021-10-27 09:51:52 -04:00
Jussi Pakkanen 4840c86ec9 Add sccache support. 2021-10-25 19:59:49 -04:00
Moroz Oleg 012ec7d5b3 Add stdc++20 support for Visual Studio 2019 v16.11
fix #9242
2021-10-24 17:08:13 +03:00
Dylan Baker 034b3a92d9 compilers/rust: fix typo in standard description 2021-10-21 13:48:01 -04:00
Dylan Baker 841dc2a4e7 compilers/rust: add support for the 2021 edition 2021-10-21 13:48:01 -04:00
Xavier Claessens a3f3ddf581 cuda: Override std=none to avoid host_compiler to emit -std argument 2021-10-14 14:17:50 -04:00
Christian Clauss a5020857f3 Fix typos discovered by codespell 2021-10-10 16:12:25 -04:00
Vladimír Čunát 98d1ec7a32 clike compilers: drop semicolon at function end
warning: ISO C does not allow extra ';' outside of a function [-Wpedantic]
2021-10-07 09:42:52 -07:00
Jesse Natalie b19530bd7d Fix compiler detection for cl/clang-cl
If the compiler specified is a path to a compiler, the current detection is broken. It needs to use just the compiler name instead.
2021-10-06 13:35:24 -07:00
Eli Schwartz 4ab70c5512
fix extra whitespace
discovered via flake8 --select E303
2021-10-04 16:29:31 -04:00
Eli Schwartz 52c4df1ba7
use idiomatic python for membership tests
"X not in Y" is preferred over "not X in Y", as the former is more
readable.
2021-10-04 16:29:31 -04:00
makise-homura e58b3adc70 Fix mypy errors 2021-09-29 20:16:02 -07:00
makise-homura 0021a21930 compilers/elbrus: Deal with C/C++/Fortran stds more correctly 2021-09-29 20:16:02 -07:00
makise-homura 0ed2d2719b compilers: Select correct clang on e2k for C++ and ObjC++ 2021-09-29 20:16:02 -07:00
makise-homura fe0809360d compilers: There is clang for e2k (elbrus) platform finally 2021-09-29 20:16:02 -07:00
makise-homura 79f9a2076a compilers/elbrus: Support prelinking with lcc correctly 2021-09-29 20:16:02 -07:00
makise-homura d9b379df87 compilers/elbrus: Fix incorrect inheritance model of Elbrus*Compiler 2021-09-29 20:16:02 -07:00
Jussi Pakkanen fa47d8dab0
Merge pull request #9014 from bonzini/mixed-language-link
Use appropriate compiler for the source file for "links" tests with file argument
2021-09-28 17:32:44 +03:00
Jussi Pakkanen f6ae82169c
Merge pull request #8773 from dcbaker/submit/rustc-enhancements-clippy
More enhancements for Rust + clippy support
2021-09-25 14:42:12 +03:00
Dylan Baker 30202a2402 compilers/rust: Add support for clippy
Clippy is a compiler wrapper for rust that provides an extra layer of
linting. It's quite popular, but unfortunately doesn't provide the
output of the compiler that it's wrapping in it's output, so we don't
detect that clippy is rustc. This small patch adds a new compiler class
(that is the Rustc class with a different id) and the necessary logic to
detect that clippy is in fact rustc)

Fixes: #8767
2021-09-24 18:48:48 -07:00
Dylan Baker 6ca732991d compilers/detect: use linker_always_args as well as linker exe_list
Otherwise we don't get critical arguments like -fuse=lld.
2021-09-24 18:48:48 -07:00
Dylan Baker 6514abf681 rustc: implement pic args 2021-09-24 18:48:48 -07:00
Dylan Baker d32fc0563d compilers/rust: Implement warning levels
Currently this implements 3 warning levels, 1 and 2 are just the
"default" set by rustc, 3, is "everything is a warning", and 0 is
"nothign is a warning".
2021-09-24 18:48:48 -07:00
Dylan Baker e2260650a0 rust: Add werror arguments 2021-09-24 18:48:48 -07:00
Dylan Baker 79ed1f985c compilers/detect: avoid mutating rustc compiler list
Because mutation is bad.
2021-09-24 18:48:48 -07:00
Dylan Baker 64c267c49c compilers: Add default search path stdlib_only_link_flags
This should be done in all cases of language_stdlib_only_link_flags, but
I don't have access to all of the compilers to test it.

This is required in cases where object files created by gfortran are
linked using another compiler with a differen default search path, such
as gfortran and clang together.
2021-09-25 00:18:22 +03:00
Jussi Pakkanen fee5cb697c
Merge pull request #9167 from dcbaker/submit/meson-main-type-checking
Add type annotations and type checking to meson main
2021-09-24 23:40:52 +03:00
Dylan Baker 68c23a6120 Add option to to transpile Cython to C++
This patch adds a new meson built-in option for cython, allowing it to
target C++ instead of C as the intermediate language. This can, of
course, be done on a per-target basis using the `override_options`
keyword argument, or for the entire project in the project function.

There are some things in this patch that are less than ideal. One of
them is that we have to add compilers in the build layer, but there
isn't a better place to do it because of per target override_options.
There's also some design differences between Meson and setuptools, in
that Meson only allows options on a per-target rather than a per-file
granularity.

Fixes #9015
2021-09-24 22:56:46 +03: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
Andrea Pappacoda 68eca11cc6 Use -Oz when optimization=s in Clang
-Oz is the appropriate flag to use when you want to produce the smallest
possible binary, and is one would expect when setting optimization to s
or using the minsize build type.
2021-09-21 09:58:48 -07:00
Rohit Goswami 32ba349f0a compilers: Use standards compliant test 2021-09-20 01:29:59 -04:00
miebka 59fe80602e C2000: Added depfile generation for incremental builds 2021-09-16 02:37:13 +03:00
Eli Schwartz 87e13af1c8
apply flake8 fixes for unused imports and missing imports 2021-09-14 15:55:07 -04:00
Eli Schwartz cbfdfca089
compilers: publicly export one more constant
It is imported from a subpackage in __init__ alongside a big list of
other things which are all exported. And elsewhere, this import is
re-imported by other code. It's pretty clearly an oversight that it
didn't get added to __all__
2021-09-14 15:50:29 -04:00
Mat Cross 85a5aed60f nagfor preprocessor flag. 2021-09-10 16:08:57 -04:00
Mat Cross 436a257c50 Comments on nagfor options setup. 2021-09-10 16:08:57 -04:00
Mat Cross 0e86258748 Implemented some missing operation for the NAG Fortran Compiler. 2021-09-10 16:08:57 -04:00
Eli Schwartz 3f796c43df objc/objcpp compiler: accept all gnu stds corresponding to c/c++ stds
The clang compiler now reimplements and re-checks the c_std and cpp_std
options in order to use them for objc as well, but it didn't
consistently support the same options. First it completely excluded all
the gnu ones, and then it added a handful of them but not for C++.

Be fully consistent -- or at least as consistent as we can be, given a
minimally working fix. (The C/C++ compiler mixin actually gates
different stds depending on detected clang version, we do not do that
here.)

Fixes regression in c54dd63547
Fixes incomplete fix from #8766 (which didn't fix objcpp at all)

Fixes #9237
2021-09-10 13:03:56 -07:00
Paolo Bonzini 8596b3bcd1 interpreter: detect and pass compiler to be used for linker tests
Allow using the links method to test that the C++ driver (e.g. g++) can be used to
link C objects.  One usecase is that the C compiler's libsanitizer might not be
compatible with the one included by the C++ driver.

This is theoretically backwards-incompatible, but it should be treated as a
bugfix in my opinion. There is no way in Meson to compile a .c file with the
C++ driver as part of a build target, therefore there would be no reason to
do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')).

Fixes: #7703
2021-09-07 14:18:33 +02:00
Paolo Bonzini 90ee43463f compilers: allow link tests to use objects from a different compiler
In some cases, link tests would like to use objects provided by a compiler
for a different language, for example linking a C object file with a C++
compiler.  This kind of scenario is what link_language is for, but it is
impossible to test that it works with a linker test.

This patch implements the required support in the Compiler class.  The
source code compiler is passed to the Compiler.links method as an
argument.
2021-09-07 13:38:12 +02:00
Paolo Bonzini 2997480ee6 compilers: do accept None in Compiler.compile extra_args
The type information allows it, but it is not actually handled.
2021-09-07 13:37:37 +02:00
Paolo Bonzini 63ddb8aafa compilers: fix flake8 issues 2021-09-07 13:37:36 +02:00
Evan Miller b8cfb3d131 Support for appleframeworks with GCC and Intel
Fixes #8792
Fixes #8733
2021-09-04 01:29:35 +03:00
Dylan Baker 9bf669a016
Clang should error for all implicit function checks (#9165)
* compilers: improve docstring to `get_compiler_check_args()`

There was an incomplete list, which wasn't useful as it now takes an
enum anyway. Also add a new entry to the list of reasons to use this
function.

* clang: Add -Werror=implicit-function-declarations to check_args

Unlike GCC, clang warns but doesn't error when an implicit function
declaration happens. This means in checks like
`compiler.has_header_symbol('string.h', 'strlcat')` (on Linux, at least)
that GCC will fail, as there is no such function; clang will emit a
warning, but since it exists with a 0 status Meson interprets that as
success. To fix this, add `-Werror=implicit-function-declarations` to
clang's check arguments.

There seems to be something specific about functions that _may_ exist in
a header on a given system, as `cc.has_header_symbol('string.h',
'foobar')` will return false with clang, but `strlcat` will return true,
even though it's not defined. It is however, defined in some OSes, like
Solaris and the BSDs.

Fixes #9140
2021-09-01 22:25:32 +03:00
Xavier Claessens ea02c1c48a msvc: Assume UTF8 source by default
Currently every project that uses UTF8 for its source files must add
'/utf-8' argument otherwise they don't work non-English locale MSVC.

Since meson.build itself is assumed to be UTF8 by default, seems better
to assume it for source files by default too.

For example:
- https://gitlab.freedesktop.org/gstreamer/gst-build/-/blob/master/meson.build#L62
- https://gitlab.gnome.org/GNOME/glib/-/blob/main/meson.build#L29
2021-09-01 19:26:36 +03: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
Tristan Partin be92e37837 Add Java module
The Java module will serve as a source for easing Java development
within Meson. Currently it only supports generating native header files.
2021-08-22 07:57:29 -07:00
Dylan Baker a3c94956c8 compilers: Add get_no_warn_args to the base Compiler class
Because it should be defined there.
2021-08-20 18:57:19 +02:00
Dylan Baker 6d055b1e27 compilers/compilers: Fix some potential issues spotted by pyright
There are two changes here, one is to remove an `elif` that is
effectively an `else`, that helps the type checker and provides a small
speedup potentially. The second is a potentially unbound variable, that
currently isn't hit, but very much could be.
2021-08-16 16:21:51 -07:00
Dylan Baker e3c72ad7c7 compilers: Fix extra_args parameter
which can also be a callable taking a CompileChekcMode as an argumetn
and returning a list of strings.
2021-08-16 16:21:51 -07:00
Dylan Baker e9639be167 compilers: Fix annotations for run and cached_compile
Which absolutely should accept `str | File`, but the annotations claim
that only strings are accepted.
2021-08-16 16:21:51 -07:00
Jussi Pakkanen a90d2925dd Revert "compilers/c++: Add MSVC option to make the __cplusplus define accurate"
This reverts commit 0b97d58548.
2021-08-15 13:18:35 +03:00
Dylan Baker 0b97d58548 compilers/c++: Add MSVC option to make the __cplusplus define accurate
Otherwise it always returns the value for c++98, starting with MSVC 2017
15.7 or later. Earlier versions are not affected by this mis-feature
2021-08-11 21:54:16 +03:00
Jussi Pakkanen f2fe271198 Add support for finding Javascript source libraries with Emscripten. 2021-08-08 15:25:48 +03:00
miebka f8c4752cbc C2000 compiler also accepts *.cla files 2021-07-25 09:07:12 -07:00
David Seifert 28d13f4bfe
Cuda: Enable PGO 2021-07-18 23:14:38 +02:00
David Seifert d648f3497e
Cuda: Filter -isystem with system paths 2021-07-18 23:14:36 +02:00
David Seifert 631abce82f
Cuda: Pass -DNDEBUG through 2021-07-18 23:14:34 +02: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
Pamplemousse 762c073500 Clang: Apply `-O0`
Fix #8986
2021-07-13 16:40:40 -07:00
Andrea Pappacoda 81d9acab87 Fix unsupported linker error message
An `f` was dropped in bd6f46e723
2021-07-06 11:46:20 -04:00
Eli Schwartz bd6f46e723 condense lines 2021-07-05 17:55:04 +03:00
Eli Schwartz b4b488f33c simplify mesonlib imports for the sake of line lengths 2021-07-05 17:55:04 +03:00
Eli Schwartz dd31891c1f more f-strings too complex to be caught by pyupgrade 2021-07-05 17:55:04 +03:00
miebka 3021f256ea C2000: linker uses now binary setting defined within the cross-file 2021-07-01 01:58:24 +03:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Ian Harvey 84b371c645 Update detect.py
Adjust Intel Fortran compiler detection to handle changes in ifort logo with the introduction of the oneapi toolkit.  See #8338.
2021-06-27 17:50:30 +03:00
Daniel Mensinger b95d6e319f typing: Annotate compilers.detect 2021-06-25 19:34:48 +02:00
Daniel Mensinger 3f889606c7 Split compiler detection from Environment
This moves all the compiler detection logic into the new
compilers.detect module. This dramatically reduces the size
and complexity of Environment.
2021-06-25 19:34:48 +02:00
Justin Handville e8e03cdc72 Fixed style issue as per comments on PR 8911. 2021-06-22 12:46:17 +02:00
Justin Handville 9f248c778d Fix for Issue 8910 (Meson filters CMake asm files) 2021-06-22 12:46:17 +02:00
Daniel Mensinger 66b32a4591 holders: Introduce HoldableObject 2021-06-18 23:48:33 +02:00
Daniel Mensinger 202e345dfb interpreter: Refactor interpreter.compiler to use ObjectHolder 2021-06-18 23:48:33 +02:00
Daniel Mensinger 9c40b33cf6 compilers: Fix missing functions in Compiler base class 2021-06-09 09:46:37 +02:00
Eli Schwartz 998076a192
upgrade percent formatted strings pyupgrade did not catch 2021-06-07 16:51:47 -04:00
Eli Schwartz 3eb1da1fa2
condense lines 2021-06-07 16:51:47 -04:00
Eli Schwartz 2c71b63e77
more f-strings everywhere
pyupgrade didn't catch many .format() methods which were too complex
(e.g. multiline or applied to templates rather than string literals)
2021-06-07 16:51:47 -04:00
Dylan Baker 0bc18f26a2 cython: Add an option for selecting python 3 vs python 2 output 2021-06-07 09:25:32 -07:00
Dylan Baker 4d1cbd1b8a compilers: Add cython file suffixes 2021-06-07 09:16:19 -07:00
Dylan Baker edf1a21722 compilers: Expose Cython compiler 2021-06-07 09:16:18 -07:00
Dylan Baker e9681b463d hack: compilers/cython: hardcode python 3 not 2 2021-06-07 09:15:13 -07:00
Dylan Baker 79e50caa7f compilers: Add a cython Compiler 2021-06-07 09:15:13 -07:00
Daniel Mensinger 240434b167 typing: Fully annotate dependencies.cuda 2021-06-05 12:35:48 +02: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
Dylan Baker b1b8e777a2 rust: override get_linker_always_args
instead of opencoding what should be there in the rust compile rule
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
Peter Harris be015a37d7
Visual Studio Address Sanitizer updates
* Allow address sanitizer for Visual Studio 2019 version 16.9

Address Sanitizer was first supported with the current syntax in Visual
Studio 16.9.0 (cl version 19.28.29910).

* VS: Convert /fsanitize=address to project file setting
2021-05-15 18:47:04 +03:00
Jussi Pakkanen ab0b727427 Add gnuXX stds to Objective C. 2021-05-15 18:45:54 +03:00
Jussi Pakkanen c54dd63547 Make objective C use C standard version. Closes #5495. 2021-05-11 22:47:17 +03:00
Alexander Neumann 8f12102549 deactivate intrinsic functions if no optimizations are requested 2021-05-10 19:17:39 +03:00
Ralf Gommers a48a89374a Clean up unused imports 2021-05-02 22:27:40 +03:00
Ralf Gommers d0325c898a Use sanity_check_impl for objc/objpp
This gets rid of compile warnings, and simplifies the code.
Note that `work_dir` in sanity_check_impl was incorrect,
it was used both to prepend to file names and as cwd=work_dir
argument to Popen. This is fixed here.

Closes gh-7344
2021-05-02 22:27:40 +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
Olexa Bilaniuk 2579420a72 Strip host-compiler -std flag from NVCC line.
Closes #8523.
2021-03-28 20:12:45 +03:00
Olexa Bilaniuk 5941e94ff8 Retract "DQSQ" merging in NVCC arguments handling.
No coverage, no tests, unreadable, unused, likely premature
optimization.
2021-03-28 20:12:45 +03:00
Olexa Bilaniuk 3dbd493de2 Canonicalize and merge consecutive -Xcompiler flags together.
Makes command-line more readable.
2021-03-28 20:12:45 +03:00
D Scott Phillips 703fd6d1fa
compilers: clang-cl: Also accept .s files (#8520)
* compilers: clang-cl: Also accept .s files

clang-cl has support for gas-compatible assembly files.

* Add clang-cl to '128 generated assembly' test
2021-03-24 12:43:51 +02:00
Jussi Pakkanen 9ab4dadef9 Remove -pipe from default list of args. Closes #8508. 2021-03-23 17:26: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
Jussi Pakkanen d76345b4be Add address sanitizer support for Visual Studio. 2021-03-09 13:52:15 -08:00
Vili Väinölä 96405c3923 Add /Od flag to msvc optimization 0 args
Without specifying optimization the used optimization depends on vs runtime-library.
With mdd it is /Od but with md it is /O2.
2021-03-08 22:11:04 +02: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
Eli Schwartz 76df995ba6
raw string literals are next to godliness
Invalid escape sequences are deprecated and will be removed from a
future version of python. Use r"" to define them so they remain
readable.
2021-03-04 17:09:00 -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
Olexa Bilaniuk 4c1a0c400f [CUDA] Bugfix: Forward sanitizer_*_args() methods to host compiler.
Enables -Db_sanitize=undefined and company.

Also serves as a testcase for NVCC comma-shielding: Because the test-
case declares `b_sanitize=address,undefined`, the host GCC compiler
needs `-fsanitize=address,undefined`, but this stands a danger of being
split by NVCC when wrapped with `-Xcompiler=args,args`. Special,
already-existing comma-shielding codepaths activate to prevent this
splitting.

Closes #8394.
2021-02-22 23:56:55 +02: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
Krzysztof Małysa c24a0f8524 compilers: clang: Drop -Xclang before -fcolor-diagnostics flag
Using -Xclang -fcolor-diagnostics provides no advantage to using just -fcolor-diagnostics option and sometimes causes problems:
* uncolored diagnostics on Arch Linux: https://bugs.archlinux.org/task/69662
* simple problem with removing flag -fcolor-diagnostics:  https://github.com/clangd/clangd/issues/279
2021-02-18 17:30:33 +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 d1e945f442 Add optional -Dcuda_ccbindir= option and -ccbin flag to CUDA compiler.
Closes #8110.
2021-02-16 15:10:21 -05:00
Olexa Bilaniuk cc09d984f1 Armour-grade quoting to account for NVCC's -Xcompiler peculiarities. 2021-02-16 15:10:11 -05:00
Olexa Bilaniuk 3669be30aa Extensive rewrite of GCC/MVSC flag translation to NVCC flags. 2021-02-16 15:00:31 -05: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
Dylan Baker 23d3b98fc1 split mesonlib into a package
Currently mesonlib does some import tricks to figure out whether it
needs to use windows or posix specific functions. This is a little
hacky, but works fine. However, the way the typing stubs are implemented
for the msvcrt and fnctl modules will cause mypy to fail on the other
platform, since the functions are not implemented.

To aleviate this (and for slightly cleaner design), I've split mesonlib
into a pacakge with three modules. A universal module contains all of
the platform agnositc code, a win32 module contains window specific
code, a posix module contains the posix specific code, and a platform
module contains no-op implementations. Then the package's __init__ file
imports all of the universal functions and all of the functions from the
approriate platform module, or the no-op versions as fallbacks. This
makes mypy happy, and avoids `if`ing all over the code to switch between
the platform specific code.
2021-01-23 12:48:29 +01:00
Marios Staikopoulos f8681b12e1 MSVC and Clang-Cl Compiler Argument Cleanup
This commit performs some cleanup for the msvc and clang-cl arguments.

* "Disable Debug" (`/Od`) is no longer manually specified for optimization levels {`0`,`g`} (it is already the default for MSVC).
* "Run Time Checking" (`/RTC1`) removed from `debug` buildtype by default
* Clang-CL `debug` buildtype arguments now match MSVC arguments
* There is now no difference between `buildtype` flags and `debug` + `optimization` flags
2021-01-20 14:11:16 -05:00
Brion Vibber d808429a48 Avoid accidental use of STANDALONE_WASM mode on compiler tests
Compiler tests, such as checking for atomics support, could fail
when compiling to WebAssembly multithreaded targets because the
compiler tests got compiled to 'output.wasm'.

Using the '.wasm' suffix in recent versions of emscripten engages
STANDALONE_WASM mode, which disables features that require a JS
runtime like shared memory.

This created false negatives on support of those features when
building a library to be linked into an executable that is not
in STANDALONE_WASM mode.

Changing these to 'output.o' will continue to produce WebAssembly
object files, but they will no longer be configured for standalone
runtime mode.
2021-01-20 19:10:21 +00:00
Marios Staikopoulos a3d8dc546c Removal of /ZI on MSVC Debug
The /ZI flag adds in "Edit and Continue" debug information, which will
cause massive slowdown. It is not a flag that we should be adding by
default to debug builds.

/Zi will still be added.
2021-01-17 21:03:35 +00: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 e81acbd606 Use a single coredata dictionary for options
This patches takes the options work to it's logical conclusion: A single
flat dictionary of OptionKey: UserOptions. This allows us to simplify a
large number of cases, as we don't need to check if an option is in this
dict or that one (or any of 5 or 6, actually).
2021-01-04 12:20:58 -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
Dylan Baker bdca05e2e6 Add choices to OptionProxy
they're probably not strictly needed, but it makes mypy happy.
2021-01-04 12:15:41 -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
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 9f1ba40252
Merge pull request #8013 from mesonbuild/cppmodules
C++ module support
2020-12-14 15:00:04 +00:00
Laurin-Luis Lehning bab1087422
Add support for driving lld-link indirectly through clang on Windows 2020-12-13 16:34:50 +02: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
Florian Schmaus a7aba905a0 compilers: add support for c++20/gnu++20
Fixes #8084.
2020-12-10 00:30:48 +02:00
Jussi Pakkanen c21b04ba08 Add prelinking support for static libraries. 2020-12-03 22:58:07 +02:00
Dylan Baker 8915538c31 compilers/fortran: Add "none" to intel compielrs for standards
Fixes #8023
2020-11-24 23:11:23 -05: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
Dylan Baker f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08:00
Jussi Pakkanen c8af3c8d29 Revert "Add thinlto support. Closes #7493."
This reverts commit 3e6fbde94c.
2020-11-17 17:51:23 +02:00
Jussi Pakkanen 299a67781e
Merge pull request #7843 from dcbaker/submit/rustc-fixes
A few fixups for rust
2020-11-14 13:47:39 +02:00
jpark37 2748c9fb3d msvc: enable /std:c17 flag
Increase allowed c_std options, and check compiler version.

Also update mlog pattern to not crash.
2020-11-13 16:13:02 -08:00
Dylan Baker 5afd608a75 compilers/rust: add and use an implementation of use_linker_args 2020-11-13 09:00:35 -08:00
Jussi Pakkanen 91876b4031
Merge pull request #7866 from dcbaker/submit/compiler-std-in-base
Put the Compiler standard option in the Language mixin
2020-11-13 17:49:52 +02:00
Dylan Baker f31acbe2a4 clang-cl: Allow clang-cl (when compiling C) to pass std to underlying clang)
This allows a wider array of standard support than would be available
directly from clang-cl, emulating MSVC stds.
2020-11-12 12:52:27 -08:00
Dylan Baker 0217faf13f compilers/c: Log that MSVC doesn't support gnu stds
Since the current approach of demoting to the nearest C standard *might*
work, but might not. For projects like Glib that detect which standard
is used and fall back this is fine. For projects like libdrm that only
work with gnu standards, this wont. We're nog tusing a warning because
this shouldn't be fatal if --meson-fatal-warnings is used. Also demote a
similar message in IntelCl from warning to log.
2020-11-12 10:06:11 -08:00
Dylan Baker 2844afedde compilers: define standards in the base language compiler
And then update the choices in each leaf class. This way we don't end up
with another case where we implicitly allow an invalid standard to be
set on a compiler that doesn't have a 'std' setting currently.
2020-11-12 10:03:15 -08:00
Dylan Baker a28a34c684 compilers: Standardize the names of compiler options
Most options don't use language prefaced options (std vs c_std)
internally, as we don't need that due to namespacing. Let's do that
across the board
2020-11-12 10:03:14 -08:00
Dylan Baker 3e62307f3a compilers/c: Clang-cl also needs specific handling for standards 2020-11-12 10:03:14 -08:00
Jussi Pakkanen 333e0aeef4 Make MSVC accept gnu11 as a language standard version. Closes: #7611.
Fixes: #7611
2020-11-12 10:03:14 -08:00
Dylan Baker ce46070b4e compilers/rust: Add color output
Rust has color output, although it's help doesn't document it. It uses
the same values as cargo (and everything else), auto, never, always.
2020-11-10 12:09:21 -08:00
Dylan Baker e430c01ef5 compilers/rust: Add vs_crt support
As far as I can Tell, rust just handles this for us (it's always worked
with no special arguments from us). However, since we're going to add
support for base options for rust, we need to add the method.
2020-11-10 12:09:03 -08:00
Jussi Pakkanen dffd66e0ff Fix WASM thread count option. Closes #7921. 2020-11-09 23:06:52 +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
Dylan Baker 7860a6aeab rust: implement support for --edition
Using the std option, so now `rust_std=..` will work. I've chosen to use
"std" even though rust calls these "editions", as meson refers to
language versions as "standards", which makes meson feel more uniform,
and be less surprising.

Fixes: #5100
2020-11-05 21:24:20 +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
Carlos Bederian c3b3dc598e compilers/cuda: Use format_map(mapping) instead of format(**mapping) 2020-10-16 18:18:46 +02:00
Carlos Bederian f09457a1e8 compilers/cuda: Fix has_header_symbol check 2020-10-16 18:18:46 +02: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
Vinson Lee 5d7069664b compilers: Enable C++20 for Intel C++ Compiler.
Intel C++ Compiler 19.1 has C++20 features.

https://software.intel.com/content/www/us/en/develop/articles/intel-c-compiler-191-for-linux-release-notes-for-intel-parallel-studio-xe-2020.html

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
2020-10-06 22:11:34 +03:00
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Dylan Baker 2fe400c350 compilers/icl fix IntelClCPP argument checking
Unlike MSVC and ClangCl it needs to call into it's own compiler check
args
2020-10-01 15:06:10 -07:00
Dylan Baker f9316fbb46 compilers/icl: Fix pch usage 2020-10-01 15:06:10 -07:00
Dylan Baker b309f4904b compilers/fortran: make ifort on windows signature match ICL's 2020-10-01 15:06:10 -07:00
Dylan Baker ff51e1c5aa compilers/clike: Store exe_wrapper as ExternalProgram
Which is what other languages do.
2020-10-01 15:06:10 -07:00