aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins
AgeCommit message (Collapse)AuthorFilesLines
2022-10-13Add b_thinlto_cache for automatically configuring incremental ThinLTOTatsuyuki Ishi2-3/+10
2022-10-13clang: Support ThinLTO with moldTatsuyuki Ishi1-4/+9
2022-10-09compilers: Add optimization=plain optionJan Tojnar8-2/+12
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-10-03pylint: enable consider-using-(min|max)-builtinDylan Baker1-6/+2
There's only one case of each, in the same function, so I've handled both in the same commit.
2022-09-28find_library with argument beginning in "lib" is a bad idea, warn about itEli Schwartz1-0/+2
We need to support cases where the library might be called "foo.so" and therefore we check for exact matches too. But this also allows `cc.find_library('libfoo')` to find libfoo.so, which is strange and won't work in many cases. Emit a warning when this happens. Fixes #10838
2022-09-22compilers: unify fortran sanity check with its parent Clike handlingEli Schwartz1-2/+3
We *mostly* just need to do the same thing. Plug in one utility method to make sanity_check_impl find the right compile args, and plug in DEVNULL to the test run. It's that simple. This solves a few inconsistencies. The main one is that fortran never logged the sanity checks to the Meson debug log, making it hard to debug. There's also some interesting quirks we built up in the dedicated fortran handling. For example: - in commit 5b109c9ad27aea39ce49d1da8ef0c957ccaef3b9 we added cwd to building the fortran executable, with a wordy comment about how the compiler has defects. But the clike base has always done that on general principle anyway, so we would never have had that bug in the first place. - in commit d6be7822a0a7391c9d2a22c053cd4fc61b5a71e4 we added special deletion of an old "bad existing exe file" just for fortran. Looking at the PR discussion for this odd requirement, it turns out that the real problem is mixing WSL and native Windows without deleting the build directory. This is apparently fortran specific simply because "contemporary Windows 10 Fortran users" switch between the two? The actual problem is that this never used .exe as the output name, so Windows thinks you want to run something other than the thing you asked to run, because it's not even a Window executable. But... the common clike handling could have fixed that without needing special cases.
2022-09-22use simpler subprocess.run interface instead of manual PopenEli Schwartz1-2/+1
This code dates back to 2012 and probably has no specific reason...
2022-09-22compilers: make sanity checks log commands using join_argsEli Schwartz1-3/+3
It is more correct to join commands with a command joiner than a whitespace joiner.
2022-09-13Use os.path.realpath for default include paths testing in -isystem.Yang Bo1-3/+4
This ensures correct removal of default include paths in -isystem options when symbolic links are involved. A test for this is also added.
2022-08-26Fix purely white space issues reported by flake8Alf Henrik Sauge2-3/+1
2022-08-24fix linker regression for compilers that don't accept LDFLAGS directlyEli Schwartz4-4/+13
e.g. ldc -- the compiler needs to process args before consuming them. Fixes #10693
2022-07-11Revert /utf-8 changes in the visualstudio mixin to the 0.62.0 stateEli Schwartz1-5/+3
Specifically, this is a combination of the following: - Revert "visualstudio.py: Apply /utf-8 only on clang or VS2015+" This reverts commit 6e7c3efa793c25259891d3b5471343f95fb061fa. - Revert "Visual Studio: Only use /utf-8 on VS2015 or later or clang-cl" This reverts commit 8ed151bbd786d2c52e6ea7b7cfe3147fc41ec041. 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-06-21visualstudio.py: Apply /utf-8 only on clang or VS2015+Chun-wei Fan1-7/+5
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-05-25Fix optimization level 's' for the TI compilerAndreas Obergschwandtner1-1/+1
2022-05-19Fix invalid Python overridesTristan Partin1-4/+4
- mismatched method type - mismatched parameter names
2022-05-09compilers/gnu: demote visibilty inlineshidden to hidden for unsupported ↔Eli Schwartz1-0/+2
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-06compiler.has_argument: Add `-Werror=unknown-warning-option` to clang-cl cmd lineKhairul Azhar Kasmiran1-1/+1
2022-04-30linkers: Add support for mold linkerFini Jastrow3-7/+15
[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-25Visual Studio: Only use /utf-8 on VS2015 or later or clang-clChun-wei Fan1-0/+4
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-13compilers: fix broken CompCert support for release flagsEli Schwartz1-1/+1
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-03-31Merge pull request #9989 from ePirat/epirat-fix-uscore-prefix-detectionJussi Pakkanen2-7/+91
Fix underscore detection
2022-03-31clike: print stderr instead of stdout for debuggingMarvin Scholz1-1/+1
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-31visualstudio: do not query underscore define with MSVCMarvin Scholz1-0/+17
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-31clike: add more reliable ways to check underscore prefixMarvin Scholz1-6/+73
Fix #5482
2022-03-30compilers/gnu: use Popen_safe to prevent resource leaksMarvin Scholz1-8/+1
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-22OptionOverrideProxy: Make it immutable to avoid copiesXavier Claessens1-1/+1
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-02compilers/gnu: set level 0 optimization to '-O0'Dylan Baker1-1/+1
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-02-16flake8: fix various whitespace errors with badly aligned codeEli Schwartz2-6/+7
2022-02-02Genericise TI compiler and add MSP430 supportWilliam Toohey1-16/+31
2022-01-15Fix system include arguments for clang-clGatgat1-0/+4
2022-01-10compilers: push the compiler id to a class variableDylan Baker11-19/+25
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-10Merge pull request #9739 from mathstuf/armclang-supportJussi Pakkanen1-0/+3
Armclang support
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-12-30Fix mypy 0.930 issuesTristan Partin1-1/+1
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-16armclang: clarify that this is support for the Keil cross-compilerBen Boeckel1-0/+3
2021-12-08clang-cl: add a translation pass for `-isystem` args to workSahnvour1-0/+14
2021-11-27Fix _calculate_toolset_version for VS2022.Luke Elliott1-0/+2
2021-11-27Add -g for debug builds.Nathanael Gray1-1/+1
2021-11-27Fix more code which appears copied from CcrxCompiler.Nathanael Gray1-4/+6
2021-11-15only pass clang LTO arguments when they are neededEli Schwartz1-2/+4
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-10-27fix various flake8 whitespace errorsEli Schwartz4-7/+7
2021-10-10Fix typos discovered by codespellChristian Clauss2-5/+5
2021-10-07clike compilers: drop semicolon at function endVladimír Čunát1-4/+4
warning: ISO C does not allow extra ';' outside of a function [-Wpedantic]
2021-10-04use idiomatic python for membership testsEli Schwartz1-1/+1
"X not in Y" is preferred over "not X in Y", as the former is more readable.
2021-09-29Fix mypy errorsmakise-homura1-0/+1
2021-09-29compilers/elbrus: Deal with C/C++/Fortran stds more correctlymakise-homura1-0/+7
2021-09-29compilers/elbrus: Support prelinking with lcc correctlymakise-homura1-0/+3
2021-09-29compilers/elbrus: Fix incorrect inheritance model of Elbrus*Compilermakise-homura1-0/+5
2021-09-21Use -Oz when optimization=s in ClangAndrea Pappacoda1-1/+1
-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-16C2000: Added depfile generation for incremental buildsmiebka1-0/+3