aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
AgeCommit message (Collapse)AuthorFilesLines
2023-12-05compilers: drop dead codeEli Schwartz7-24/+0
no_warn_args is unused. Its only purpose was to implement automatic hiding of UB in transpiled code, and it was not used at all in languages other than C/C++ -- specifically when the C/C++ source files were created by transpiling from vala or cython.
2023-12-01More robust linker detection for armar (TI vs non-TI)Will Toohey1-3/+1
2023-11-26fix broken type annotation imports being ignoredEli Schwartz1-1/+1
If an annotation could not be resolved, it's classified as a "missing import" and our configuration ignored it: ``` Skipping analyzing "mesonbuild.backends": module is installed, but missing library stubs or py.typed marker ``` As far as mypy is concerned, this library may or may not exist, but it doesn't have any typing information at all (may need to be installed first). We ignored this because of our docs/ and tools/ thirdparty dependencies, but we really should not. It is trivial to install them, and then enforce that this "just works". By enforcing it, we also make sure typos get caught.
2023-11-22clike: Deduplicate rpath linker flagsFini Jastrow1-2/+2
[why] On Apple clang 15.0.0 linker (i.e. ld64 1015.7) giving the same rpath multiple times raises a warning: ld: warning: duplicate -rpath '/local/lib' ignored This can frequently happen when linking several dependencies that all have that rpath in e.g. pkgconfig. [how] Deduplicate all rpath arguments. [note] I'm not sure how the code handles --start/end-group, but for rpath that should not make any difference as that is not bound to a group. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-11-04Fix visibility attribute support check for GCC on WindowsChristoph Reiter1-7/+7
has_function_attribute() depends on -Wattributes being emitted when an attribute is not supported by the compiler. In case of GCC on Window (at least) there is no warning in case the attribute is used on a declaration. Only once there is also a function definition does it emit a warning like: a.c: In function ‘foo’: a.c:8:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes] 8 | } To fix this add a dummy function definition to all visibility compiler checks in meson. The tests in "197 function attributes" only checked for positive return result on on-msvc compilers, except one special case for dllexport/dllimport. Refactor the tests a bit so one can specify also a negative expected result, and add tests for all visibility attribute variants.
2023-10-31Fix traceback on AIX in shlib archiving codeAditya Vidyadhar Kamath1-0/+2
A compiler may not have a linker: ``` 'NoneType' object has no attribute 'get_command_to_archive_shlib' ```
2023-10-20fix ninja backend rules containing internal enum reprsEli Schwartz3-4/+4
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-20add missing imports for future annotationsEli Schwartz1-0/+2
2023-10-19rust: Always link dll and exe with the correct vscrtXavier Claessens1-0/+16
This fixes missing flags in the link_whole case and link failure for static libraries.
2023-10-19Remove duplicated code to canonicalize b_vscrt option valueXavier Claessens4-70/+29
Add a common function that infers vscrt from buildtype in Compiler base class.
2023-10-16compilers/d: use DFeatures for get_features_argsDylan Baker2-85/+64
2023-10-16compilers/d: remove duplicate method from subclassDylan Baker1-88/+0
The DCompiler and DmDLikeCompiler classes both implement the exact same `get_feature_args()` method. The DmdLikeCompiler inherits the DCompiler. As such, removing it doesn't change the behavior of anything, but decreases the chances of bugs being introduced, as well as LoC.
2023-10-12cpp: use -nostlib++ instead of -nostlib for custom cpp_stdlibMattijs Korpershoek1-0/+3
The <lang>_stdlib can be used in cross files to use a custom standard library for a given language. When cpp_stdlib is used in a cross file, meson passes * -nostdinc++ to the compiler * -nostlib to the linker According to [1] (gcc) and [2] (clang), we should pass -nostlib++ to the linker when we don't want to link to the standard C++ library. Currently, we pass -nostlib. Fix this by implementing a C++ specific get_no_stdlib_link_args() function. [1] https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-nostdlib_002b_002b [2] https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-nostdlib Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-10-09Allow c++23 in gcc-11.Benjamin Redelings1-1/+1
2023-10-04clike compilers: use MesonBugException instead of AssertionErrorMarvin Scholz1-1/+1
Follow-up to #12223
2023-09-26compilers: use correct version comparison for openbsd librariesEli Schwartz1-3/+6
It should *be* a version comparison. We are guaranteed to get a two-element version number, which also parses as a float but a float doesn't correctly handle version sorting when the second component differs in number of digits. The standard way to handle this is by comparing tuples such that each component is an integer. Do so here. Fixes #12195 Co-authored-by: George Koehler <xkernigh@netscape.net> (for unittests)
2023-09-25fix bug where all java builds & tests fail to run SanityCheck on JDK11Alan Brooks1-1/+1
Needed a classpath set in the current working directory. This was on a Zulu build of OpenJDK 11.0.17 on a macOS ARM machine. The errors folks might encounter: Error: Could not find or load main class SanityCheck Caused by: java.lang.ClassNotFoundException: SanityCheck
2023-09-24cpp: restore c++26 supportChristoph Reiter1-1/+1
c++26 support was added in #11986, but regressed in #10332 because the versions now get checked against the global _ALL_STDS list, and c++26 was missing there. Fix by adding c++26 to _ALL_STDS
2023-09-21objective-c++: add support for current supported standards in Apple ClangSteven Noonan1-1/+3
Pulled from this list on Xcode 15 beta: $ clang -E -dM -xobjective-c++ -std=arglbargle -o - /dev/null error: invalid value 'arglbargle' in '-std=arglbargle' note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU extensions' standard note: use 'c++11' for 'ISO C++ 2011 with amendments' standard note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard note: use 'c++14' for 'ISO C++ 2014 with amendments' standard note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard note: use 'c++17' for 'ISO C++ 2017 with amendments' standard note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' standard note: use 'c++20' for 'ISO C++ 2020 DIS' standard note: use 'gnu++20' for 'ISO C++ 2020 DIS with GNU extensions' standard note: use 'c++2b' for 'Working draft for ISO C++ 2023 DIS' standard note: use 'gnu++2b' for 'Working draft for ISO C++ 2023 DIS with GNU extensions' standard Signed-off-by: Steven Noonan <steven@uplinklabs.net>
2023-09-19Rust: Use Popen_safe_logged in sanity checksXavier Claessens1-11/+5
2023-09-18Metrowerks assembler should not inherit opt args from mixinNomura1-0/+3
The Metrowerks assembler does not support optimization flags. However, it received the same opt args as the Metrowerks C and C++ compilers, because it inherits from the 'MetrowerksCompiler' mixin. This broke builds with opt level higher than 0 that used the Metrowerks Assembler, as the latter received unsupported args. This is now fixed.
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-07Rename OptionOverrideProxy to OptionsView and move to coredataXavier Claessens1-2/+2
Coredata is where all option handling is done so it makes sense there. It is a view on a list of options for a given subproject and with optional overrides. This change prepare for using that view in a more generic way in the future.
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-09-01compilers: fix compiler detection when the "ccache" string is in the pathFilipe Laíns1-1/+1
Signed-off-by: Filipe Laíns <lains@riseup.net>
2023-08-30Merge pull request #10332 from xclaesse/std-optJussi Pakkanen3-96/+98
c_std, cpp_std: Change to a list of desired versions in preference order
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 Schwartz7-25/+25
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-08-07c_std, cpp_std: Change to a list of desired versions in preference orderXavier Claessens2-94/+96
Projects that prefer GNU C but can fallback to ISO C can now set for example `default_options: 'c_std=gnu11,c11'` and it will use gnu11 when available, fallback to c11 otherwise. It is an error only if none of the values are supported by the current compiler. This allows to deprecate gnuXX values from MSVC compiler, that means that `default_options: 'c_std=gnu11'` will now print warning with MSVC but still fallback to 'c11' value. No warning is printed if at least one of the values is valid, i.e. `default_options: 'c_std=gnu11,c11'`. In the future that deprecation warning will become an hard error because `c_std=gnu11` should mean GNU is required, for projects that cannot be built with MSVC for example.
2023-08-06UserArrayOption: Remove user_input argumentXavier Claessens1-2/+2
The only place it can be set to False is from optinterpreter. Better check value there and deprecate string usage.
2023-07-31Merge pull request #11986 from williamspatrick/clang-enable-cpp23Jussi Pakkanen1-2/+24
add support for newer C++ -std= flags on Clang/GCC
2023-07-25make 'gui_app' an interpreter only conceptDylan Baker2-7/+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 Schwartz2-5/+3
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-17Merge pull request #11976 from tristan957/cleanupsJussi Pakkanen18-366/+394
Some various type related cleanups
2023-07-15rust: disable overflow-checks by defaultDylan Baker1-1/+1
These result in very large binaries when linked, and are not generally useful. A user can turn them back on by passing `-C overflow-checks=yes` manually via `-Drust_args` or the `RUSTFLAGS` environment variable fixes: #11785
2023-07-14c++: add support for c++23/c++26 standard and aliasesSteven Noonan1-2/+20
GCC 12.3 and Clang 16 support -std flags for c++23/c++2b. The unreleased GCC 14 and Clang 17 will support -std flags for c++26/c++2c. Signed-off-by: Steven Noonan <steven@uplinklabs.net> Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-07-14c++: add fallback mappings for C++23 and C++26Steven Noonan1-0/+4
The c++23 mappings apply to current production compilers (GCC, Clang). None of the production c++ compilers support c++26 flags yet, but this mapping will be ready once they do. Signed-off-by: Steven Noonan <steven@uplinklabs.net> Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-07-12Fix return type of debugfile functionsTristan Partin2-3/+3
It was returning None in some cases while being marked as returning string.
2023-07-12Remove Compiler._build_wrapper(temp_dir:)Tristan Partin2-5/+4
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 Partin7-19/+19
Names and types of some methods did not match their parent methods.
2023-07-12Make CPPCompiler.get_display_language() a classmethodTristan Partin1-2/+2
This matches the parent declaration.
2023-07-12Fix the typing around Compiler._get_compile_output()Tristan Partin2-7/+7
This function says it returns a string, but was returning None in some cases.
2023-07-12Annotate naked fundamental Python typesTristan Partin13-36/+35
Although mypy wasn't complaining, pyright was.
2023-07-12Replace some type comments with annotationsTristan Partin12-217/+241
2023-07-12Use CompileCheckMode enumTristan Partin9-45/+45
There were a ton of naked strings with TODOs telling us to use the enum.