summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
AgeCommit message (Collapse)Author
2025-02-27use ElementaryOptionValues instead of open coding... againDylan Baker
2025-02-27modules/rust: use 'nightly' as the bindgen version if the compiler is nightlyDylan Baker
This adds tracking for both nightly and beta to the rust compiler.
2025-02-27compilers/detect: Split -beta and -nightly suffixes from rustcDylan Baker
Store both a full version with the nightly and beta suffixes, and the version as just X.Y.Z. This sort of distinction is why full_version exists. This fixes an issue with the bindgen module where we pass invalid version of X.Y.Z-beta and X.Y.Z-nightly.
2025-02-27Fixes issue 14089 (detection of Intel compiler)Tom Evers
2025-02-16c: add -Wno-vla-larger-than to the exceptions for -Wno*Paolo Bonzini
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 Pakkanen
2025-02-11ninja backend: Use swiftc flag -working-directory if availableMarco Rebhan
This makes SourceKit-LSP work using a meson-generated compile_commands.json.
2025-02-05options: Replace uses of `UserOption[T.Any]` with a Union of UserOption typesDylan Baker
The fact that UserOption is generic is really an implementation detail, not something to be used publicly. So by having an `AnyOptionType` alias, we can get better type checking, as can be seen by the patch as a whole. One of the big fixes it replace open-coded equivlalents of `MutableKeydOptionDictType` with that type alias.
2025-02-05options: Add an EnumeratedUserOption classDylan Baker
This will allow us to take choices out of the UserOption class, which doesn't actually use this attribute.
2025-02-05options: use dataclasses for UserOptionDylan Baker
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 Baker
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-02-05compilers: use super().get_options() instead of CompilerClass.get_options()Dylan Baker
Because the latter doesn't always interact with the MRO correctly.
2025-02-05compilers: fix the UserStdOption name of the C and C++ compilersDylan Baker
2025-02-05options: Get rid of the invalid _U type, and use UserOption[_T]Dylan Baker
2025-02-03rust: use f-string to build rpath argumentsPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-02-03ninjabackend: start adjusting for differences between rustc and rustdocPaolo Bonzini
Add functions to RustCompiler() to account for differences between rustc and "rustdoc --test": rustdoc always generates a binary, does not support -g, and does not need --emit. Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-02-03ninjabackend: unify building rpath argsPaolo Bonzini
Implement RustCompiler.build_rpath_args, so that more code can be shared between non-Rust and Rust targets. Then, RustCompiler can override it to convert the arguments to "-C link-arg=" and add the rustup sysroot. Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-01-29swift: Fix duplicate SDK include paths causing a compile errorPiotr Brzeziński
Some dependencies can bring include paths pointing to older macOS SDK's. In this case, it was libffi pointing to SDK from 12.0. When the Foundation framework is imported in Swift, swiftc attempts to import the FFI module from the most recent version of the SDK, which causes a compilation error because of conflicting definitions between the two SDK versions. SwiftPM also had this problem: https://github.com/swiftlang/swift-package-manager/pull/6772 The solution on our side is a simplified version of what SwiftPM did. Let's naively look for .sdk paths in the compile args of our dependencies and replace them with the most recent one. I included a test which is confirmed to fail without the workaround added in this patch. This was not tested on anything else than macOS, but I don't expect it to make the situation worse in any case.
2025-01-28Merge pull request #13642 from dcbaker/submit/fix-objc-standardsJussi Pakkanen
Support lists for ObjC and ObjC++ standards
2025-01-28compilers/clang++: Add `-fpch-instantiate-templates` to speed up clang++ buildsinsunaa
- see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5168
2025-01-27compilers: Check if GCC has support for ObjC and/or ObjC++Dylan Baker
Since this is optional, we should not accept that GCC is a valid ObjC or G++ is a valid ObjC++ Compiler unless we've tested that they can actually do a basic compile. This requires fixing a number of tests that have broken assumptions. In some cases I've split tests where issues with one language would hide the other. It would be great if we had a competent test framework that allowed subtests to skip, unfortunately we have python's unittest instead. Because of that we can't avoid extra tests by use of subtests.
2025-01-27compilers: split Apple C++ version handling to a mixinDylan Baker
2025-01-27compilers: move Apple C Std version handling to a mixinDylan Baker
To avoid duplication between C and ObjC
2025-01-27compilers/objcpp: Use the GnuCPPStdMixin for ObjC++Dylan Baker
2025-01-27compilers/gnu: Split Gnu C++ standard handling into a mixin classDylan Baker
So we can re-use it in the ObjC++ standards
2025-01-27compilers/objc: Use Shared GNU C standard handlingDylan Baker
2025-01-27compilers/gnu: Pull C Standard handling out of GnuCCompilerDylan Baker
So we can re-use it for the ObjC code
2025-01-27compilers/objcpp: Use shared C++ standards with ClangCPPStandardDylan Baker
2025-01-27compilers/clang: split the Std handling for C++ out of the ClangCPPCompilerDylan Baker
We'll want to use this for the ObjC++ compiler too.
2025-01-27compilers/objc: Use shared C standards with clang C compilerDylan Baker
This means that the two compilers will update together, and that ObjC has the list behavior that C does.
2025-01-27compilers/clang: Move the Mixin for C standards out of the c moduleDylan Baker
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-27adding c_std=c2y option for gcc-15ajs
Signed-off-by: ajs <sam4lordjesus@outlook.com>
2025-01-27adding c_std=c2y option for clangajs
Signed-off-by: ajs <sam4lordjesus@outlook.com>
2025-01-20Remove GCC's -Wunsuffixed-float-constants from warningsDavid Robillard
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"​
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-15Fix minimum required Apple clang version for C++26Nikolai Vavilov
2025-01-09Add Linear ASM compilerWu, Zhenyu
Fix #13670
2025-01-09Merge pull request #12342 from gerioldman/TaskingCCompilerJussi Pakkanen
Add support for the TASKING compiler family, and its MIL linking feature
2025-01-08Update cpp language list for intel compiler on windowsborg323
2025-01-08rust: add 2024 editionPaolo Bonzini
Rust edition 2024 is being released in February, add support for rust_std=2024. Resolves: #14074 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-01-08rust: change warning_level=0 to "--cap-lints allow"Paolo Bonzini
This is a better and more backwards-compatible way to disable all warnings, compared to "-A warnings". The Rust RFC (https://rust-lang.github.io/rfcs/1193-cap-lints.html) explains the rationale: > We would very much like to be able to modify lints, however. For example > rust-lang/rust#26473 updated the missing_docs lint to also look for missing > documentation on const items. This ended up breaking some crates in the > ecosystem due to their usage of #![deny(missing_docs)]. While at it, document that Rust deviates from the other languages in its interpretation of warning_level=0. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-01-08First draft version of Tasking MIL linking with b_lto and prelinkinggerioldman
2025-01-08Add TASKING compiler supportgerioldman
2024-12-29compilers: cache the results of is_source()Paolo Bonzini
is_source() is called almost 900000 times in a QEMU setup. Together with the previously added caching, this basically removes _determine_ext_objs() from the profile when building QEMU. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-12-27compilers: De-dup -Wl,-rpath, and -Wl,-rpath-link,Nirbheek Chauhan
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 Chauhan
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 Hao
`-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-19rust: raise a warning if clippy is used instead of rustcPaolo Bonzini
clippy-driver is not meant to be a general-purpose compiler front-end. Since Meson can now provide natively the ability to invoke clippy, raise a warning if someone uses it that way. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-12-19scripts: add "clippy" internal toolPaolo Bonzini
Similar to the "ninja scan-build" target for C, add a clippy internal tool that runs clippy-driver on all crates in the project. The approach used is more efficient than with "ninja scan-build", and does not require rerunning Meson in a separate build directory; it uses the introspection data to find the compiler arguments for the target and invokes clippy-driver with a slightly modified command line. This could actually be applied to scan-build as well, reusing the run_tool_on_targets() function. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-12-19mtest: move determine_worker_count to utils, generalizePaolo Bonzini
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>