aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins/clang.py
AgeCommit message (Collapse)AuthorFilesLines
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-12Replace some type comments with annotationsTristan Partin1-4/+4
2023-06-26linkers: delay implementations import until detect is runEli Schwartz1-1/+1
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-02-01treewide: add future annotations importEli Schwartz1-0/+1
2022-10-13Add b_thinlto_cache for automatically configuring incremental ThinLTOTatsuyuki Ishi1-2/+8
2022-10-13clang: Support ThinLTO with moldTatsuyuki Ishi1-4/+9
2022-10-09compilers: Add optimization=plain optionJan Tojnar1-0/+1
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-04-30linkers: Add support for mold linkerFini Jastrow1-3/+5
[why] Support for the relatively new mold linker is missing. If someone wants to use mold as linker `LDFLAGS="-B/path/to/mold"` has to be added instead of the usual `CC_LD=mold meson ...` or `CXX_LD=mold meson ...`. [how] Allow `mold' as linker for clang and newer GCC versions (that versions that have support). The error message can be a bit off, because it is generic for all GNU like compilers, but I guess that is ok. (i.e. 'mold' is not listed as possible linker, even if it would be possible for the given compiler.) [note] GCC Version 12.0.1 is not sufficient to say `mold` is supported. The expected release with support will be 12.1.0. On the other hand people that use the un-released 12.0.1 will probably have built it from trunk. Allowing 12.0.1 is helping bleeding edge developers to use mold in Meson already now. Fixes: #9072 Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-02-16flake8: fix various whitespace errors with badly aligned codeEli Schwartz1-1/+1
2022-01-10compilers: push the compiler id to a class variableDylan Baker1-1/+2
It really is a per class value, and shouldn't be set per instance. It also allows us to get rid of useless constructors, including those breaking mypy
2021-11-15only pass clang LTO arguments when they are neededEli Schwartz1-2/+4
If the LTO threads == 0 clang will default to the same argument we manually pass, which meant we dropped support for admittedly ancient versions of clang that didn't yet add that option. Drop the extraneous argument, and add a specific error condition when too old versions of clang are detected. Fixes #9569
2021-10-27fix various flake8 whitespace errorsEli Schwartz1-1/+1
2021-10-10Fix typos discovered by codespellChristian Clauss1-2/+2
2021-09-21Use -Oz when optimization=s in ClangAndrea Pappacoda1-1/+1
-Oz is the appropriate flag to use when you want to produce the smallest possible binary, and is one would expect when setting optimization to s or using the minsize build type.
2021-09-01Clang should error for all implicit function checks (#9165)Dylan Baker1-1/+5
* compilers: improve docstring to `get_compiler_check_args()` There was an incomplete list, which wasn't useful as it now takes an enum anyway. Also add a new entry to the list of reasons to use this function. * clang: Add -Werror=implicit-function-declarations to check_args Unlike GCC, clang warns but doesn't error when an implicit function declaration happens. This means in checks like `compiler.has_header_symbol('string.h', 'strlcat')` (on Linux, at least) that GCC will fail, as there is no such function; clang will emit a warning, but since it exists with a 0 status Meson interprets that as success. To fix this, add `-Werror=implicit-function-declarations` to clang's check arguments. There seems to be something specific about functions that _may_ exist in a header on a given system, as `cc.has_header_symbol('string.h', 'foobar')` will return false with clang, but `strlcat` will return true, even though it's not defined. It is however, defined in some OSes, like Solaris and the BSDs. Fixes #9140
2021-07-13Clang: Apply `-O0`Pamplemousse1-1/+1
Fix #8986
2021-03-04mass rewrite of string formatting to use f-strings everywhereEli Schwartz1-2/+2
performed by running "pyupgrade --py36-plus" and committing the results
2021-02-18compilers: clang: Drop -Xclang before -fcolor-diagnostics flagKrzysztof MaƂysa1-3/+3
Using -Xclang -fcolor-diagnostics provides no advantage to using just -fcolor-diagnostics option and sometimes causes problems: * uncolored diagnostics on Arch Linux: https://bugs.archlinux.org/task/69662 * simple problem with removing flag -fcolor-diagnostics: https://github.com/clangd/clangd/issues/279
2021-02-17compilers: Only insert -flto-jobs in clang's link argumentsDylan Baker1-0/+4
Clang has a hand `-Wunused-command-line-argument` switch, which when turned to an error, gets very grump about `-flto-jobs=0` being set in the compiler arguments (although `-flto=` belongs there). We'll refactor a bit to put that only in the link arguments. GCC doesn't have this probably because, a) it doesn't have an equivalent warning, and b) it uses `-flto=<$numthreads. Fixes: #8347
2021-02-02Add support for LLVM's thinLTODylan Baker1-4/+13
This uses a separate option, b_lto_mode. It works in conjunction with b_lto_threads. Fixes #7493
2021-02-02compilers: Add support for using multiple threads with ltoDylan Baker1-1/+9
Both Clang and GCC support using multiple threads for preforming link time optimizaions, and they can now be configured using the `-Db_lto_threads` option. Fixes #7820
2021-01-04use OptionKey for builtin and base optionsDylan Baker1-3/+4
I would have prefered to do these seperatately, but they are combined in some cases, so it was much easier to convert them together. this eliminates the builtins_per_machine dict, as it's duplicated with the OptionKey's machine parameter.
2020-12-14Propagate Windows target checks upLaurin-Luis Lehning1-1/+1
2020-12-14Make win_subsystem a linker propertyLaurin-Luis Lehning1-6/+0
2020-12-13Add support for driving lld-link indirectly through clang on WindowsLaurin-Luis Lehning1-1/+7
2020-11-17Revert "Add thinlto support. Closes #7493."Jussi Pakkanen1-7/+0
This reverts commit 3e6fbde94c1cb8d4e01b7daf0282c315ff0e6c7d.
2020-11-08Add thinlto support. Closes #7493.Jussi Pakkanen1-0/+7
2020-10-01compilers: clang: use get_compiler_check_argsDylan Baker1-5/+8
2020-09-24compilers: Tell mypy that the compiler mixins are just thatDylan Baker1-15/+3
We do this by making the mixins inherit the Compiler class only when mypy is examining the code (using some clever inheritance shenanigans). This caught a bunch of issues, and also lets us delete a ton of code.
2020-09-24compilers/mixins/clang: Make type safeDylan Baker1-5/+16
2020-08-02Make meson recognize the Qualcomm LLVM toolchainAntony Chan1-0/+5
Meson calls `path/to/clang++ --version` to guess which build toolchain the user has picked to build the source code. For the Qualcomm LLVM toolchain, the output have an unusual output as shown below: ``` clang version 8.0.12 Snapdragon LLVM ARM Compiler 8.0.12 (based on llvm.org 7.0+) Target: arm-unknown-linux-gnueabi Thread model: posix Repository: (ssh://git-hexagon-aus.qualcomm.com:...) InstalledDir: /pkg/qct/software/llvm/release/arm/8.0.12/bin ``` Another unusual pattern is the output of `path/to/ld.qcld --version`: ``` ARM Linker from Snapdragon LLVM ARM Compiler Version 8.0.12 ARM Linker based on LLVM version: 8.0 ``` The Meson logic is modified accordingly so that Meson can correctly determine toolchain as "LLVM aarch64 cross-compiler on GNU/Linux64 OS". This is the expected output of `meson --native-file native_file.ini --cross-file cross_file.ini build/aarch64-debug/`: ``` ... C++ compiler for the host machine: ... (clang 8.0.12 "clang version 8.0.12") C++ linker for the host machine: ... ld.lld 8.0.12 ... ```
2020-05-22Allow building with b_coverage set to true when clang is being used ↔georgev931-0/+3
regardless of linker selection.
2020-05-22compilers: add fetching of define list for clangYevhenii Kolesnikov1-1/+8
Simmilar to gcc, the list of pre-processor defines can be fetched with `-dM -E` option. The way cpu_family is determined on linux relies on this list. Fixes incorrect value of cpu_family on linux, when crosscompiling: ``` CC="clang -m32" meson ./build ``` Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com> Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-04-20compilers: Silence warning about gnu_inline with clangNirbheek Chauhan1-0/+5
The warning is due to a change in behaviour in Clang 10 and newer: https://releases.llvm.org/10.0.0/tools/clang/docs/ReleaseNotes.html#c-language-changes-in-clang This was already fixed for clang++, but not for clang for some reason. It was also fixed incorrectly; by adding `extern` instead of moving from `-Werror` to `-Werror=attributes`.
2020-03-24compilers: Clang can take linkers that are pathsDylan Baker1-0/+14
This will be a regression in 0.54.0 because we now enforce that gnu compilers only get gold, bfd, or lld.
2020-03-15Resolve Clang failure to use -Og with --optimization=gPhillip Johnston1-2/+9
Clang supports the GCC -Og flag, but --optimization=g is not setting that. This is because Clang is referencing the clike_optimization_args, which does not define a flag for 'g'. To address this, we'll mimic the GNU options instead of the C-like ones. Fixes #6619
2020-01-08types: import typing as T (fixes #6333)Daniel Mensinger1-10/+10
2019-10-07compilers: replace CompilerType with MachineInfoDylan Baker1-7/+10
Now that the linkers are split out of the compilers this enum is only used to know what platform we're compiling for. Which is what the MachineInfo class is for
2019-07-15compilers/mixins/clang: Add type annotationsDylan Baker1-12/+21
2019-07-15compilers: Put clang mixin in a moduleDylan Baker1-0/+81