aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/c.py
AgeCommit message (Collapse)AuthorFilesLines
2021-01-23split mesonlib into a packageDylan Baker1-1/+2
Currently mesonlib does some import tricks to figure out whether it needs to use windows or posix specific functions. This is a little hacky, but works fine. However, the way the typing stubs are implemented for the msvcrt and fnctl modules will cause mypy to fail on the other platform, since the functions are not implemented. To aleviate this (and for slightly cleaner design), I've split mesonlib into a pacakge with three modules. A universal module contains all of the platform agnositc code, a win32 module contains window specific code, a posix module contains the posix specific code, and a platform module contains no-op implementations. Then the package's __init__ file imports all of the universal functions and all of the functions from the approriate platform module, or the no-op versions as fallbacks. This makes mypy happy, and avoids `if`ing all over the code to switch between the platform specific code.
2021-01-13Fix misspellsAntonin Décimo1-1/+1
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-11move handling of CFLAGS and friends to environmentDylan Baker1-2/+1
This has a bunch of nice features. It obviously centralizes everything, which is nice. It also means that env is only re-read at `meson --wipe`, not `meson --reconfigure`. And it's going to allow more cleanups.
2021-01-04move OptionKey to mesonlibDylan Baker1-2/+1
There's starting to be a lot of things including coredata that coredata needs to itself include. putting it in mesonlib makes more sense
2021-01-04use OptionKey for compiler_optionsDylan Baker1-62/+79
2021-01-04Add choices to OptionProxyDylan Baker1-12/+12
they're probably not strictly needed, but it makes mypy happy.
2020-11-13msvc: enable /std:c17 flagjpark371-8/+19
Increase allowed c_std options, and check compiler version. Also update mlog pattern to not crash.
2020-11-12clang-cl: Allow clang-cl (when compiling C) to pass std to underlying clang)Dylan Baker1-34/+33
This allows a wider array of standard support than would be available directly from clang-cl, emulating MSVC stds.
2020-11-12compilers/c: Log that MSVC doesn't support gnu stdsDylan Baker1-1/+13
Since the current approach of demoting to the nearest C standard *might* work, but might not. For projects like Glib that detect which standard is used and fall back this is fine. For projects like libdrm that only work with gnu standards, this wont. We're nog tusing a warning because this shouldn't be fatal if --meson-fatal-warnings is used. Also demote a similar message in IntelCl from warning to log.
2020-11-12compilers: define standards in the base language compilerDylan Baker1-84/+28
And then update the choices in each leaf class. This way we don't end up with another case where we implicitly allow an invalid standard to be set on a compiler that doesn't have a 'std' setting currently.
2020-11-12compilers: Standardize the names of compiler optionsDylan Baker1-9/+9
Most options don't use language prefaced options (std vs c_std) internally, as we don't need that due to namespacing. Let's do that across the board
2020-11-12compilers/c: Clang-cl also needs specific handling for standardsDylan Baker1-0/+19
2020-11-12Make MSVC accept gnu11 as a language standard version. Closes: #7611.Jussi Pakkanen1-3/+7
Fixes: #7611
2020-10-01compilers: fully type annotate the C compilersDylan Baker1-120/+196
2020-09-24compilers: make is_cross part of the base Compiler classDylan Baker1-2/+2
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: make sanity_check_impl a protected methodDylan Baker1-1/+1
It's an implementation detail after all
2020-09-15Add support for the CompCert C CompilerSebastian Meyer1-0/+31
* 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-08-23Merge pull request #7600 from alexrp/masterJussi Pakkanen1-2/+13
Add C2x option support.
2020-08-22Add C2x option support.Alex Rønne Petersen1-2/+13
2020-08-22Merge pull request #7447 from scivision/nvcJussi Pakkanen1-0/+9
Add support for NVidia HPC SDK compilers
2020-08-09msvc: enable /std:c11 flagMichael Hirsch1-0/+20
2020-07-13add Nvidia HPC SDK compilersMichael Hirsch, Ph.D1-0/+9
2020-05-22compilers: add fetching of define list for clangYevhenii Kolesnikov1-2/+3
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-20Compiler options per langJohn Ericson1-43/+86
A current rather untyped storage of options is one of the things that contributes to the options code being so complex. This takes a small step in synching down by storing the compiler options in dicts per language. Future work might be replacing the langauge strings with an enum, and defaultdict with a custom struct, just like `PerMachine` and `MachineChoice`.
2020-03-23Fix legacy env var support with crossJohn Ericson1-1/+1
Fix #3969
2020-03-21-Add xc16 and c2000 C,Cpp toolchain supportalanNz1-0/+91
2020-03-08Merge pull request #6688 from dcbaker/emcc-linker-bugsJussi Pakkanen1-2/+2
Emcc linker bugs and improvments
2020-03-03Set c_winlibs/cpp_winlibs for Clang in the same way as for GCCMartin Storsjö1-0/+6
clang-cl is handled as a separate case (ClangClCCompiler), which already gets c_winlibs from VisualStudioLikeCCompilerMixin.
2020-02-27compilers/linkers: Add a representation for wasm-ldDylan Baker1-2/+2
Emscripten does have a stand alone linker, wasm-ld. This patch adds the linker, adds detection for the linker, and removes the IsLinkerMixin for emscripten. This is a little more correct, and makes the code a lot cleaner and more robust.
2020-02-27compilers/mixins/emscripten: Implement thread supportDylan Baker1-1/+1
Emscripten has pthread support (as well as C++ threads), but we don't currently implement them. This fixes that by adding the necessary code. The one thing I'm not sure about is setting the pool size. The docs suggest that you really want to do this to ensure that your code works correctly, but the number should really be configurable, not sure how to set that. Fixes #6684
2020-02-27compilers/emcc: Fix inheritance orderDylan Baker1-1/+1
Sot hat the BasicLinkerIsCompilerMixin comes before ClangCCompiler, which hides its "call the linker" methods, as emcc doesn't have a separate linker.
2020-01-30-Fixed Renesas RX Family compiler to work with latest meson, updated ↵alanNz1-0/+3
cross-file, fixed assembly file use
2020-01-28compilers: Split ClangCL and MSVC mixinsDylan Baker1-7/+5
Instead of checking the compiler id inside the VisualStudioLikeCompiler class, this creates two subclasses that each represent the divergent behavior of the two compilers
2020-01-27Bringing back defines in Elbrus C compiler to simplify environment.pymakise-homura1-2/+3
2020-01-27Fix missing 'defines' argumet for Elbrus compilermakise-homura1-3/+3
...But somehow it still remains in C++ compiler.
2020-01-08types: import typing as T (fixes #6333)Daniel Mensinger1-3/+3
2020-01-06Updated linker MR (#6407)Jussi Pakkanen1-1/+1
* environment: Fix passing always args to a number of less common linkers These are mostly (oops xilink) proprietary linkers I can't use for various reasons. Fixes: #6332 * Add intelfix from scivision. * Ifort fix from scivision. * PGI fix from scivision. * Cuda fix from scivision. * Fix linker passing for armclang.
2019-12-17Merge pull request #6065 from dcbaker/pass-options-to-linker-detectionJussi Pakkanen1-1/+2
Pass options to linker detection
2019-12-13compilers: make use of mlog.log_onceDylan Baker1-5/+1
I'm sure there are other places that could use this, but I didn't see any right off that bat.
2019-12-12compilers: move language attribute to the class levelDylan Baker1-1/+2
We know that if a compiler class inherits CCompiler it's language will be C, so doing this at the class level makes more sense.
2019-11-18Use strict function prototypesMichael Hirsch, Ph.D1-2/+2
2019-10-18Refactor duplicate Emscripten code into a mixinAndrei Alexeyev1-13/+2
2019-10-15Fix emscripten C compiler initializationAndrei Alexeyev1-3/+4
2019-10-14Implement get_linker_output_args in Emscripten compilersAndrei Alexeyev1-0/+3
2019-10-14Implement get_allow_undefined_link_args in EmscriptenCCompilerAndrei Alexeyev1-0/+4
2019-10-11compilers: Fix version requirements for ClangC and AppleClangCTing-Wei Lan1-4/+4
Commit ff4a17dbef08a1d8afd075f57dbab0f5c76951ab modified the version requirements wrongly. AppleClangC should be the one with higher version numbers. Exchange them to fix the check.
2019-10-07compilers: replace CompilerType with MachineInfoDylan Baker1-38/+68
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 Baker1-4/+18
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 Baker1-22/+2
Most of the cuda code is from Olexa Bilaniuk. Most of the PGI code is from Michael Hirsc
2019-08-14compilers: Make MSVClike compilers proxy extra keyword argumentsDylan Baker1-6/+6