aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
AgeCommit message (Collapse)AuthorFilesLines
2024-07-30flake8: move unused typing-only imports to TYPE_CHECKINGEli Schwartz6-9/+8
2024-07-28add initial support for llvm-flangH. Vetinari2-6/+78
2024-07-21compilers: fix partial refactor of coredata optionsEli Schwartz1-3/+3
Fallout from the OptionStore refactor, and specifically commit 9a6fcd4d9a0c7bb248c5d0587632b741a3301e03. The `std` object was migrated from having an option itself, to having the value fetched and saved directly. In most cases, this also meant avoiding `.value`, but in a couple cases this refactor went overlooked, and crashed at runtime. Only affects Elbrus and Intel C++ compilers, seemingly. Fixes #13401
2024-07-19compilers: handle -Wno-attributes= for GCCSam James1-2/+4
For other reasons, Meson transforms "-Wno-x" into "-Wx -Wno-x" for GCC, but this breaks with "-Wno-attributes=x" with: ``` cc1plus: error: arguments ignored for '-Wattributes='; use '-Wno-attributes=' instead ``` Suppress that workaround for -Wno-attributes=. Closes: https://github.com/mesonbuild/meson/issues/13022
2024-07-17Remove language (AKA compiler) type from OptionKey.Jussi Pakkanen8-19/+23
2024-07-16Revert logic also in followup commitChristoph Reiter1-1/+1
In 8d7ffe6e863834f0190e need_exe_wrapper() use was copied which was just reverted, so replace with is_cross there too, to keep things in sync.
2024-07-16Revert various cross compile changesChristoph Reiter4-6/+6
c1076241af11f10acac28d771688bb54c6b0b340 changed the logic in multiple places, in particular it looks like it was assumed that is_cross is always the same as need_exe_wrapper(), but that's not true. Also the commit only talks about mypy, so this was definitely not intended. This reverts all the cases where need_exe_wrapper() was introduced back to is_cross. The change in backends.py could be a correct simplification, but I don't know the code base enough, so reverting that too. See #13403 and #13410
2024-07-12Rename langopt methodJussi Pakkanen7-102/+102
The public facing name of language options is compiler option, so let's standardise on that.
2024-07-11Move OptionKey in the option source file.Jussi Pakkanen17-18/+29
2024-07-10nasm: Add -mms-bitfields to the list of ignored flagsL. E. Segovia1-1/+1
Fixes building Nasm objects with Meson's native language support, when depending against a library that exports that flag, like Glib.
2024-06-26compilers: Add support for OpenMP from homebrew with AppleClangDylan Baker3-2/+61
Which requires injecting some extra paths and the `-Xpreprocess` flag, as well as extra search paths for libomp and the headers. Fixes: #7435
2024-06-26compilers|dependencies: Move Clang-CL specific logic out of OpenMP depDylan Baker1-0/+7
And into the Clang-CL mixin.
2024-06-26compilers: pass Environment to openmp_flagsDylan Baker8-18/+21
This will be needed by the Apple compiler
2024-06-24compilers: make lang_map publicSam James3-9/+9
2024-06-24compilers: detect: fix pre-processor scraping by defining languageSam James2-21/+77
_get_gnu_compiler_defines and _get_clang_compiler_defines were broken by not defining the language they used. Neither GCC nor Clang infer the language based on the driver name which means `self.defines` isn't populated correctly in compilers/cpp.py. e.g. ``` $ echo "" | g++ -E -dM - | grep -i cplus $ echo "" | g++ -x c++ -E -dM - | grep -i cplus #define __cplusplus 201703L ``` Fix that by passing '-cpp -x LANGUAGE' as a first pass. If it fails, try again without '-cpp -x LANGUAGE' as before, as its portability isn't certain. We do '-cpp' because during testing, I found Fortran needs this, although per below, I had to drop Fortran in the end and leave it to the fallback (existing) path. Without this change, a63739d394dd77314270f5a46f79171a8c544e77 is only partially effective. It works if the system has injected Clang options via /etc/clang configuration files, but not by e.g. patching the driver (or for GCC there too). Unfortunately, we have to wimp out for Fortran and fallback to the old method because you need the language standard (e.g. -x f95).
2024-06-24compilers: detect: fix comment/error string in _get_gnu_compiler_definesSam James1-2/+2
Make the debug & error message strings consistent between the GCC and Clang probes. Copy-paste error. Here, we're scraping pre-processor tokens, not checking for the compiler type.
2024-06-24compilers: detect: fix typo in commentSam James1-1/+1
2024-06-23compilers: cpp: fix header name and return value use in header checkBarnabás Pőcze1-1/+1
There are two issues: 1. has_header() wants just the header name without surrounding <> or similar; it fails otherwise. 2. has_header() returns a tuple of two bools, where the first element determines whether or not the header has been found. So use that element specifically, otherwise the tuple will always evaluate to true because it is not empty. Fixes: 675b47b0692131 ("compilers: cpp: improve libc++ vs libstdc++ detection (again)")
2024-06-23feat(compilers): cppm extension supportTheHillBright1-1/+1
recognize the file extension `cppm` as c++ source file
2024-06-16BUG: Use an F77 snippet for sanity testing FortranRohit Goswami1-2/+2
Closes gh-13319
2024-06-14Fix mypy.Jussi Pakkanen5-7/+12
2024-06-14Replace direct indexing with named methods.Jussi Pakkanen11-162/+162
2024-06-14Rename option variable to optstore to make it unique.Jussi Pakkanen3-4/+4
2024-06-08Use helper method in remaining compiler classes.Jussi Pakkanen2-12/+14
2024-06-08Use helper method in Rust compiler class.Jussi Pakkanen1-2/+2
2024-06-08Use helper method in Fortran compiler classes.Jussi Pakkanen1-9/+9
2024-06-08Use helper method in C++ compiler classes.Jussi Pakkanen1-52/+60
2024-06-08Create helper method for lang opts and use in C compiler classes.Jussi Pakkanen2-34/+59
2024-05-24compilers: improve a comment describing why we add a silly clang workaroundEli Schwartz1-3/+17
Clang is such a great compiler! Not. Compilers have enhanced diagnostics for some kinds of "well known" undeclared identifiers, telling you exactly which header you might have forgotten to include. The reason why clang needs an option GCC doesn't need is because clang's fixit suggestions, unlike GCC's actually *changes the type of the error*, as a result of a fixit of all things. After the fixit suggestion grants this error the right to be ignored, we start having to add clang-specific options. Follow-up to https://github.com/mesonbuild/meson/issues/9140 Upstream clang bug, which appears to be going nowhere: https://github.com/llvm/llvm-project/issues/33905
2024-05-23Refactor option classes to their own file.Jussi Pakkanen10-79/+84
2024-05-22cuda: fix `cuda.find_library()` hardcoded to yield trueDavid Seifert2-2/+2
* Previously, cuda would just plainly prepend `-l` to the libname. * By relying on the host compiler to find libraries, we now get more subtle failures, such as CUDA modules not being found anymore. * We need to simplify these CUDA modules when nvcc is used for linking, since this may have side-effects from the cuda toolchain. Closes: #13240
2024-05-22add cross-compile argument for ldc linker guessingAxel Ricard1-1/+5
2024-05-22fix sanity check for d cross-compilationAxel Ricard2-3/+14
2024-05-19Fix handling of C standard support for Emscripten.Ralf Gommers1-0/+10
Emscripten version numbers are unrelated to Clang version numbers, so it is necessary to change the version checks for `c_std=c17` & co. Without that, no project that defaults to C17 or newer will build with Emscripten. See https://github.com/pyodide/pyodide/discussions/4762 for more context. Also note that this bug caused defaulting to C17 in scikit-learn to be reverted (scikit-learn#29015), and it may be a problem for SciPy 1.14.0 too since that release will upgrade from C99 to C17. Co-authored-by: Loic Esteve <loic.esteve@ymail.com>
2024-05-15Merge pull request #11421 from mon/ti-armclangJussi Pakkanen1-6/+5
Basic support for TI Arm Clang toolchain
2024-05-07cuda: pass static archives to nvcc without -Xlinker= prefixDavid Seifert1-1/+4
2024-05-07Add support for GCC's null_terminated_string_arg function attributeTristan Partin1-0/+2
This is new as of 14.1.
2024-04-30Fix dependencies for vala.links #13158Ben Corby1-0/+44
Using the keyword argument dependencies with compiler.links() for vala doesn't work as the library being linked to needs to be prefixed with --pkg= before being passed to valac.
2024-04-28Prefer Clang over GCC for Objective-C(++)Jonathan Schleifer1-5/+4
GCC only has very limited support for Objective-C and doesn't support any of the modern features, so whenever Clang is available, it should be used instead. Essentially, the only reason to ever use GCC for Objective-C is that Clang simply does not support the target system.
2024-04-27compilers/fortran: fix werror options for Intel compilersBenjamin Gilbert1-0/+6
Unlike in the Intel C compiler, -Werror and /WX are not accepted.
2024-04-27backend/ninja: use generate_basic_compiler_args() for C#, Java, SwiftBenjamin Gilbert2-1/+14
C#, Java, and Swift targets were manually collecting compiler arguments rather than using the helper function for this purpose. This caused each target type to add arguments in a different order, and to forget to add some arguments respectively: C#: /nologo, -warnaserror Java: warning level (-nowarn, -Xlint:all, -Xdoclint:all), debug arguments (-g, -g:none), -Werror Swift: -warnings-as-errors Fix this. Also fix up some no-longer-unused argument processing in the Compiler implementations.
2024-04-26nasm: Fallback to native compiler when cross compilingXavier Claessens1-3/+9
If nasm is not defined in cross file binaries we can fallback to build machine nasm. When cross compiling C code we need a different gcc binary for native and cross targets, e.g. `gcc` and `x86_64-w64-mingw32-gcc`. But when cross compiling NASM code the compiler is the same, it is the source code that has to be made for the target platform. We can thus use nasm from build machine's PATH to cross compile for Windows on Linux for example. The difference is the arguments Meson will pass when invoking nasm e.g. `-fwin64`. That is already handled by NasmCompiler class.
2024-04-25Catch Python exception in the event alignment can't be converted to intTristan Partin1-1/+9
The user almost certainly has to be using a compiler wrapper script that doesn't actually work if we land here. Fixes: #12982
2024-04-24rust: Fix warning_level=everything caseXavier Claessens1-0/+1
Fixes: #13100
2024-04-23Fix compile.links for valaBen Corby1-0/+40
Fixes issue #12959 compiler.links command for vala crashes
2024-04-22Merge pull request #12808 from U2FsdGVkX1/masterJussi Pakkanen1-4/+4
Fix ninja cannot find the library when libraries contain symlinks.
2024-04-15Don't sanitize a None path when checking for, but could not find, ↵William D. Jones1-2/+2
unsupported cl clones.
2024-04-09nasm, yasm: Fix debug flags for Windows and macOSL. E. Segovia1-1/+1
2024-04-09nasm, yasm: Fix debug flags for Windows and macOSL. E. Segovia1-5/+8
2024-04-05compilers: Ensure -L flags do not get reordered when used with MSVCL. E. Segovia1-3/+9
If -L flags get into CLikeCompiler::build_wrapper_args, they will be correctly detected and the /LINK flag added to the list. However, CompilerArgs::__iadd__ will reorder them to the front, thinking they're GNU-style flags, and this will cause MSVC to ignore them after conversion. The fix is twofold: 1. Convert all the linker args into their compiler form, making sure the /LINK argument is dropped (see 2) 2. Insert /LINK into extra_args if not already present 3. Execute in situ the unix_to_native replacement, ensuring no further reordering occurs. Fixes #11113