aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins
AgeCommit message (Collapse)AuthorFilesLines
13 dayscompilers: Enable out-of-the-box MSVC compatibility with ccacheL. E. Segovia1-6/+4
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-01call determine_rpath_dirs only when linker requires itCharles Brunet1-3/+2
2025-07-29fix formatting issue in the previous commitEli Schwartz1-7/+5
2025-07-29c: add more exceptions to -Wno-*Henrik Lehtonen1-4/+13
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-06-27compilers-fortran: Fix preprocessing when fortran uses concat operatorAndrew Lister1-0/+2
2025-06-18compilers: pgi: fix preprocessing argumentsPaolo Bonzini1-0/+6
Based on reports from the users, PGI compilers need an explicit "-o -" on the command line to emit preprocessed output on stdout. Override the methods in the PGICompiler mixin to add it when output goes to stdout but not when output goes elsewhere. Fixes: #13216 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-05Add eld as default linker for Qualcomm Hexagon compilerKushal Pal1-1/+4
Signed-off-by: Kushal Pal <kushpal@qti.qualcomm.com>
2025-05-21compilers: add option for ignoring system dirsDavid Seifert2-9/+9
2025-04-30compilers: introduce common helper for sanity checksPaolo Bonzini1-15/+1
Avoid reinventing the wheel and instead use a single helper, taking care of logging and cross compilation. Fixes: #14373 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-30compilers: clike: log output of sanity checkPaolo Bonzini1-2/+1
Particularly if using an exe_wrapper, it can be useful to have output logged for debugging. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-08coredata: move MutableKeyedOptionDict to optionsDylan Baker3-5/+4
2025-04-04compilers: move -std options to get_option_std_args, special-casing CUDAPaolo Bonzini1-1/+1
Move building the -std option to the new get_option_std_args method, special casing CUDA to never include the option from the host compiler. This fixes again #8523, which was broken by the option refactoring (unsurprisingly, since the fix was ripped out unceremoniously without a replacement). Fixes: #14365 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-03-10coredata: remove get_option_for_subprojectDylan Baker1-3/+3
This is just a wrapper around `OptionStore.get_option_for`, but without taking an `OptionKey`. This complicates the subproject passing, since `OptionKey` is designed to encapsulate the option name and subproject.
2025-03-09compilers: convert `b_sanitize` to a free-form array optionPatrick Steinhardt3-12/+13
In the preceding commit we have started to perform compiler checks for the value of `b_sanitize`, which allows us to detect sanitizers that aren't supported by the compiler toolchain. But we haven't yet loosened the option itself to accept arbitrary values, so until now it's still only possible to pass sanitizer combinations known by Meson, which is quite restrictive. Lift that restriction by adapting the `b_sanitize` option to become a free-form array. Like this, users can pass whatever combination of comma-separated sanitizers to Meson, which will then figure out whether that combination is supported via the compiler checks. This lifts a couple of restrictions and makes the supporting infrastructure way more future proof. A couple of notes regarding backwards compatibility: - All previous values of `b_sanitize` will remain valid as the syntax for free-form array values and valid combo choices is the same. We also treat 'none' specially so that we know to convert it into an empty array. - Even though the option has been converted into a free-form array, callers of `get_option('b_sanitize')` continue to get a string as value. We may eventually want to introduce a kwarg to alter this behaviour, but for now it is expected to be good enough for most use cases. Fixes #8283 Fixes #7761 Fixes #5154 Fixes #1582 Co-authored-by: Dylan Baker <dylan@pnwbakers.com> Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-03-09Optimize CLikeCompiler._get_file_from_list()Charles Brunet1-7/+7
2025-02-27coredata: delete the OptionsViewDylan Baker1-2/+2
This also makes KeyedOptionDictType obsolete and it's removed
2025-02-16c: add -Wno-vla-larger-than to the exceptions for -Wno*Paolo Bonzini1-4/+10
When supplying -Wno-vla-larger-than to compiler.get_supported_arguments, meson will inject -Wvla-larger-than as an argument which considered invalid by GCC, as the converse argument is -Wvla-larger-than=<value>. Just like CLikeCompiler._has_multi_arguments special-cases -Wno-attributes=, do the same for -Wno-vla-larger-than. Resolves: https://github.com/mesonbuild/meson/issues/14208 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-02-13Make all Meson level options overridable per subproject.Jussi Pakkanen4-6/+13
2025-02-05options: use dataclasses for UserOptionDylan Baker1-1/+2
This reduces code, makes this clearer, and will be a nice step toward the goal of getting everything typesafe. For `UserIntegerOption` this makes a fairly nice, but substantial change in that the old method used a tuple of `(min, value, max)` to pass to the initializer, while all other types just passed `value`. The new `UserIntegerOption` does the same, with keyword arguments for the min and max values.
2025-02-05compilers: remove Compiler.create_optionDylan Baker1-9/+9
This saves a *tiny* bit of typing, but at the cost of requiring either the current solution of throwing up our hands and saying "typing is too hard, better to have bugs!" or an extensive amount of `TypedDict`s, `overloads`, and a very new version of mypy. Let's get our type safety back, even if it means writing a little bit more code.
2025-01-27compilers: split Apple C++ version handling to a mixinDylan Baker1-0/+8
2025-01-27compilers: move Apple C Std version handling to a mixinDylan Baker1-1/+10
To avoid duplication between C and ObjC
2025-01-27compilers/gnu: Split Gnu C++ standard handling into a mixin classDylan Baker1-0/+25
So we can re-use it in the ObjC++ standards
2025-01-27compilers/gnu: Pull C Standard handling out of GnuCCompilerDylan Baker1-1/+29
So we can re-use it for the ObjC code
2025-01-27compilers/clang: split the Std handling for C++ out of the ClangCPPCompilerDylan Baker1-0/+27
We'll want to use this for the ObjC++ compiler too.
2025-01-27compilers/clang: Move the Mixin for C standards out of the c moduleDylan Baker1-0/+43
We'll want to use this for ObjC as well, so we'll make it public and put it in a public place.
2025-01-20Remove GCC's -Wunsuffixed-float-constants from warningsDavid Robillard1-3/+1
This inclusion was a misunderstanding on my part: this warning isn't generally applicable to standard C (it prevents using double literals whatsoever since C doesn't have a suffix for them), but exists to support a GNU C extension. It also has no counterpart in clang. So, remove it, since warning_level=everything doesn't include such things.
2025-01-20compilers/clike: Speedup cross_compute_intFlorian "sp1rit"​1-0/+15
Expand the expression passed into cross_compute_int using the preprocessor first and then try to evaluate the expanded expression using the host machine compiler and test if the result is valid. Co-authored-by: Charles Brunet <charles.brunet@optelgroup.com>
2025-01-08First draft version of Tasking MIL linking with b_lto and prelinkinggerioldman4-10/+22
2025-01-08Add TASKING compiler supportgerioldman1-0/+126
2024-12-27compilers: De-dup -Wl,-rpath, and -Wl,-rpath-link,Nirbheek Chauhan1-1/+1
When followed by a comma, we can be absolutely sure that these are argument prefixes, and will not consume the next argument to form a single argument. Fixes spammy warnings on apple clang: `ld: warning: duplicate -rpath 'build/dist/darwin_universal/arm64/lib/pkgconfig/../../lib' ignored` Continuation from https://github.com/mesonbuild/meson/pull/13819
2024-12-27arglist: De-dup arg prefixes only when they are used as a prefixNirbheek Chauhan1-2/+2
This was already done for dedup2_prefixes, also do it for dedup1_prefixes, and move export-dynamic to dedup1_args, where it belongs. Also modify some comments around this to clearly distinguish standalone argument matching and argument-prefix matching.
2024-12-19compilers: Do not pass `-fuse-ld=lld` via `-Wl,`LIU Hao1-1/+1
`-fuse-ld=` is a driver option for selection of a linker; it shall not be passed to a linker with `-Wl,`. For the Microsoft compiler and linker, the options for the compiler and those for the linker are separated by `/LINK`, which looks like `cl /cl-options ... /link /link-options ...`. Formally, they are passed in the same command line. When Clang is invoking the Microsoft linker or a Microsoft-style linker (that is, LLD-LINK), every linker option has to prefixed by `-Wl,` or `-Xlink`. Previously, using Clang-CL and LLD-LINK, given: cc = meson.get_compiler('c') assert(cc.has_link_argument('/LTCG')) This code failed to detect the `/LTCG` option, because `-fuse-ld=lld` was passed to the linker, as an invalid option: Command line: `clang E:\lh_mouse\Desktop\t\build\meson-private\tmpg0221fee\testfile.c -o E:\lh_mouse\Desktop\t\build\meson-private\tmpg0221fee\output.exe -D_FILE_OFFSET_BITS=64 -O0 -Werror=implicit-function-declaration -Wl,-WX -Wl,/LTCG -Wl,-fuse-ld=lld` -> 4044 stdout: LINK : warning LNK4044: unrecognized option '/fuse-ld=lld'; ignored LINK : error LNK1218: warning treated as error; no output file generated However, it should be noted that not all LINK options can be passed with `-Wl,`. The `/subsystem:windows,6.1` option has a comma, which would be converted to a space. Therefore, this option must be passed as `-Xlinker -subsystem:windows,6.1`. This issue is not addressed in this commit. Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-12-19mtest: move determine_worker_count to utils, generalizePaolo Bonzini1-3/+3
It is useful to apply a limit to the number of processes even outside "meson test", and specifically for clang tools. In preparation for this, generalize determine_worker_count() to accept a variable MESON_NUM_PROCESSES instead of MESON_TESTTHREADS, and use it throughout instead of multiprocessing.cpu_count(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-12-10compilers: Pass `vs_module_defs` with `/DEF:` to LLD-LINKLIU Hao1-1/+1
Recently, it is possible to install Clang with Visual Studio Installer. By default this Clang has a MSVC target, and invokes the Microsoft Linker; if `-fuse-ld=lld` is specified, it will invoke LLD-LINK. Both linkers take MSVC-style arguments, and take DEF files with `/DEF:<path>`. Previously DEF files were passed in the GNU way, directly on the linker command line like an object file, which caused errors like lld-link: error: ..\my.def: unknown file type While Clang-CL takes Unix-style options, it actually passes MSVC-style options to LINK or LLD-LINK with `-Wl,`. There is already a check for both linkers in `linker_to_compiler_args()`, so it's necessary to do the same in `gen_vs_module_defs_args()`. This commit closes https://github.com/mesonbuild/meson/issues/13988. Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-11-27Add VS preview version.Jussi Pakkanen1-0/+2
2024-11-19compilers: avoid one or more version_compare per targetPaolo Bonzini1-3/+6
version_compare can take a few milliseconds. If you have a thousand object files or a multiple thereof, it adds up. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-10-31Revert "meson: De-dup rpath arguments"Eli Schwartz1-1/+1
This reverts commit 8242187eb06adaabbd9c9dbb6e5d9a8c102ee6a2. This same change was previously introduced in #12495 / commit 30ab9747ae03364ac2ccd4a8f508286c57ed54a5 and subsequently reverted in #12672 / commit 2fbc7b5ce3aced483b196dd10ca9eee1713b7494 Reintroduced in #13819 but it's still the same old problem. To repeat the problem: This breaks at least: - frameworks/17 mpi - frameworks/30 scalapack The problem is that openmpi's pkg-config emitted link arguments includes: ``` -Wl,-rpath -Wl,/path/to/libdir ``` The deduplication logic in meson doesn't contain sufficient information to tell when the compiler is passing an argument that requires values, and definitely cannot tell when that argument is split across argv. But for arguments that *can* do this, it is not possible to deduplicate a single argument as standalone, because it is not standalone. The argument for deduplicating rpath here was that if you have multiple dependencies that all add the same rpath, the Apple ld64 emits a non-fatal warning "duplicate -rpath ignored". Since this is non-fatal, it's not a major issue. A major issue is when builds fatally error out with: ``` FAILED: scalapack_c cc -o scalapack_c scalapack_c.p/main.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group /usr/lib64/libscalapack.so /usr/lib64/liblapack.so /usr/lib64/libblas.so -Wl,-rpath -Wl,/usr/lib64 -Wl,/usr/lib64 -Wl,--enable-new-dtags /usr/lib64/libmpi.so -Wl,--end-group /usr/libexec/gcc/x86_64-pc-linux-gnu/ld: error: /usr/lib64: read: Is a directory ``` Today we have CI for this so the change actually caused our own unittest CI to go red.
2024-10-31meson: De-dup rpath argumentsNirbheek Chauhan1-1/+1
This fixes spammy warnings on apple clang: ld: warning: duplicate -rpath 'build/dist/darwin_universal/arm64/lib/pkgconfig/../../lib' ignored
2024-10-30Merge pull request #13681 from EngJay/13678-fix-ti-cgt-supportJussi Pakkanen1-2/+2
Fix TI C2000 support
2024-10-16add c2000 to ti library naming conditional so static libs are foundJason Scott1-2/+2
2024-10-01compilers: remove hasattr from `can_compile_suffixes`Dylan Baker1-1/+0
This is never set outside the `Compiler.__init__`, only added to. As such there's no reason to have this `hasattr` check. It's wasting time *and* confusing our static checkers.
2024-09-29metrowerks: Pass warning flags to all subtoolsmid-kid1-6/+5
The "on" option is documented as passing the warning flags to all subtools, and implies "most". The default in the majority of projects is -warnings on,nocmdline, which I'd take to be the equivalent of -Wall -Wextra, there isn't really an inbetween.
2024-09-29metrowerks: Fix compute_parameters_with_absolute_pathsmid-kid1-1/+1
2024-09-17compilers: Pass mode to determine_args, not its string valueAndrew McNulty1-1/+1
We always pass the string value of the mode to determine_args, which causes the check on the mode argument inside determine_args to always evaluate to false. Fix this by passing the mode itself, not its value.
2024-09-11compilers: avoid -Wunused-value compiler warning in CLikeCompiler.has_type()Thomas Haller1-1/+1
Otherwise, `CFLAGS='-Wall -Werror' meson build` can fail detection: Running compile: Working directory: ./project/build/meson-private/tmpk86bgc04 Code: #include <sys/types.h> void bar(void) { sizeof(loff_t); } ----------- Command line: `cc ./project/build/meson-private/tmpk86bgc04/testfile.c -o ./project/build/meson-private/tmpk86bgc04/output.obj -c -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1 stderr: ./project/build/meson-private/tmpk86bgc04/testfile.c: In function 'bar': ./project/build/meson-private/tmpk86bgc04/testfile.c:3:13: error: statement with no effect [-Werror=unused-value] 3 | sizeof(loff_t); | ^~~~~~ cc1: all warnings being treated as errors ----------- Checking for type "loff_t" : NO
2024-09-11compilers: avoid -Wunused-value compiler warning in CLikeCompiler.has_members()Thomas Haller1-1/+2
Otherwise, `CFLAGS='-Wall -Werror' meson build` can fail detection: void bar(void) { struct stat foo; foo.st_mtim.tv_nsec; } ----------- Command line: `cc ./project/build/meson-private/tmpqz_gi65d/testfile.c -o ./project/build/meson-private/tmpqz_gi65d/output.obj -c -O3 -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1 stderr: ./project/build/meson-private/tmpqz_gi65d/testfile.c: In function 'bar': ./project/build/meson-private/tmpqz_gi65d/testfile.c:45:24: error: statement with no effect [-Werror=unused-value] 45 | foo.st_mtim.tv_nsec; | ~~~~~~~~~~~^~~~~~~~ cc1: all warnings being treated as errors
2024-08-30Add lto support to clang-cl and lld-linkElliot1-0/+29
Enables lto & thinlto support for clang-cl when used with lld-link.
2024-08-26compilers: Allow prelinking with Apple ClangL. E. Segovia1-0/+4
2024-08-15compilers: do not strip '-isystem' from C build argumentsJunjie Mao1-6/+6
Meson accidentally strips '-isystem' from C build args like ['-isystem', '/path/to/headers'] if the compiler includes the current working directory in the header search paths. The root cause is that '-isystem'[8:] evaluates to an empty string and os.path.realpath('') returns the absolute path to the current working directory, causing meson to think that '-isystem' specifies a default include path. Different compiler versions varies whether the current working directory is in its search paths. For example, on Ubuntu 21.04: # gcc -xc -v -E - gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1) #include "..." search starts here: #include <...> search starts here: . /usr/lib/gcc/x86_64-linux-gnu/10/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include End of search list. While on Ubuntu 24.04: # gcc -xc -v -E - gcc version 13.2.0 (Ubuntu 13.2.0-23ubuntu4) ... #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-linux-gnu/13/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include End of search list. Do not check the '-isystem=' and '-isystem/path/to/header' cases when the option is '-isystem' but the path that follows is not a default search path. Signed-off-by: Junjie Mao <junjie.mao@hotmail.com>