summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
AgeCommit message (Collapse)Author
2024-07-11Move OptionKey in the option source file.Jussi Pakkanen
2024-07-10nasm: Add -mms-bitfields to the list of ignored flagsL. E. Segovia
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 Baker
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 Baker
And into the Clang-CL mixin.
2024-06-26compilers: pass Environment to openmp_flagsDylan Baker
This will be needed by the Apple compiler
2024-06-24compilers: make lang_map publicSam James
2024-06-24compilers: detect: fix pre-processor scraping by defining languageSam James
_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 James
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 James
2024-06-23compilers: cpp: fix header name and return value use in header checkBarnabás Pőcze
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 supportTheHillBright
recognize the file extension `cppm` as c++ source file
2024-06-16BUG: Use an F77 snippet for sanity testing FortranRohit Goswami
Closes gh-13319
2024-06-14Fix mypy.Jussi Pakkanen
2024-06-14Replace direct indexing with named methods.Jussi Pakkanen
2024-06-14Rename option variable to optstore to make it unique.Jussi Pakkanen
2024-06-08Use helper method in remaining compiler classes.Jussi Pakkanen
2024-06-08Use helper method in Rust compiler class.Jussi Pakkanen
2024-06-08Use helper method in Fortran compiler classes.Jussi Pakkanen
2024-06-08Use helper method in C++ compiler classes.Jussi Pakkanen
2024-06-08Create helper method for lang opts and use in C compiler classes.Jussi Pakkanen
2024-05-24compilers: improve a comment describing why we add a silly clang workaroundEli Schwartz
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 Pakkanen
2024-05-22cuda: fix `cuda.find_library()` hardcoded to yield trueDavid Seifert
* 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 Ricard
2024-05-22fix sanity check for d cross-compilationAxel Ricard
2024-05-19Fix handling of C standard support for Emscripten.Ralf Gommers
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 Pakkanen
Basic support for TI Arm Clang toolchain
2024-05-07cuda: pass static archives to nvcc without -Xlinker= prefixDavid Seifert
2024-05-07Add support for GCC's null_terminated_string_arg function attributeTristan Partin
This is new as of 14.1.
2024-04-30Fix dependencies for vala.links #13158Ben Corby
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 Schleifer
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 Gilbert
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 Gilbert
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 Claessens
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 Partin
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 Claessens
Fixes: #13100
2024-04-23Fix compile.links for valaBen Corby
Fixes issue #12959 compiler.links command for vala crashes
2024-04-22Merge pull request #12808 from U2FsdGVkX1/masterJussi Pakkanen
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. Jones
unsupported cl clones.
2024-04-09nasm, yasm: Fix debug flags for Windows and macOSL. E. Segovia
2024-04-09nasm, yasm: Fix debug flags for Windows and macOSL. E. Segovia
2024-04-05compilers: Ensure -L flags do not get reordered when used with MSVCL. E. Segovia
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
2024-04-05Merge pull request #12144 from amyspark/fix-msvc-clangcl-linker-flag-detectionJussi Pakkanen
linkers: Fix detection of link arguments to Clang(-cl) + MSVC
2024-04-03Fix regression in TI CGT supportWill Toohey
When C6000 support was added in #12246, TI compilers were given the correct version argument. This broke the previous check which relied on an error being thrown by the compiler.
2024-04-01nasm: Add support for .nasm file extension (#13027)Junior Rantila
2024-03-28compilers: cpp: reduce macro pollution for stdlib macrosSam James
Now that we have access to Environment in get_assert_args, we can check what the actual C++ stdlib provider is and only set relevant macros rather than all possibly-relevant ones based on the compiler. Also, while we're here, now that's sorted, wire up the GCC experimental libc++ support in the macro emission given it doesn't uglify anything for libstdc++ users now. Bug: https://github.com/mesonbuild/meson/issues/12962 Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-03-28compilers: cpp: factor out C++ stdlib detectionSam James
We're going to use it in some more places in a minute (for controlling assertions). Bug: https://github.com/mesonbuild/meson/issues/12962 Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-03-28Pass Environment down from BackendSam James
We'll need it in a moment for get_base_compile_args -> get_assert_args. Bug: https://github.com/mesonbuild/meson/issues/12962 Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-03-28compilers: cpp: don't set stdlib assertion macros if already setSam James
Followup to 90098473d51e6f059e775f1833b0a2ea91c8f8f9. If the compiler already has one of these assertion macros [0] set, then don't interfere. e.g. a Linux distribution might be setting a stricter default than usual. This is a pitfall many fell into with _FORTIFY_SOURCE and it's why AX_ADD_FORTIFY_SOURCE [1] was contributed to autoconf-archive. [0] _GLIBCXX_ASSERTIONS, _LIBCPP_HARDENING_MODE, or _LIBCPP_ENABLE_ASSERTIONS. [1] https://www.gnu.org/software/autoconf-archive/ax_add_fortify_source.html Bug: https://github.com/mesonbuild/meson/issues/12962 Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-03-28compilers: cpp: relax assertion level for libc++Sam James
Followup to 90098473d51e6f059e775f1833b0a2ea91c8f8f9. I changed my mind on this a few times. libcxx's documentation describes [0] the hardening modes as: """ 1) Unchecked mode/none, which disables all hardening checks. 2) Fast mode, which contains a set of security-critical checks that can be done with relatively little overhead in constant time and are intended to be used in production. We recommend most projects adopt this. 3) Extensive mode, which contains all the checks from fast mode and some additional checks for undefined behavior that incur relatively little overhead but aren’t security-critical. Production builds requiring a broader set of checks than fast mode should consider enabling extensive mode. The additional rigour impacts performance more than fast mode: we recommend benchmarking to determine if that is acceptable for your program. 4) Debug mode, which enables all the available checks in the library, including internal assertions, some of which might be very expensive. This mode is intended to be used for testing, not in production. """ We chose 3) before because it felt like a better fit for what we're trying to do and the most equivalent option to libstdc++'s _GLIBCXX_ASSERTIONS, but on reflection, maybe we're better off picking a default with less overhead and more importantly guarantees constant time checks. [0] https://libcxx.llvm.org/Hardening.html#using-hardening-modes Bug: https://github.com/mesonbuild/meson/issues/12962 Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>