aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
AgeCommit message (Collapse)AuthorFilesLines
2022-11-05nasm: Fix get_optimization_args()Ole André Vadla RavnÄs1-1/+11
2022-11-01nasm: Implement get_crt_compile_args()Xavier Claessens1-0/+3
This fix a crash when using NASM on Windows.
2022-10-25compilers: Make sure to not use ccache in compiler checksXavier Claessens5-12/+10
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 Claessens15-112/+110
Only combine them in the Compiler base class, this will make easier to run compiler without ccache.
2022-10-24Fix mismatched param names between Compiler and BasicLinkerIsCompilerMixinTristan Partin2-6/+10
2022-10-24Use f-strings in JavaCompilerTristan Partin1-2/+2
2022-10-24Add missing compiler functions to JavaCompilerTristan Partin1-0/+6
Fixes #2571
2022-10-24basic support for oneapi compilersRobert Cohn4-4/+65
2022-10-24Add MASM compilerXavier Claessens3-1/+159
ml and armasm are Microsoft's Macro Assembler, part of MSVC.
2022-10-24Not all compilers support depfileXavier Claessens2-2/+2
2022-10-24nasm: Harcode default path on WindowsXavier Claessens1-0/+4
NASM's installer does not add itself into PATH, even when installed by choco.
2022-10-24Add yasm as fallback for nasm languageXavier Claessens2-3/+25
2022-10-24Add NASM compilerXavier Claessens3-1/+110
2022-10-23gnulike: Fix preprocessing files with any extensionXavier Claessens1-0/+6
2022-10-23Compilers: Add a preprocessor mode for clike compilersXavier Claessens3-0/+35
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 Ishi3-7/+22
2022-10-13clang: Support ThinLTO with moldTatsuyuki Ishi1-4/+9
2022-10-09compilers: Add optimization=plain optionJan Tojnar13-7/+25
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-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-22compilers: unify fortran sanity check with its parent Clike handlingEli Schwartz2-40/+14
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-19pylint: enable consider-using-inDylan Baker1-1/+1
2022-09-19pylint: enable use-maxsplit-argDylan Baker2-3/+3
This finds a bunch of places where we can do more efficient string splitting.
2022-09-19fix odd mypy issue in unreachable codeEli Schwartz1-0/+1
This used to be fine, until imports were removed from this file. Now a function annotated as T.NoReturn doesn't actually tell mypy that it cannot return, though, so we manually do it.
2022-09-19simplify type annotationEli Schwartz1-1/+1
2022-09-19compilers: avoid importing compilers upfront for detectEli Schwartz1-114/+2
We no longer need these upfront at all, since we now import the ones we need for the language we are detecting, at the time of actual detection. This avoids importing 28 files, consisting of just under 9,000 lines of code, at interpreter startup. Now, it is only imported depending on which languages are invoked by add_languages, which may not even be anything. And even if we do end up importing a fair chunk of it for C/C++ projects, spreading the import cost around the interpreter runtime helps responsiveness.
2022-09-19compilers: perform targeted imports for detectEli Schwartz1-86/+103
Only import the ones we need for the language we are detecting, once we actually detect that language. This will allow finally dropping the main imports of these files in a followup commit.
2022-09-19compilers: use more direct checks for what kind of compiler we haveEli Schwartz1-7/+7
Instead of comparing against specific compiler classes, check the logical compiler id or language etc. In a couple cases, we seem to be missing a couple things by being a bit too strict about the exact class type.
2022-09-19compilers/detect: rename potentially conflicting nameEli Schwartz1-12/+12
Preparation for future commit.
2022-09-19compilers: use consistent function signature for objcEli Schwartz1-7/+7
e.g. for detect_c_or_cpp we just take the language itself as an argument.
2022-09-19compilers: remove dead codeEli Schwartz1-1/+1
It doesn't matter whether the language is c or cpp, xc16 only has a C compiler so that's what this has to be.
2022-09-19compilers: single-source compiler class as cls, consistentlyEli Schwartz1-18/+26
It's the style for most, but not all, of this file.
2022-09-19compilers: don't export every compiler as a top-level propertyEli Schwartz1-161/+0
This is wasteful and generally unneeded, since code can just use the compiler they detected instead of manually poking at the internals of this subpackage. It also avoids importing an absolute ton of code the instant one runs `from . import compilers`
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-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-07compilers: correct the MSVC version comparison for turning on __cplusplusEli Schwartz1-1/+1
We compared a Visual Studio (the IDE) version, but we wanted a MSVC (the compiler) version. This caused the option to be passed for a few too many versions of MSVC, and emit a "D9002 : ignoring unknown option" on those systems. Compare the correct version using the version mapping from https://walbourn.github.io/vs-2017-15-7-update/ Fixes #10787 Co-authored-by: CorrodedCoder <38778644+CorrodedCoder@users.noreply.github.com>
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-29flake8: move typing-only imports into T.TYPE_CHECKINGEli Schwartz2-2/+6
2022-08-26Fix purely white space issues reported by flake8Alf Henrik Sauge3-12/+10
2022-08-24fix linker regression for compilers that don't accept LDFLAGS directlyEli Schwartz6-13/+31
e.g. ldc -- the compiler needs to process args before consuming them. Fixes #10693
2022-07-25linkers: Add a representation for the Apple AR LinkerDylan Baker1-1/+2
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-21ar linker: detect the "osx ld" case (where generating thin archives won't ↔Justin Blanchard1-3/+3
work) based on host OS, not build OS.
2022-07-21compilers: add logging to obscure compiler defines scraperEli Schwartz1-2/+8
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-21compilers: include compiler detection output in the debug logsEli Schwartz1-0/+5
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-21compilers: better reporting of command failuresEli Schwartz1-25/+26
Use join_args to ensure that commands are rendered correctly.
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.