aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
AgeCommit message (Collapse)AuthorFilesLines
2023-03-16prevent lib prefix warning from pkg-configCharles Brunet1-1/+1
2023-02-27Use caching in Compiler.sizeof() and Compiler.alignment()Andres Freund1-2/+2
2023-02-27Add Compiler.cached_run()Andres Freund1-1/+29
Caching Compiler.run() seems likely to cause problems, but some users, like .sizeof(), we know enough about the program run to make it safe. This commit just adds the Compiler.cached_run(), a subsequent commit makes use of it.
2023-02-25Misleading comment mtribiere1-1/+1
Code moved to detect.py in recent version
2023-02-20nasm: Link with windows CRT libs when nasm is used as linker languageXavier Claessens1-1/+1
2023-02-01remove unneeded type commentEli Schwartz1-1/+1
2022-10-25compilers: Make sure to not use ccache in compiler checksXavier Claessens1-3/+4
ccache was used in all command lines but disabled using CCACHE_DISABLE in Compiler.compile() method. Wrapping invokations still has a cost, especially on Windows. With sccache things are even worse because CCACHE_DISABLE was not respected at all, making configure *extremely* slow on Windows when sccache is installed.
2022-10-25Compilers: Keep ccache and exelist separatedXavier Claessens1-2/+2
Only combine them in the Compiler base class, this will make easier to run compiler without ccache.
2022-10-24Add MASM compilerXavier Claessens1-1/+2
ml and armasm are Microsoft's Macro Assembler, part of MSVC.
2022-10-24Not all compilers support depfileXavier Claessens1-1/+1
2022-10-24Add NASM compilerXavier Claessens1-1/+2
2022-10-23Compilers: Add a preprocessor mode for clike compilersXavier Claessens1-0/+12
A compiler object can now return a list of "modes", they are new compiler object specialized for a specific task.
2022-10-13Add b_thinlto_cache for automatically configuring incremental ThinLTOTatsuyuki Ishi1-4/+12
2022-10-09compilers: Add optimization=plain optionJan Tojnar1-2/+4
https://github.com/mesonbuild/meson/pull/9287 changed the `optimization=0` to pass `-O0` to the compiler. This change is reasonable by itself but unfortunately, it breaks `buildtype=plain`, which promises that ā€œno extra build flags are usedā€. `buildtype=plain` is important for distros like NixOS, which manage compiler flags for optimization and hardening themselves. Let’s introduce a new optimization level that does nothing and set it as the default for `buildtype=plain`.
2022-09-27compilers: Cleanup a bit languages/suffixes listsXavier Claessens1-18/+22
Use set where order does not matter, fix is_source() to really mean only source suffixes.
2022-09-09compilers: drop some useless info from CompileResultEli Schwartz1-5/+2
text_mode was never set, nor used, and pid was set but never used.
2022-09-09compilers: fix regression in logging cached compile commandsEli Schwartz1-4/+3
In commit d326c87fe22507b8c25078a7cd7ed88499ba7dc1 we added a special holder object for cached compilation results, with some broken attributes: - "command", that was never set, but used to print the log - "args", that was set to some, but not all, of the information a fresh compilation would log, but never used Remove the useless args attribute, call it command, and use it properly.
2022-09-01env2mfile: reuse logical lists of interesting facts from meson itselfEli Schwartz1-0/+1
Meson internally knows about many languages and tools, and *FLAGS variables, and which languages to use them for. Instead of duplicating this logic, import it from mesonbuild.* This logic was originally standalone, but now that it is merged into the Meson tree we can have a single source of truth.
2022-08-24fix linker regression for compilers that don't accept LDFLAGS directlyEli Schwartz1-1/+5
e.g. ldc -- the compiler needs to process args before consuming them. Fixes #10693
2022-07-03move various unused typing-only imports into type-checking blocksEli Schwartz1-1/+3
2022-06-06compilers: Add support for stand-alone leak sanitizerMarco Trevisan (TreviƱo)1-1/+1
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-01compiler: Add missing needs_static_linker to base Compiler classDylan Baker1-0/+3
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 ```