Commit Graph

897 Commits

Author SHA1 Message Date
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