aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/d.py
AgeCommit message (Collapse)AuthorFilesLines
2023-07-12Annotate naked fundamental Python typesTristan Partin1-8/+7
Although mypy wasn't complaining, pyright was.
2023-07-12Replace some type comments with annotationsTristan Partin1-36/+42
2023-07-12Use CompileCheckMode enumTristan Partin1-2/+2
There were a ton of naked strings with TODOs telling us to use the enum.
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-04-21compilers: convert method to get assert control to a booleanDylan Baker1-6/+12
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-11Change "can not" to "cannot" throughout projectHiPhish1-1/+1
The word "cannot" expresses inability to do something whereas "can not" expresses the ability to refrain from doing something.
2023-02-27Use caching in Compiler.sizeof() and Compiler.alignment()Andres Freund1-7/+7
2022-11-30pylint: enable the set_membership pluginDylan Baker1-1/+1
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-29Don't ignore documentation-related flags for D compilersAxel Ricard1-1/+3
Fixes #11085
2022-11-27Add warning_level=everythingDavid Robillard1-1/+5
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: Keep ccache and exelist separatedXavier Claessens1-1/+1
Only combine them in the Compiler base class, this will make easier to run compiler without ccache.
2022-10-09compilers: Add optimization=plain optionJan Tojnar1-2/+4
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-24fix linker regression for compilers that don't accept LDFLAGS directlyEli Schwartz1-8/+13
e.g. ldc -- the compiler needs to process args before consuming them. Fixes #10693
2022-07-03move various unused typing-only imports into type-checking blocksEli Schwartz1-1/+3
2022-04-30implement and test a few compiler checks for DRemi Thebault1-2/+99
- run - sizeof - alignment - has_header
2022-04-30linkers: Add support for mold linkerFini Jastrow1-2/+2
[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-03-01compilers/d: fix mangling of rpath-link in DMD-like compilersEli Schwartz1-1/+1
We didn't consider that it has arguments following it, so the resulting compiler command line ended up with stuff like: -L=-rpath-link -L=-L=/path/to/directory -L=more-args and the directory for rpath-link got eaten up as a regular -L path to the compiler rather than being passed as -Xlinker to the linker. Then the -rpath-link would consume the next -Xlinker argument, end up with the wrong rpath-link (may or may not cause link errors) and then disappear arguments we need. As an example failure mode, if the next argument is -soname this treats the soname text as an input file, which probably does not exist if it was generated in a subdirectory, and also because it can never be successfully built in the first place -- though if it did, it would link to itself which is very wrong.
2022-02-06dlang: fix #9250 invalid include flag for root directoryTobias Pankrath1-0/+2
2022-01-10compilers: push the compiler id to a class variableDylan Baker1-3/+5
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-12-30fix type annotations for compiler toolchain rpathsEli Schwartz1-1/+1
We pass around a tuple of rpaths, because rpaths *can* be more than one. But all the annotations said it would be a str instead.
2021-11-22ldc2: invoke -Oz instead of -OsDenis Feklushkin1-1/+1
2021-10-10Fix typos discovered by codespellChristian Clauss1-3/+3
2021-09-24pylint: check for duplicate importsDylan Baker1-1/+2
I ran into one of these from LGTM, and it would be nice if pylint could warn me as part of my local development process instead of waiting for the CI to tell me.
2021-08-31pylint: turn on superflous-parensDylan Baker1-2/+2
We have a lot of these. Some of them are harmless, if unidiomatic, such as `if (condition)`, others are potentially dangerous `assert(...)`, as `assert(condtion)` works as expected, but `assert(condition, message)` will result in an assertion that never triggers, as what you're actually asserting is `bool(tuple[2])`, which will always be true.
2021-07-14linkers: remove is_shared_module argument to get_soname_argsPaolo Bonzini1-3/+2
The argument is now unused, drop it.
2021-06-29fix: Always explicitly set encoding for text files (fixes #8263)Daniel Mensinger1-1/+1
2021-03-19split program related classes and functions out of dependenciesDylan Baker1-1/+1
Dependencies is already a large and complicated package without adding programs to the list. This also allows us to untangle a bit of spaghetti that we have.
2021-03-17Fix D lib search path translationRemi Thebault1-15/+49
This requires quite a complex and messy logic. As @dcbaker suggested in #8491, this could be replaced by an abstraction over linker flags instead of having GNU flags translated.
2021-03-14ninjabackend: Use rsp_file_syntax methodDylan Baker1-3/+4
This also makes us of the new enum value in the backend, for better type saftey.
2021-03-14compilers/linkers: Add a methhod for getting the rspfile syntaxDylan Baker1-2/+11
2021-03-04mass rewrite of string formatting to use f-strings everywhereEli Schwartz1-13/+13
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04various python neatness cleanupsEli Schwartz1-12/+12
All changes were created by running "pyupgrade --py3-only --keep-percent-format" and committing the results. I have not touched string formatting for now. - use set literals - simplify .format() parameter naming - remove __future__ - remove default "r" mode for open() - use OSError rather than compatibility aliases - remove stray parentheses in function(generator) scopes
2021-03-02fix missing versions with generated sourceRemi Thebault1-0/+6
2021-03-01D add build dir to -J switchRemi Thebault1-2/+6
2021-01-04use OptionKey for builtin and base optionsDylan Baker1-5/+7
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-29Implement support of dlang -makedeps switch (#8119)Remi Thebault1-2/+31
* Implement support of dlang -makedeps switch Fix #8118 * resolve code review comments
2020-10-14vs: add static_from_buildtype to b_vscrtPeter Harris1-5/+11
2020-10-01compilers/d: add type annotationsDylan Baker1-128/+138
2020-10-01compilers/cuda: make type safeDylan Baker1-6/+0
2020-10-01compilres: move depfile_for_object to compilerDylan Baker1-6/+0
2020-10-01compilers: move get_dependency_gen_args to base CompilerDylan Baker1-4/+0
So that every subclass doesn't have to reimplement it. Especially since the Gnu implementation moved out of the CCompiler and into the GnuLikeCompiler mixin
2020-09-24compilers: make is_cross part of the base Compiler classDylan Baker1-12/+14
Every class needs to set this, so it should be part of the base. For classes that require is_cross, the positional argument remains in their signature. For those that don't, they just allow the base class to set their value to it's default of False.
2020-09-24compilers: put name_string method in base compilerDylan Baker1-3/+0
Every language had the exact same implementation
2020-08-30D: fix include orderPierrick Bouvier1-0/+7
Commit 93c3ec7e introduced a new way to handle deduplication with compiler args. This resulted in D includes to be reversed.
2020-06-22compilers: Return CompilerArgs from compiler instanceDylan Baker1-2/+1
Since the CompileArgs class already needs to know about the compiler, and we really need at least per-lanaguage if not per-compiler CompilerArgs classes, let's get the CompilerArgs instance from the compiler using a method.
2020-06-22compilers: Split CompilerArgs into a separate moduleDylan Baker1-1/+1
I've also moved this out of the compilers pacakge because we're soon going to need it in linkers, and that creates some serious spagetti
2020-05-20compilers/d: Add b_ndebug supportDylan Baker1-3/+12
D lang compilers have an option -release (or similar) which turns off asserts, contracts, and other runtime type checking. This patch wires that up to the b_ndebug flag. Fixes #7082
2020-05-18Merge pull request #7103 from dankegel/bug4027-rpath-rememberJussi Pakkanen1-4/+5
Let .pc files and LDFLAGS provide rpaths.
2020-05-18compilers/d: Enable pgo for GDCDylan Baker1-1/+2
2020-05-16Let .pc files specify rpath.Dan Kegel1-4/+5
Fixes #4027