aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins
AgeCommit message (Collapse)AuthorFilesLines
2023-09-18Metrowerks: set optlevel 3 to max optimization argsNomura1-1/+1
According to the Meson documentation, optimization level 3 should set the highest possible optimization for the compiler in use. In Metrowerks, this is 'O4,p'. However, Meson's Metrowerks implementation mapped opt level 3 to '-O3'. This has been fixed.
2023-09-18Metrowerks: remove duplicate optimization argsNomura1-4/+4
The args were in both buildtype and optimization. This broke buildtypes other than plain or custom unless manually setting the optimization level to 0, because Metrowerks chokes on duplicate arguments.
2023-09-09clike compilers: fix cross_* functions' includeMoody Liu1-3/+5
A standard C library may not exist for cross-compile environments, thus the existence of <stdio.h> cannot be guaranteed. Use <stddef.h> instead, this header contains compiler-specific defines thus it usually comes from the compiler.
2023-09-07Add compiler.has_defineMarvin Scholz1-7/+20
Adds a new method to the compiler object, has_define. This makes it possible to check if a preprocessor macro/define is set or not. This is especially helpful if the define in question is empty, for example: #define MESON_EMPTY_DEFINE This would yield the same results as a missing define with the existing get_define method, as it would return an empty string for both cases. Therefore this additional method is needed.
2023-08-22compilers: fix checks handling of internal dependenciesBenoit Pierre1-0/+4
The include directories were not passed to the compiler.
2023-08-11treewide: automatic rewriting of all comment-style type annotationsEli Schwartz3-18/+18
Performed using https://github.com/ilevkivskyi/com2ann This has no actual effect on the codebase as type checkers (still) support both and negligible effect on runtime performance since __future__ annotations ameliorates that. Technically, the bytecode would be bigger for non function-local annotations, of which we have many either way. So if it doesn't really matter, why do a large-scale refactor? Simple: because people keep wanting to, but it's getting nickle-and-dimed. If we're going to do this we might as well do it consistently in one shot, using tooling that guarantees repeatability and correctness. Repeat with: ``` com2ann mesonbuild/ ```
2023-08-11remove useless type annotationsEli Schwartz2-2/+2
These annotations all had a default initializer of the correct type, or a parent class annotation.
2023-08-09Optimize CLikeCompiler._get_file_from_list()Charles Brunet1-13/+11
Simplify and optimize the function. When not on Mac OS, it was iterating two times the list when there were no files in it.
2023-08-08clang: use gcc syntax to enable diagnostics colorkiwixz1-3/+3
clang has supported gcc syntax since version 3.3.0 from 10 years ago. It's better than its own version because it takes a "when" verb which allows us to explicitely ask for "auto". This is useful when overriding flags that came from elsewhere. Before this patch, meson was just treating b_colorout="auto" as "always".
2023-07-25make 'gui_app' an interpreter only conceptDylan Baker1-3/+0
Since it's deprecated anyway, we don't really want to plumb it all the way down into the build and backend layers. Instead, we can just turn it into a `win_subsystem` value in the interpreter if `win_subsystem` isn't already set.
2023-07-19fix implicit_reexport issues and enforce them going forwardEli Schwartz1-2/+1
This detects cases where module A imports a function from B, and C imports that same function from A instead of B. It's not part of the API contract of A, and causes innocent refactoring to break things.
2023-07-12Fix return type of debugfile functionsTristan Partin1-2/+2
It was returning None in some cases while being marked as returning string.
2023-07-12Remove Compiler._build_wrapper(temp_dir:)Tristan Partin1-3/+3
The function wasn't using the keyword argument and all the callers were using env.scratch_dir anyway.
2023-07-12Match the method signatures of parent classesTristan Partin5-15/+15
Names and types of some methods did not match their parent methods.
2023-07-12Fix the typing around Compiler._get_compile_output()Tristan Partin1-3/+1
This function says it returns a string, but was returning None in some cases.
2023-07-12Annotate naked fundamental Python typesTristan Partin8-12/+12
Although mypy wasn't complaining, pyright was.
2023-07-12Replace some type comments with annotationsTristan Partin9-115/+119
2023-07-12Use CompileCheckMode enumTristan Partin4-21/+24
There were a ton of naked strings with TODOs telling us to use the enum.
2023-07-05comp.preprocess(): Do not treat every file as assemblyXavier Claessens1-9/+10
Fixes: #11940
2023-07-05Merge pull request #11742 from xclaesse/link-whole-casesJussi Pakkanen1-1/+1
Fix niche cases when linking static libs
2023-07-04compilers: strip get_define outputKacper Michajłow1-1/+1
Fixes get_define() for MSVC. cl with /std:c11 and newer add a trailing space character when substituting, even if macro is empty. This breaks parsing preprocessed output to extract value. Since they cannot contain spaces it is safe to simply strip parsed value. Fixes: #10179
2023-06-26linkers: delay implementations import until detect is runEli Schwartz3-3/+3
This saves on a 1500-line import at startup and may be skipped entirely if no compiled languages are used. In exchange, we move the implementation to a new file that is imported instead. Followup to commit ab20eb5bbc21ae855bcd211131132d2778602bcf.
2023-05-06Initial support for Metrowerks AssemblerNomura1-0/+68
2023-05-01extract_all_objects: Include PCH object with MSVCXavier Claessens1-1/+1
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-24Initial support for Metrowerks C/C++ compilerNomura1-0/+232
2023-04-21compilers: convert method to get assert control to a booleanDylan Baker1-2/+4
C like compilers only off `-DNDEBUG` to disable asserts. This is not a universal paradigm however. Rust, for example has an argument that takes a boolean. To better represent this, we allow passing a `disable` boolean. `disable` was chosen rather than `enable` because it allowed all existing logic to be left in place
2023-04-11fix various spelling issuesJosh Soref2-3/+3
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-11Change "can not" to "cannot" throughout projectHiPhish2-2/+2
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 Lavarec5-0/+6
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-03-18Small fix on how cc.sizeof (and similar functions) use the 'prefix' kwargVolker Weißmann1-14/+14
2023-03-16prevent lib prefix warning from pkg-configCharles Brunet2-8/+8
2023-03-12Fix warning_level=everything with GCC 8David Robillard1-1/+3
This option was introduced with GCC 8.1.0 as in the original commit, but the value wasn't right initially and was volatile during the 8 series. To avoid this, this commit moves the warning to 9.1.0 (the next version we generally care about), since we don't want to get too deep into the weeds of point releases, and a warning not being used yet in some particular version of GCC isn't a big deal.
2023-02-27Use caching in Compiler.sizeof() and Compiler.alignment()Andres Freund1-14/+16
2023-02-17compilers: -fprofile-correction is only a valid switch with gcc itself.Luke Elliott1-1/+4
clang++ main.cpp -fprofile-correction clang-15: warning: optimization flag '-fprofile-correction' is not supported [-Wignored-optimization-argument]
2023-02-08compilers: Remove /utf-8 from Visual Studio command args onceDylan Baker1-3/+9
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 Baker1-1/+2
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 Fan1-0/+10
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-01pylint 2.16: join iterables without repeated appendEli Schwartz1-3/+1
We do += style joining in a loop, but we could just join with `''.join()` which is faster, neater, and simpler.
2023-02-01treewide: add future annotations importEli Schwartz10-0/+10
2023-02-01remove /utf-8 option when /validate-charset- is presentCharles Brunet1-1/+3
2022-12-27emscripten: remove redundant `thread_flags` implementationKleis Auke Wolthuizen1-3/+0
Since it's the same as the one in `CLikeCompiler`.
2022-12-27emscripten: use single arguments when specifying optionsKleis Auke Wolthuizen1-1/+1
i.e. without a space between the "-s" and option name. See: https://github.com/emscripten-core/emscripten/issues/11463 This is supported since Emscripten 1.39.19, see: https://github.com/emscripten-core/emscripten/commit/f45bea21f3a8f74a68ed4e3e3d7e290807ee2aff
2022-12-27emscripten: prefer `-pthread` over `-s USE_PTHREADS=1`Kleis Auke Wolthuizen1-2/+2
See: https://github.com/emscripten-core/emscripten/issues/12346 This is supported since Emscripten 1.38.33, see: https://github.com/emscripten-core/emscripten/commit/24350798a8570f567327f873cf1efb0361aec284
2022-12-22meson: Cache os.path.realpath in CLikeCompilerArgsNirbheek Chauhan1-4/+9
Profiling showed that we were spending 25s inside os.path.realpath() on Windows while generating compile lines for build.ninja, inside NinjaBackend.generate() The real path for these will not (should not) change during a single meson invocation, so cache all these. Brings build.ninja generation from 73s to 47s on my machine.
2022-11-30pylint: enable the set_membership pluginDylan Baker2-4/+4
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 Robillard9-7/+254
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-25compilers: Make sure to not use ccache in compiler checksXavier Claessens3-8/+5
ccache was used in all command lines but disabled using CCACHE_DISABLE in Compiler.compile() method. Wrapping invokations still has a cost, especially on Windows. With sccache things are even worse because CCACHE_DISABLE was not respected at all, making configure *extremely* slow on Windows when sccache is installed.
2022-10-24Fix mismatched param names between Compiler and BasicLinkerIsCompilerMixinTristan Partin1-2/+2
2022-10-23gnulike: Fix preprocessing files with any extensionXavier Claessens1-0/+6
2022-10-23Compilers: Add a preprocessor mode for clike compilersXavier Claessens2-0/+23
A compiler object can now return a list of "modes", they are new compiler object specialized for a specific task.