summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
AgeCommit message (Collapse)Author
2025-10-31Always check if found libraries are linkableSam James
We don't always check if a library is actually linkable because of concerns that a library may not be standalone, so linking against it may still have unresolved references. We can workaround that by building a shared library as a test rather than an executable, and in fact we already do that in a bunch of cases since bb5f2ca3da821d7a8e865cd55a8d5d638e0aab22. This comes up in particular with Fedora and dependency('atomic') because on x86_64, they provide a libatomic.so linker script (so our file existence check passes), but trying to use it later on will fail if the backing package isn't installed. _get_file_from_list has not been deleted because the Ninja backend's guess_library_absolute_path uses it. We might be able to change it to also use a link test but I've left that alone. Test notes: * The _test_all_naming unittest has been tweaked because we were using a blank file rather than an actual shared library, which (as expected), now fails. * I've also added a test for dependency('atomic') providing a result that can actually be linked against. I've not made it check generally whether dependency('atomic') finds something when we expect to (at least for now) as it'll involve some CI whack-a-mole. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=2352531 Bug: https://github.com/mesonbuild/meson/issues/14946 Closes: https://github.com/mesonbuild/meson/issues/10936
2025-10-31compilers: handle older Python behaviour for TemporaryDirectorySam James
In an Ubuntu Bionic container with Python 3.7.5: ``` $ python3 -c 'import tempfile; print(tempfile.mkdtemp(dir=""))' tmpycdjfo6m $ python3 -c 'import tempfile; print(tempfile.mkdtemp(dir=None))' /tmp/tmpy6dlpv0r ``` Pass dir as None to get the behaviour we need - which is how newer Pythons act, as otherwise we aren't running in the cwd for the compile test that we expect. This shows up as a failure in _test_all_naming when _find_library_real is modified to use links().
2025-10-30Add ifx to list of Fortran compilers on WindowsMads Bach Villadsen
Intel's oneAPI installation, as of 2025.3, no longer provides the classic ifort compiler, only the newer llvm-based ifx compiler.
2025-10-29compilers: add Microchip XC32 compilerLiza Chevalier
The Microchip XC32 compiler is a GCC-based compiler implemented using existing GNU compiler classes. As the XC32 version and GCC version do not match mixins have been implemented to override versions used in versions checks where applicable.
2025-10-29compilers/gnu: use version attributes for feature checksLiza Chevalier
Replace the hardcoded version strings with class attributes to allow subclasses to override them.
2025-10-29compilers/nvidia_hpc: support C/C++ -stdEisuke Kawashima
2025-10-29environment: move detection functions to envconfig.pyPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-29environment, compilers: move is_library caching to the sourcePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-29compilers/asm: Move arch support check to initializerDylan Baker
It really isn't a sanity check that a specific compiler doesn't work on a specific platform. This re-implements the check as a shared component in the ASMCompiler base class, which has the advantage of code sharing.
2025-10-29compilers/asm: Introduce an ASMCompiler base classDylan Baker
This will be able to hold some shared state between the different ASM compilers (or should that be assemblers?)
2025-10-23cargo: Use --env-set when we have nightly rustcXavier Claessens
2025-10-23rust: Add rust_nightly feature optionXavier Claessens
This is used for project to require a nightly Rust compiler, and also for Meson to enable nightly feature if available.
2025-10-23cargo: generate lint arguments from tablePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-15rust: mark verbatim unsupported also for wasmKohei Tokunaga
This fixes the following error occured in the test 3 of the Emscripten build. > wasm-ld: error: unable to find library -llibvalue.a Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2025-10-14compilers: clang: pass /nodefaultlibPaolo Bonzini
Work around https://github.com/llvm/llvm-project/issues/129881. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-14compilers: make link/lld-link check homogeneousPaolo Bonzini
Use the same check for all of clang, nasm and rustc. This also avoids the following warning: Sanity check compiler command line: clang++ sanitycheckobjcpp.mm -o sanitycheckobjcpp.exe -D_MT -D_DLL -D_DEBUG -D_FILE_OFFSET_BITS=64 -Wl,-fms-runtime-lib=dll_dbg Sanity check compile stdout: LINK : warning LNK4044: unrecognized option /fms-runtime-lib=dll_dbg; ignored iWhat happens is that -fms-runtime-lib sets up an automatic dependency from the .o files to the final link product, and therefore must be passed as a compiler argument. But the constructor for ClangCompiler was incorrectly allowing b_vscrt for MINGW, so I messed up the logic. With this change, MINGW won't get the b_vscrt option. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-14Add C23 and C2Y supported c_std versions for Apple compilers.John Ralls
2025-10-11fix rustc -l argument on WindowsPaolo Bonzini
On Windows, rustc searches both FOO.lib and libFOO.a when passed -lfoo. This means that the check for nonstandard names in the Unix sense is too struct, and indeed it breaks passing for example -lkernel32 (which adds kernel32.lib to the link). Fix this by special casing Windows. Extract the logic to the Rust compiler class for clarity. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-08rust: query linker in addition to compiler for verbatim supportPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-07Revert "compilers/asm: Introduce an ASMCompiler base class"Dylan Baker
This reverts commit 1e254ad7f327e5ed2021463e4b66c37072d354e3.
2025-10-07Revert "compilers/asm: Move arch support check to initializer"Dylan Baker
This reverts commit be50d0e23737dc0fc5f074a291644d7fde39ef7b.
2025-10-06compilers: do not use coredata.set_optionsPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06options: replace get_value with get_value_forPaolo Bonzini
The two methods are identical. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06Revert "compilers: refactor sanity checking code"Dylan Baker
This reverts commit 806289a5d27958a084bc6cba41b7cf9ccee4ecf4.
2025-10-06Revert "compilers/asm: Store the C Compiler inside the Assembly Compilers"Dylan Baker
This reverts commit 8847c938dd1c9e2c6e64e3050eb58f7ec54fccb3.
2025-10-06Revert "compilers/asm: Implement infrastructure for sanity checking"Dylan Baker
This reverts commit 08221c6d1fc4a6afe780a479bbc7e40899242601.
2025-10-06Revert "compilers/asm: Implement sanity checking code for NASM on Windows ↵Dylan Baker
and Linux" This reverts commit c520e8981693056419d846f60ffb85061bf3191f.
2025-10-06compilers/asm: Implement sanity checking code for NASM on Windows and LinuxDylan Baker
This leaves other systems to be implemented, as I don't have a good way of checking that they work correctly.
2025-10-06compilers/asm: Implement infrastructure for sanity checkingDylan Baker
ASM has some special concerns because it has to be implemented in terms of assembling an object, and then linking the object with a linker or linker driver. That makes the implementation somewhat complex. There is a bit of a hack going on here with the `_run_sanity_check` method and the mro. I'm still thinking about how best to handle that.
2025-10-06compilers/asm: Store the C Compiler inside the Assembly CompilersDylan Baker
Such as NASM and MASM. These compilers don't actually do any linking, the just produce object files. As such, we need the C compiler to link the program in order to make things like sanity_check work.
2025-10-06compilers: refactor sanity checking codeDylan Baker
The goal is to reduce code duplication, and allow each language to implement as little as possible to get good checking. The main motivation is that half of the checks are fragile, as they add the work directory to the paths of the generated files they want to use. This works when run inside mesonmain because we always have an absolute build directory, but when put into run_project_tests.py it doesn't work because that gives a relative build directory.
2025-10-06compilers/asm: Move arch support check to initializerDylan Baker
It really isn't a sanity check that a specific compiler doesn't work on a specific platform. This re-implements the check as a shared component int he ASMCompiler base class, which has the advantage of code sharing
2025-10-06compilers/asm: Introduce an ASMCompiler base classDylan Baker
This will be able to hold some shared state between the different ASM compilers (or should that be assemblers?)
2025-09-26Add eld in GnuLikeCompilerKushal Pal
Signed-off-by: Kushal Pal <kushpal@qti.qualcomm.com>
2025-09-24compilers: clang: map -Db_vscrt to -fms-runtime-libPaolo Bonzini
The main complication here is that passing -fms-runtime-lib during compilation results in a warning: clang: error: argument unused during compilation: '-fms-runtime-lib=dll' [-Werror,-Wunused-command-line-argument] (https://github.com/mesonbuild/meson/actions/runs/17727020048/job/50369771571). So, for compilation expand the -D flags by hand, and only pass -fms-runtime-lib when linking. Fixes: #14571 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-09-24compilers: use CRT linker arguments also for testsPaolo Bonzini
get_crt_link_args was only called for the final linker command line; add its result to the sanity check and compiler tests as well. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-09-24compilers: replace "type: ignore" with assertionsPaolo Bonzini
Option values have type "str | int | list[str]", assert that they are strings before passing them to self.get_crt_compile_args(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-09-06compilers: Enable out-of-the-box MSVC compatibility with ccacheL. E. Segovia
ccache has been for a long time compatible with MSVC (since 4.6) but when using debug mode, the /Z7 flag must be passed instead of /Zi. See https://ccache.dev/releasenotes.html#_ccache_4_6
2025-08-25linkers: Fix dsymutil being unable to symbolicate binaries with LTOL. E. Segovia
According to https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-flto, the -object_path_lto flag is needed to preserve the intermediate object files.
2025-08-10compiler,rust: No native-static-libs for wasm after 1.84Ruben Gonzalez
Rust 1.84 uses the latest emsdk 3.1.68 [1], and it fixed an issue with Emscripten dynamic linking and libc [2]. After that no native-static-libs in the output if running: ``` rustc --target=wasm32-unknown-emscripten --crate-type staticlib --print native-static-libs - < /dev/null ``` [1] https://github.com/rust-lang/rust/pull/131533 [2] https://github.com/rust-lang/libc/pull/4002
2025-08-07cpp: handle Apple Clang deprecation of hardening macro for old versions tooSam James
a16ec8b0fb6d7035b669a13edd4d97ff0c307a0b changed the threshold to 17 for Apple Clang, but it needs to be 16 instead. Bug: https://github.com/mesonbuild/meson/issues/14440 Closes: https://github.com/mesonbuild/meson/issues/14856
2025-08-02swift: Pass C++ base compile options to swiftcKatalin Rebhan
2025-08-02Add swift_interoperability_mode kwargKatalin Rebhan
2025-08-01call determine_rpath_dirs only when linker requires itCharles Brunet
2025-07-29build: allow picking 'rust' as a link_languagePaolo Bonzini
rustc only needs to be a linker if there are any Rust-ABI dependencies. Skip it whenever linking to a C-ABI dependency. This makes it possible for Meson to pick 'rust' whenever it sees Rust sources, but not whenever it sees Rust used by a dependency with "rust_abi: 'c'". Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-29ninjabackend: handle specially TUs where compilation and linking happens ↵Paolo Bonzini
together Rust sources are not compiled separately: generation of the .a or .so or binary happens at the same time as compilation. There is no separate compilation phase where the .o file is created. In preparation for moving generate_rust_target where generate_link is now, make the compilation phase of generate_target skip them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-29fix formatting issue in the previous commitEli Schwartz
2025-07-29c: add more exceptions to -Wno-*Henrik Lehtonen
Commit eca1ac18dc1978b15b500c9f1710c05cb1ccc0ec (#14252) added support for properly detecting the -Wno-vla-larger-than flag: a value must be specified for its positive form (-Wvla-larger-than=N), or GCC will exit with the error "missing argument to ‘-Walloc-size-larger-than=’". There is a handful of other -Wno-* flags whose positive form act in the same manner, but are not covered here: * -Wno-alloc-size-larger-than (GCC >=7.1.0) * -Wno-alloca-larger-than (GCC >=7.1.0) * -Wno-frame-larger-than (GCC >=4.4.0) * -Wno-stack-usage (GCC >=4.7.0) Add logic to treat these in the same way. Signed-off-by: Henrik Lehtonen <eigengrau@vm86.se>
2025-07-24Add -parse-as-library to Swift library targetsKatalin Rebhan
2025-07-21rust: pass rpath arguments to rustdoc --testPaolo Bonzini
rustdoc does not support --print, and therefore the rpath argument corresponding to the rust installation is not passed to doctests. Forward anything that requires --print to the RustCompiler, thus fixing doctests with a shared library dependency. Fixes: #14813 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>