aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
AgeCommit message (Collapse)AuthorFilesLines
2022-04-30linkers: Add support for mold linkerFini Jastrow1-2/+2
[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-03-22OptionOverrideProxy: Make it immutable to avoid copiesXavier Claessens1-2/+2
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-02-16flake8: fix various whitespace errors with badly aligned codeEli Schwartz1-1/+1
2021-12-30fix type annotations for compiler toolchain rpathsEli Schwartz1-1/+1
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-11-01migrate python 3.5 compatible superclass variable annotations to 3.6Eli Schwartz1-5/+3
As we now require python 3.6, we can declare their types without initializing them.
2021-10-29Remove duplicated CEXE_MAPPING tableXavier Claessens1-5/+0
2021-10-10Fix typos discovered by codespellChristian Clauss1-1/+1
2021-09-28Merge pull request #9014 from bonzini/mixed-language-linkJussi Pakkanen1-8/+20
Use appropriate compiler for the source file for "links" tests with file argument
2021-09-25compilers: Add default search path stdlib_only_link_flagsDylan Baker1-1/+1
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-14apply flake8 fixes for unused imports and missing importsEli Schwartz1-2/+2
2021-09-07interpreter: detect and pass compiler to be used for linker testsPaolo Bonzini1-0/+2
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-07compilers: allow link tests to use objects from a different compilerPaolo Bonzini1-2/+12
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-07compilers: do accept None in Compiler.compile extra_argsPaolo Bonzini1-1/+2
The type information allows it, but it is not actually handled.
2021-09-07compilers: fix flake8 issuesPaolo Bonzini1-7/+6
2021-09-01Clang should error for all implicit function checks (#9165)Dylan Baker1-2/+3
* 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-08-20compilers: Add get_no_warn_args to the base Compiler classDylan Baker1-0/+4
Because it should be defined there.
2021-08-16compilers/compilers: Fix some potential issues spotted by pyrightDylan Baker1-2/+4
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-16compilers: Fix extra_args parameterDylan Baker1-13/+15
which can also be a callable taking a CompileChekcMode as an argumetn and returning a list of strings.
2021-08-16compilers: Fix annotations for run and cached_compileDylan Baker1-5/+5
Which absolutely should accept `str | File`, but the annotations claim that only strings are accepted.
2021-08-08Add support for finding Javascript source libraries with Emscripten.Jussi Pakkanen1-1/+2
2021-07-14linkers: remove is_shared_module argument to get_soname_argsPaolo Bonzini1-3/+2
The argument is now unused, drop it.
2021-06-29fix: Always explicitly set encoding for text files (fixes #8263)Daniel Mensinger1-2/+2
2021-06-22Fixed style issue as per comments on PR 8911.Justin Handville1-2/+1
2021-06-22Fix for Issue 8910 (Meson filters CMake asm files)Justin Handville1-0/+3
2021-06-18holders: Introduce HoldableObjectDaniel Mensinger1-3/+4
2021-06-09compilers: Fix missing functions in Compiler base classDaniel Mensinger1-0/+19
2021-06-07compilers: Add cython file suffixesDylan Baker1-0/+2
2021-06-02use an immutable list for an lru_cached functionsDylan Baker1-0/+1
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-05-19compilers: Add `get_debug_args` to base CompilerDylan Baker1-0/+4
This was missed, there should be an implementation in the base Compiler class, if for nothing else to help mypy
2021-05-19.C files are now treated as C++ codeVolker-Weissmann1-2/+4
2021-04-01environment: get environment variables for both host and build machinesDylan Baker1-8/+15
Fixes #8605
2021-03-30Split environment variable and command line cflagsDylan Baker1-4/+7
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-14compilers/linkers: Add a methhod for getting the rspfile syntaxDylan Baker1-1/+9
2021-03-04compilers: Use EnvironmentException not EnvironmentError/OSErrorDylan Baker1-8/+8
The latter is a python built-in exception, the former is a meson exception.
2021-03-04mass rewrite of string formatting to use f-strings everywhereEli Schwartz1-16/+16
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04various python neatness cleanupsEli Schwartz1-9/+9
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-02-19Ensure that $lang_args and $lang_link_args are properly parsedDylan Baker1-16/+12
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-17compilers: Only insert -flto-jobs in clang's link argumentsDylan Baker1-2/+4
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-16Add default debug flags for two configurations to NVCC.Olexa Bilaniuk1-2/+2
2021-02-14Add custom entyr to cuda buildtype dict. Closes #8336.Jussi Pakkanen1-0/+1
2021-02-02Add support for LLVM's thinLTODylan Baker1-2/+6
This uses a separate option, b_lto_mode. It works in conjunction with b_lto_threads. Fixes #7493
2021-02-02compilers: Add support for using multiple threads with ltoDylan Baker1-2/+18
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-01-13Fix misspellsAntonin Décimo1-3/+3
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-11move handling of CFLAGS and friends to environmentDylan Baker1-60/+15
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-11use PEP8 style naming for LANGUAGES_USING_* as wellDylan Baker1-4/+4
2021-01-11rename cflags_mapping to CFLAGS_MAPPINGDylan Baker1-14/+18
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-04use OptionKey for builtin and base optionsDylan Baker1-55/+51
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-04move OptionKey to mesonlibDylan Baker1-2/+1
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-04use OptionKey for compiler_optionsDylan Baker1-13/+13
2020-12-14Propagate Windows target checks upLaurin-Luis Lehning1-4/+4