Commit Graph

1079 Commits

Author SHA1 Message Date
Eli Schwartz f4cc60bf20 flake8: move typing-only imports into T.TYPE_CHECKING 2022-08-29 23:32:43 +03:00
Alf Henrik Sauge 06bf9a5cda Fix purely white space issues reported by flake8 2022-08-26 17:12:40 -04:00
Eli Schwartz 27748f9cd1
fix linker regression for compilers that don't accept LDFLAGS directly
e.g. ldc -- the compiler needs to process args before consuming them.

Fixes #10693
2022-08-24 23:49:14 -04:00
Dylan Baker d6b9d431ec linkers: Add a representation for the Apple AR Linker
Which is old and annoying and doesn't expose global symbols by default,
so we need a work around.

see: https://github.com/mesonbuild/meson/pull/10587
see: https://lists.gnu.org/archive/html/libtool/2002-07/msg00025.html
2022-07-25 15:36:59 -07:00
Justin Blanchard ec388fe7c2 ar linker: detect the "osx ld" case (where generating thin archives won't work) based on host OS, not build OS. 2022-07-21 22:00:00 -07:00
Eli Schwartz 0eed99318b
compilers: add logging to obscure compiler defines scraper
If this command fails, for example when CXX is something not generic
enough to be a valid universal compiler command (clang -std=c++11
perhaps), we end up with two problems:

- it's impossible to figure out what Meson ran to get that error

- the error report isn't clear on what is stdout and what is stderr, or
  even that that is what the message is about.

  ```
  meson.build:1:0: ERROR: Unable to get clang pre-processor defines:
  error: invalid argument '-std=c++11' not allowed with 'C'
  ```

  What's C doing there and why is Meson talking about it? Answer: that's
  compiler stdout. Say so.
2022-07-21 16:45:01 -04:00
Eli Schwartz 1f527550c6
compilers: include compiler detection output in the debug logs
We do something similar when running get_compiler() method checks from
the DSL. This ensures that if errors happen, the log file we tell people
to check actually works.
2022-07-21 16:45:01 -04:00
Eli Schwartz 93ba937186
compilers: better reporting of command failures
Use join_args to ensure that commands are rendered correctly.
2022-07-21 16:45:00 -04:00
Eli Schwartz 46793145ba
Revert /utf-8 changes in the visualstudio mixin to the 0.62.0 state
Specifically, this is a combination of the following:

- Revert "visualstudio.py: Apply /utf-8 only on clang or VS2015+"

  This reverts commit 6e7c3efa79.

- Revert "Visual Studio: Only use /utf-8 on VS2015 or later or clang-cl"

  This reverts commit 8ed151bbd7.

The changes were broken and untested, although this is because of a lack
of general CI testing for all languages on Windows. At least, this broke
the use of ifort, and possibly more.

The changes are fundamentally a bit "exciting", as they step out of the
hierarchy of compiler definitions and apply arguments almost willy-nilly.

And apparently it's leaky all over the place. I don't understand all of
what is going on with it, but it plainly failed to achieve its desired
goal and needs to be rolled back ASAP.
2022-07-11 17:58:02 -04:00
Tristan Partin af846a109f Detect Cython and Vala compilers on the build machine always
Transpilers need to run on the build machine in order to generate their
output, which can then be taken by a cross-compiler to create the final
output.
2022-07-06 12:04:59 -07:00
Eli Schwartz 0703ee0aef
move various unused typing-only imports into type-checking blocks 2022-07-03 14:11:31 -04:00
Eli Schwartz 46148f923b
fix totally invalid import of an import
MachineChoice is a mesonlib object, not a compilers object, so it makes
no sense to import it from the latter simply because the latter imports
it too. This results in brittle module dependencies and everything
breaking when a refactor removes it from the latter.

... also it is a typing-only import so while we are fixing it to import
from the right place, we can also put it in a type-checking block.
2022-07-03 14:11:31 -04:00
Chun-wei Fan 6e7c3efa79 visualstudio.py: Apply /utf-8 only on clang or VS2015+
In PR 10263, we didn't account for that we may have initialize the Visual
Studio-like compiler two times, once for a C compiler and once for the
C++ compiler, so we end up with Meson breaking on Visual Studio 2013
or earlier, such as when building GLib.

Fix this by setting up the always_args member of
the VisualStudioLikeCompiler instance during __init__() as needed, so that
we avoid falling into modifying shared objects.
2022-06-21 21:08:06 +03:00
Stepan Nassyr b0158955b7 ACfL version detection with regex 2022-06-10 08:24:52 -07:00
Stepan Nassyr d045c9f79d Allow for 3-component ACfL versions 2022-06-10 08:24:52 -07:00
Eli Schwartz a49cd00d64 treewide: various cleanups to move imports for mypy into typechecking blocks
Along the way, add __future__ annotations where lacking.
2022-06-10 09:15:48 -04:00
Marco Trevisan (Treviño) 29c26d5b26 compilers: Add support for stand-alone leak sanitizer
Leak sanitizer can be enabled without the whole AddressSanitizer, this
can be done by passing -fsanitize=leak as documented at [1].

Meson doesn't support this, so add support for it.

[1] https://clang.llvm.org/docs/LeakSanitizer.html
2022-06-06 09:40:14 -07:00
Dylan Baker d553748b60 compiler: Add missing needs_static_linker to base Compiler class 2022-06-01 22:49:10 -04:00
Andreas Obergschwandtner bfc4e958b4 Fix optimization level 's' for the TI compiler 2022-05-25 07:12:02 -07:00
Eli Schwartz 1c52ac4e15
move various imports into TYPE_CHECKING blocks for neatness 2022-05-23 16:44:08 -04:00
Tristan Partin 5d0538d235 Fix invalid Python overrides
- mismatched method type
- mismatched parameter names
2022-05-19 15:05:53 -04:00
Tristan Partin 8d918e0147 Add cc.has_function_attribute('sentinel') 2022-05-19 15:05:53 -04:00
Tristan Partin 5d438b6aed Add cc.has_function_attribute('section') 2022-05-19 15:05:53 -04:00
Eli Schwartz 7c4087ace5 compilers/gnu: demote visibilty inlineshidden to hidden for unsupported compilers
This option is only valid for C++ and ObjC++, but the kwarg is useful
for mixed language targets. Asking for inlines as well, when the
compiler driver is trying to build the C components of a target, results
in gcc emitting:

```
cc1: warning: command-line option ‘-fvisibility-inlines-hidden’ is valid for C++/ObjC++ but not for C
```

Squelch this warning by filtering it out on Meson's side of things.
2022-05-09 10:49:04 -04:00
Eli Schwartz 04c728a126 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.

See: https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-160

This was originally applied as 0b97d58548
but later reverted because it made the CI red. Try it again, now.

Original-patch-by: Dylan Baker <dylan@pnwbakers.com>
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2022-05-08 14:40:54 -04:00
Khairul Azhar Kasmiran 6b7bc608b7 compiler.has_argument: Add `-Werror=unknown-warning-option` to clang-cl cmd line 2022-05-06 23:09:52 +03:00
Remi Thebault f24ad87e05 implement and test a few compiler checks for D
- run
 - sizeof
 - alignment
 - has_header
2022-04-30 10:07:38 -04:00
Fini Jastrow c16fdaeeca linkers: Add support for mold linker
[why]
Support for the relatively new mold linker is missing. If someone wants
to use mold as linker `LDFLAGS="-B/path/to/mold"` has to be added instead
of the usual `CC_LD=mold meson ...` or `CXX_LD=mold meson ...`.

[how]
Allow `mold' as linker for clang and newer GCC versions (that versions
that have support).

The error message can be a bit off, because it is generic for all GNU
like compilers, but I guess that is ok. (i.e. 'mold' is not listed as
possible linker, even if it would be possible for the given compiler.)

[note]
GCC Version 12.0.1 is not sufficient to say `mold` is supported. The
expected release with support will be 12.1.0.
On the other hand people that use the un-released 12.0.1 will probably
have built it from trunk. Allowing 12.0.1 is helping bleeding edge
developers to use mold in Meson already now.

Fixes: #9072

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-04-30 10:06:22 -04:00
Chun-wei Fan 8ed151bbd7 Visual Studio: Only use /utf-8 on VS2015 or later or clang-cl
The compiler flag only exists on Visual Studio 2015 or later, or clang-cl,
and using this always can interfere with compiler feature detection when
this flag is not supported.

So, remove '/utf-8' from always_args if we are on Visual Studio 2013 or
earlier.
2022-04-25 20:29:16 +03:00
Eli Schwartz a0e7f93414 compilers: fix broken CompCert support for release flags
This has been broken ever since the original implementation. Due to a
typo, the optimization flag used a zero instead of an uppercase "o",
which the compiler then breaks on during argument parsing because it is
an invalid argument.

Fixes #10267
2022-04-13 21:11:09 +03:00
Jussi Pakkanen efc7604ca2
Merge pull request #9989 from ePirat/epirat-fix-uscore-prefix-detection
Fix underscore detection
2022-03-31 16:26:22 +03:00
Marvin Scholz 89620dc8e7 clike: print stderr instead of stdout for debugging
When something goes wrong with running the compiler in
_symbols_have_underscore_prefix_searchbin, print stderr instead,
as it actually contains helpful output while stdout is usually empty
in this case.
2022-03-31 10:55:55 +02:00
Marvin Scholz 1b03441bc4 visualstudio: do not query underscore define with MSVC
MSVC does not has the builtin define to check for the symbol
prefix, so do not try to query it at all, to save some time.
2022-03-31 10:55:55 +02:00
Marvin Scholz f02ffc007c clike: add more reliable ways to check underscore prefix
Fix #5482
2022-03-31 10:55:55 +02:00
Marvin Scholz 4b97c60650 compilers/gnu: use Popen_safe to prevent resource leaks
Fixes the following ResourceWarnings:

ResourceWarning: subprocess 25556 is still running
  _warn("subprocess %s is still running" % self.pid,
ResourceWarning: Enable tracemalloc to get the object allocation traceback

mesonbuild/compilers/mixins/gnu.py:195: ResourceWarning: unclosed file <_io.BufferedReader name=4>
  return gnulike_default_include_dirs(tuple(self.exelist), self.language).copy()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
2022-03-30 16:04:23 -04:00
Xavier Claessens ebbe4425e7 Debian renamed cython to cython3, support both 2022-03-24 10:16:53 -04:00
Xavier Claessens 06d12064d0 OptionOverrideProxy: Make it immutable to avoid copies
It is always used as an immutable view so there is no point in doing
copies. However, mypy insist it must implement the same APIs as
Dict[OptionKey, UserOption[Any]] so keep faking it.
2022-03-22 17:20:48 -04:00
Dylan Baker 655746e8b4 compilers: fix mypy warning in Rust detection 2022-03-22 15:15:29 +02:00
Paolo Bonzini ff844f3a1f fix detection of language standard library paths
The code in the C++ and Fortran compilers' language_stdlib_only_link_flags
method is broken and cannot possibly have ever worked.  Instead of
splitting by line, it splits by whitespace and therefore, instead of
the last line of the compiler output:

 programs: =/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
libraries: =/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0

it is only the last field that has its first 11 characters removed.
Instead of reinventing the wheel with a new and brittle pattern,
reuse get_compiler_dirs.

Fixes: 64c267c49 ("compilers: Add default search path stdlib_only_link_flags", 2021-09-25)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-16 09:24:57 -07:00
Eli Schwartz bfdbf7bf65 remove unused type ignore that mypy 0.940 no longer needs
And now that it doesn't need it, it errors out when you use it.
2022-03-12 00:31:12 +02:00
Eli Schwartz a009eacc65
treewide: string-quote the first argument to T.cast
Using future annotations, type annotations become strings at runtime and
don't impact performance. This is not possible to do with T.cast though,
because it is a function argument instead of an annotation.

Quote the type argument everywhere in order to have the same effect as
future annotations. This also allows linters to better detect in some
cases that a given import is typing-only.
2022-03-07 19:01:04 -05:00
Dylan Baker f9bfeb2add compilers/gnu: set level 0 optimization to '-O0'
GCC with optimization set to 0 does not actually result in no
optimizations, which can be annoying when trying to use a debugger like
gdb, and finding that your variable has been optimized out. We already
do this with clang, so gcc is a bit of an outlier here.
2022-03-02 19:59:45 +02:00
Eli Schwartz 530338782c compilers/d: fix mangling of rpath-link in DMD-like compilers
We didn't consider that it has arguments following it, so the resulting
compiler command line ended up with stuff like:

-L=-rpath-link -L=-L=/path/to/directory -L=more-args

and the directory for rpath-link got eaten up as a regular -L path to
the compiler rather than being passed as -Xlinker to the linker.

Then the -rpath-link would consume the next -Xlinker argument, end up
with the wrong rpath-link (may or may not cause link errors) and then
disappear arguments we need.

As an example failure mode, if the next argument is -soname this treats
the soname text as an input file, which probably does not exist if it
was generated in a subdirectory, and also because it can never be
successfully built in the first place -- though if it did, it would link
to itself which is very wrong.
2022-03-01 18:34:58 -08:00
Eli Schwartz 9daaece785
flake8: fix various whitespace errors with badly aligned code 2022-02-16 23:00:31 -05:00
Eli Schwartz 60c893f1c2
flake8: remove some redundant separators 2022-02-16 18:19:13 -05:00
Eli Schwartz 07d9c72e17
flake8: fix wrong numbers of blank line separators 2022-02-16 18:19:13 -05:00
Eli Schwartz baecebda0e
flake8: fix typoed whitespace surrounding tokens 2022-02-16 18:19:13 -05:00
Tobias Pankrath 91ca3e2d58 dlang: fix #9250 invalid include flag for root directory 2022-02-06 14:16:51 -08:00
William Toohey b4d9b2551c Genericise TI compiler and add MSP430 support 2022-02-02 16:45:05 +02:00
Eli Schwartz ff7a30c0ea mark regex string as raw string to fix invalid escapes 2022-01-27 10:48:01 -08:00
Eli Schwartz 3990dc6d64 flake8: fix indentation style 2022-01-27 10:48:01 -08:00
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