summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins/visualstudio.py
AgeCommit message (Collapse)Author
2025-12-01compilers: pass target to get_lto_*_argsPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-23compilers: forward gen_vs_module_defs_args to linkerPaolo Bonzini
This adds support for DEF files to rust and removes some hasattr duck typing. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-11-19compilers: Remove Environment parameter from CLikeCompiler.has_argumentsDylan Baker
2025-11-19compilers: Remove Environment parameter from ↵Dylan Baker
Compiler.symbols_have_underscore_prefix
2025-11-19compilers: Remove Environment parameter from Compiler.sanitizer_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.find_libraryDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.thread_flagsDylan Baker
Same logic as the openmp flags
2025-11-19compilers: Remove Environment parameter from Compiler.openmp_flagsDylan Baker
I've done the compile and link flags in one commit since they're so closely related
2025-11-19compilers: Remove Environment parameter from Compiler.has_function_attributeDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler._build_wrapperDylan Baker
2025-11-19Prevent /link being passed twice in compiler flagsFrankie Robertson
This does not work correctly with clang-cl/lld-link
2025-11-12compilers: pass target and env to sanitizer_*_argsPaolo Bonzini
The Rust compiler will need these to check the rust_nightly option. 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-03-09compilers: convert `b_sanitize` to a free-form array optionPatrick Steinhardt
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>
2024-11-27Add VS preview version.Jussi Pakkanen
2024-08-30Add lto support to clang-cl and lld-linkElliot
Enables lto & thinlto support for clang-cl when used with lld-link.
2024-08-08Fix compiling ObjC/ObjC++ on Windows/MinGWJonathan Schleifer
Co-Authored-By: L. E. Segovia <amy@amyspark.me>
2024-08-07compilers: change get_argument_syntax to static methodKacper Michajłow
This allows to get this fixed value before the class is initialized. Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2024-07-11Move OptionKey in the option source file.Jussi Pakkanen
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-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-03-11Only link to generated pch object when using msvc. (#12957)Elliot
backend: Only link to generated pch object when using msvc
2024-02-25compilers: Forward Meson's preference of lld-link to clang-clL. E. Segovia
The latter prefers LINK.exe by default, which rejects GNU-like linker flags.
2023-12-23Remove `get_buildtype_args` functionCharles Brunet
This is a first step to make `buildtype` a true alias of `debug` and `optimization` options. See #10808. Relates to: - #11645 - #12096 - #5920 - #5814 - #8220 - #8493 - #9540 - #10487 - #12265 - #8308 - #8214 - #7194 - #11732
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field
2023-10-20fix ninja backend rules containing internal enum reprsEli Schwartz
Partially reverts commit 1624354f33bf0a33f0e715ba1ca391ae0154ad19 which moved a bunch of stuff from strings to enums. The issue here is that Compiler.mode is not just, or primarily, something we compare, but is instead written in as e.g. `rule c_{compiler.mode}` to build.ninja, so this identifier needs to be a string. Ultimately, the issue is that the commit tried to rewrite a bunch of things called "mode" that had a couple of TODOs saying to use enums... but it rewrote everything called "mode" regardless of whether it was a function kwarg or a compiler property, even though the TODO only applied to one of them.
2023-10-19Remove duplicated code to canonicalize b_vscrt option valueXavier Claessens
Add a common function that infers vscrt from buildtype in Compiler base class.
2023-07-12Match the method signatures of parent classesTristan Partin
Names and types of some methods did not match their parent methods.
2023-07-12Annotate naked fundamental Python typesTristan Partin
Although mypy wasn't complaining, pyright was.
2023-07-12Replace some type comments with annotationsTristan Partin
2023-07-12Use CompileCheckMode enumTristan Partin
There were a ton of naked strings with TODOs telling us to use the enum.
2023-05-01extract_all_objects: Include PCH object with MSVCXavier Claessens
This changes the object file name with ninja backend to match the name used by vs backend and add it in outputs of the ninja rule.
2023-04-11fix various spelling issuesJosh Soref
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-11Change "can not" to "cannot" throughout projectHiPhish
The word "cannot" expresses inability to do something whereas "can not" expresses the ability to refrain from doing something.
2023-03-23asm: Add sx extensionRenan Lavarec
docs: gcc https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html scons: https://scons.org/doc/3.0.5/HTML/scons-user/apb.html .S Windows: assembly language file ARM: CodeSourcery Sourcery Lite .sx assembly language file + C pre-processor POSIX: assembly language file + C pre-processor
2023-02-08compilers: Remove /utf-8 from Visual Studio command args onceDylan Baker
Instead of looking at it each time get_always_args() is called, do it once. Also avoid mutating global state.
2023-02-08compilers: Copy const always_args before returningDylan Baker
Eventually we would probably be better served (to avoid unnecessary copies) to use the ImmutableListProtocol here, but for the moment this is effective, it's also what we do in every other case.
2023-02-07Visual Studio: Drop /utf-8 if it is not supportedChun-wei Fan
We assume /utf-8 for all C builds unless /source-charset or /execution-charset is specified, but then this will cause trouble for Visual Studio 2013 or earler since the /utf-8 flag is only supported since Visual Studio 2015. Specifically, if we try to check whether compiler flags are supported, those checks will fail since /utf-8 is never supported on these older Visual Studio versions. Drop /utf-8 from get_always_args() if we are using Visual Studio 2013 or earlier.
2023-02-01treewide: add future annotations importEli Schwartz
2023-02-01remove /utf-8 option when /validate-charset- is presentCharles Brunet
2022-11-30pylint: enable the set_membership pluginDylan Baker
Which adds the `use-set-for-membership` check. It's generally faster in python to use a set with the `in` keyword, because it's a hash check instead of a linear walk, this is especially true with strings, where it's actually O(n^2), one loop over the container, and an inner loop of the strings (as string comparison works by checking that `a[n] == b[n]`, in a loop). Also, I'm tired of complaining about this in reviews, let the tools do it for me :)
2022-11-27Add warning_level=everythingDavid Robillard
Adds a new maximum warning level that is roughly equivalent to "all warnings". This adds a way to use `/Wall` with MSVC (without the previous broken warning), `-Weverything` with clang, and almost all general warnings in GCC with strictness roughly equivalent to clang's `-Weverything`. The GCC case must be implemented by meson since GCC doesn't provide a similar option. To avoid maintenance headaches for meson, this warning level is defined objectively: all warnings are included except those that require specific values or are specific to particular language revisions. This warning level is mainly intended for new code, and it is expected (nearly guaranteed) that projects will need to add some suppressions to build cleanly with it. More commonly, it's just a handy way to occasionally take a look at what warnings are present with some compiler, in case anything interesting shows up you might want to enable in general. Since the warnings enabled at this level are inherently unstable with respect to compiler versions, it is intended for use by developers and not to be set as the default.
2022-10-23Compilers: Add a preprocessor mode for clike compilersXavier Claessens
A compiler object can now return a list of "modes", they are new compiler object specialized for a specific task.
2022-10-09compilers: Add optimization=plain optionJan Tojnar
https://github.com/mesonbuild/meson/pull/9287 changed the `optimization=0` to pass `-O0` to the compiler. This change is reasonable by itself but unfortunately, it breaks `buildtype=plain`, which promises that “no extra build flags are used”. `buildtype=plain` is important for distros like NixOS, which manage compiler flags for optimization and hardening themselves. Let’s introduce a new optimization level that does nothing and set it as the default for `buildtype=plain`.
2022-08-26Fix purely white space issues reported by flake8Alf Henrik Sauge
2022-07-11Revert /utf-8 changes in the visualstudio mixin to the 0.62.0 stateEli Schwartz
Specifically, this is a combination of the following: - Revert "visualstudio.py: Apply /utf-8 only on clang or VS2015+" This reverts commit 6e7c3efa793c25259891d3b5471343f95fb061fa. - Revert "Visual Studio: Only use /utf-8 on VS2015 or later or clang-cl" This reverts commit 8ed151bbd786d2c52e6ea7b7cfe3147fc41ec041. The changes were broken and untested, although this is because of a lack of general CI testing for all languages on Windows. At least, this broke the use of ifort, and possibly more. The changes are fundamentally a bit "exciting", as they step out of the hierarchy of compiler definitions and apply arguments almost willy-nilly. And apparently it's leaky all over the place. I don't understand all of what is going on with it, but it plainly failed to achieve its desired goal and needs to be rolled back ASAP.
2022-06-21visualstudio.py: Apply /utf-8 only on clang or VS2015+Chun-wei Fan
In PR 10263, we didn't account for that we may have initialize the Visual Studio-like compiler two times, once for a C compiler and once for the C++ compiler, so we end up with Meson breaking on Visual Studio 2013 or earlier, such as when building GLib. Fix this by setting up the always_args member of the VisualStudioLikeCompiler instance during __init__() as needed, so that we avoid falling into modifying shared objects.
2022-05-06compiler.has_argument: Add `-Werror=unknown-warning-option` to clang-cl cmd lineKhairul Azhar Kasmiran
2022-04-25Visual Studio: Only use /utf-8 on VS2015 or later or clang-clChun-wei Fan
The compiler flag only exists on Visual Studio 2015 or later, or clang-cl, and using this always can interfere with compiler feature detection when this flag is not supported. So, remove '/utf-8' from always_args if we are on Visual Studio 2013 or earlier.