summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/__init__.py
AgeCommit message (Collapse)Author
2025-07-29ninjabackend: handle specially TUs where compilation and linking happens ↵Paolo Bonzini
together Rust sources are not compiled separately: generation of the .a or .so or binary happens at the same time as compilation. There is no separate compilation phase where the .o file is created. In preparation for moving generate_rust_target where generate_link is now, make the compilation phase of generate_target skip them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-09interpreter: Error if java sources used with non-jar target (#14424)Andrew McNulty
If the user specifies java sources as input to a non-jar build target, raise an error with a message directing them to use the jar target instead. Fixes: https://github.com/mesonbuild/meson/issues/13870
2025-04-02options: move BASE_OPTIONS to the options moduleDylan Baker
This makes more sense from a "group all options together" It also allows us to remove a bunch of imports in functions, a clear code smell.
2025-03-03compilers: Remove the BaseOption typeDylan Baker
This class only served one purpose, to avoid typing the name of the option twice. Unfortunately the way it was implemented made getting the type checking right difficult, and required storing the same data twice. This patch replaces this approach with a dictionary comprehension that creates the OptionKey from the UserOption. This allows us to initialize a single dictionary once, avoid typing the name twice, delete lines of code, and get better type safety. As an added bonus, it means that the exported data from the module can be marked module constant, ie, ALL_CAPS.
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
2022-09-19compilers: don't export every compiler as a top-level propertyEli Schwartz
This is wasteful and generally unneeded, since code can just use the compiler they detected instead of manually poking at the internals of this subpackage. It also avoids importing an absolute ton of code the instant one runs `from . import compilers`
2022-02-02Genericise TI compiler and add MSP430 supportWilliam Toohey
2021-09-28Merge pull request #9014 from bonzini/mixed-language-linkJussi Pakkanen
Use appropriate compiler for the source file for "links" tests with file argument
2021-09-24compilers/rust: Add support for clippyDylan Baker
Clippy is a compiler wrapper for rust that provides an extra layer of linting. It's quite popular, but unfortunately doesn't provide the output of the compiler that it's wrapping in it's output, so we don't detect that clippy is rustc. This small patch adds a new compiler class (that is the Rustc class with a different id) and the necessary logic to detect that clippy is in fact rustc) Fixes: #8767
2021-09-14compilers: publicly export one more constantEli Schwartz
It is imported from a subpackage in __init__ alongside a big list of other things which are all exported. And elsewhere, this import is re-imported by other code. It's pretty clearly an oversight that it didn't get added to __all__
2021-09-07interpreter: detect and pass compiler to be used for linker testsPaolo Bonzini
Allow using the links method to test that the C++ driver (e.g. g++) can be used to link C objects. One usecase is that the C compiler's libsanitizer might not be compatible with the one included by the C++ driver. This is theoretically backwards-incompatible, but it should be treated as a bugfix in my opinion. There is no way in Meson to compile a .c file with the C++ driver as part of a build target, therefore there would be no reason to do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')). Fixes: #7703
2021-06-25Split compiler detection from EnvironmentDaniel Mensinger
This moves all the compiler detection logic into the new compilers.detect module. This dramatically reduces the size and complexity of Environment.
2021-06-18interpreter: Refactor interpreter.compiler to use ObjectHolderDaniel Mensinger
2021-06-09compilers: Fix missing functions in Compiler base classDaniel Mensinger
2021-06-07compilers: Expose Cython compilerDylan Baker
2021-06-05typing: Fully annotate dependencies.cudaDaniel Mensinger
2021-01-11use PEP8 style naming for LANGUAGES_USING_* as wellDylan Baker
2020-09-15Add support for the CompCert C CompilerSebastian Meyer
* Add preliminary support for the CompCert C Compiler The intention is to use this with the picolibc, so some GCC flags are automatically filtered. Since CompCert uses GCC is for linking, those GCC-linker flags which are used by picolibc, are automatically prefixed with '-WUl', so that they're passed to GCC. Squashed commit of the following: commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d Author: Sebastian Meyer <meyer@absint.com> Date: Mon Aug 31 14:20:39 2020 +0200 remove '-fall' from default arguments, also filter -ftls-model=.* commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67 Author: Sebastian Meyer <meyer@absint.com> Date: Mon Aug 31 14:13:55 2020 +0200 use regex for filtering ccomp args commit d68d242d0ad22f8bf53923ce849da9b86b696a75 Author: Sebastian Meyer <meyer@absint.com> Date: Mon Aug 31 13:54:36 2020 +0200 filter some gcc arguments commit 982a01756266bddbbd211c54e8dbfa2f43dec38f Author: Sebastian Meyer <meyer@absint.com> Date: Fri Aug 28 15:03:14 2020 +0200 fix ccomp meson configuration commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9 Author: Sebastian Meyer <meyer@absint.com> Date: Thu Aug 27 13:02:19 2020 +0200 add CompCert to meson (does not fully work, yet) * remove unused import and s/cls/self/ fixes the two obvious LGTM warnings * CompCert: Do not ignore unsupported GCC flags Some are safe to ignore, however, as per https://github.com/mesonbuild/meson/pull/7674, they should not be ignored by meson itself. Instead the meson.build should take care to select only those which are actually supported by the compiler. * remove unused variable * Only add arguments once. * Apply suggestions from code review Co-authored-by: Dylan Baker <dylan@pnwbakers.com> * Remove erroneous ' ' from '-o {}'.format() As noticed by @dcbaker * added release note snippet for compcert * properly split parameters As suggested by @dcbaker, these parameters should be properly split into multiple strings. Co-authored-by: Dylan Baker <dylan@pnwbakers.com> * Update add_compcert_compiler.md Added a sentence about the state of the implementation (experimental); use proper markdown * properly separate arguments Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-06backends: check external rpaths for all languages using ldflagsJames Hilliard
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2020-08-22Merge pull request #7609 from dcbaker/submit/2020-08/cmake-fix-apple-clangJussi Pakkanen
Fix mapping of apple compilers in cmake
2020-08-22compilers: Add Apple subclasses for ObjC and ObjC++Dylan Baker
These are needed because in some cases we need to be able to know if we're using vanilla clang or Apple's clang.
2020-07-13add Nvidia HPC SDK compilersMichael Hirsch, Ph.D
2020-06-22compilers: Split CompilerArgs into a separate moduleDylan Baker
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-03-23Fix linker evn var testsJohn Ericson
Just because we are on windows doesn't mean we can use `link`. This ought to be done better, but this will do for now.
2020-03-21-Add xc16 and c2000 C,Cpp toolchain supportalanNz
2020-02-12Improve error reported when language has no compilerJon Turney
This gives consistent reporting of this error for all platforms. Also, reporting this error when constructing the BuildTarget, rather than discovering the problem during backend generation means that the error is reported against with a location.
2019-10-20Fix all flake8 warningsDaniel Mensinger
2019-10-07compilers: replace CompilerType with MachineInfoDylan Baker
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-10-07compilers: Add a specific type for AppleClangCDylan Baker
This allows us to detect use classes rather than methods to determine what C standards are available.
2019-08-14compilers: Dispatch to dynamic linker classDylan Baker
Most of the cuda code is from Olexa Bilaniuk. Most of the PGI code is from Michael Hirsc
2019-08-05Add basic Webassembly support via Emscripten.Jussi Pakkanen
2019-07-23compilers: pull sanitzier args into compiler classesDylan Baker
This simplifies and cleans things up.
2019-07-15compilers: Put clang mixin in a moduleDylan Baker
2019-07-15compilers: Put Intel compiler classes into the mixins folderDylan Baker
2019-07-15compilers: split gnu and gnulike compilers out of compilersDylan Baker
I debated a bit whether both classes really belong in the same module, and decided that they do because the share a number of helpers.
2019-07-15compilers: Move the VisualStudioLikeCompiler class into mixinsDylan Baker
2019-07-15compilers: move ccrx compiler abstraction into mixinsDylan Baker
2019-05-13compilers: Add basic ICL abstractionsDylan Baker
2019-05-13compilers: rename IntelCompiler to IntelGnuLikeCompilerDylan Baker
The Intel compiler is strange. On Linux and macOS it's called ICC, and it tries to mostly behave like gcc/clang. On Windows it's called ICL, and tries to behave like MSVC. This makes the code that's used to implement ICC support useless for supporting ICL, because their command line interfaces are completely different.
2019-05-03compilers: Split C-Like functionality into a mixin classesDylan Baker
Currently C++ inherits C, which can lead to diamond problems. By pulling the code out into a standalone mixin class that the C, C++, ObjC, and Objc++ compilers can inherit and override as necessary we remove one source of diamonding. I've chosen to split this out into it's own file as the CLikeCompiler class is over 1000 lines by itself. This also breaks the VisualStudio derived classes inheriting from each other, to avoid the same C -> CPP inheritance problems. This is all one giant patch because there just isn't a clean way to separate this. I've done the same for Fortran since it effectively inherits the CCompiler (I say effectively because was it actually did was gross beyond explanation), it's probably not correct, but it seems to work for now. There really is a lot of layering violation going on in the Compilers, and a really good scrubbing would do this code a lot of good.
2019-05-02Revert "detect Intel ICL on windows"Dylan Baker
This reverts commit 3a75bb5259abbcae820b47f5f4633c564411893b.
2019-04-27detect Intel ICL on windowsMichael Hirsch, Ph.D
ICL CPP working
2019-01-29correct naming to CudaCompiler, pep8Michael Hirsch, Ph.D
2019-01-21added cuda compilerBeau Johnston
2019-01-21Add PGI C and C++ compilers (#4803)Michael Hirsch, Ph.D
2019-01-16Flang Fortran compiler added.Michael Hirsch, Ph.D
2019-01-06Absolute path generation refactoringDaniel Mensinger
2018-11-08Add support for Renesas CC-RX toolchainPhillip Cao
2018-11-04Detect clang-cl as msvc-like, not clang-likeJon Turney
Handle clang's cl or clang-cl being in PATH, or set in CC/CXX Future work: checking the name of the executable here seems like a bad idea. These compilers will fail to be detected if they are renamed. v2: Update compiler.get_argument_type() test Fix comparisons of id inside CCompiler, backends and elsewhere v3: ClangClCPPCompiler should be a subclass of ClangClCCompier, as well Future work: mocking in test_find_library_patterns() is effected, as we now test for a subclass, rather than self.id in CCompiler.get_library_naming()
2018-09-16Use enum instead of `int` for compiler variantsDavid Seifert
* Enums are strongly typed and make the whole `gcc_type`/`clang_type`/`icc_type` distinction redundant. * Enums also allow extending via member functions, which makes the code more generalisable.