aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
AgeCommit message (Collapse)AuthorFilesLines
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-25make 'gui_app' an interpreter only conceptDylan Baker1-4/+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-12Fix return type of debugfile functionsTristan Partin1-1/+1
It was returning None in some cases while being marked as returning string.
2023-07-12Remove Compiler._build_wrapper(temp_dir:)Tristan Partin1-2/+1
The function wasn't using the keyword argument and all the callers were using env.scratch_dir anyway.
2023-07-12Fix the typing around Compiler._get_compile_output()Tristan Partin1-4/+6
This function says it returns a string, but was returning None in some cases.
2023-07-12Annotate naked fundamental Python typesTristan Partin1-1/+1
Although mypy wasn't complaining, pyright was.
2023-07-12Replace some type comments with annotationsTristan Partin1-63/+72
2023-07-12Use CompileCheckMode enumTristan Partin1-15/+12
There were a ton of naked strings with TODOs telling us to use the enum.
2023-07-12Remove type comments from compilers.pyTristan Partin1-53/+59
2023-06-28Experimental 'genvslite' WIP. (#11049)GertyP1-1/+4
* Capture all compile args from the first round of ninja backend generation for all languages used in building the targets so that these args, defines, and include paths can be applied to the .vcxproj's intellisense fields for all buildtypes/configurations. Solution generation is now set up for mutiple build configurations (buildtypes) when using '--genvslite'. All generated vcxprojs invoke the same high-level meson compile to build all targets; there's no selective target building (could add this later). Related to this, we skip pointlessly generating vcxprojs for targets that aren't buildable (BuildTarget-derived), which aren't of interest to the user anyway. When using --genvslite, no longer inject '<ProjectReference ...>' dependencies on which a generated .vcxproj depends because that imposes a forced visual studio build dependency, which we don't want, since we're essentially bypassing VS's build in favour of running 'meson compile ...'. When populating the vcxproj's shared intellisense defines, include paths, and compiler options fields, we choose the most frequent src file language, since this means more project src files can simply reference the project shared fields and fewer files of non-primary language types need to populate their full set of intellisense fields. This makes for smaller .vcxproj files. Paths for generated source/header/etc files, left alone, would be added to solution projects relative to the '..._vs' build directory, where they're never generated; they're generated under the respective '..._[debug/opt/release]' ninja build directories that correspond to the solution build configuration. Although VS doesn't allow conditional src/header listings in vcxprojs (at least not in a simple way that I'm aware of), we can ensure these generated sources get adjusted to at least reference locations under one of the concrete build directories (I've chosen '..._debug') under which they will be generated. Testing with --genvslite has revealed that, in some cases, the presence of 'c:\windows\system32;c:\windows' on the 'Path' environment variable (via the make-style project's ExecutablePath element) is critical to getting the 'meson compile ...' build to succeed. Not sure whether this is some 'find and guess' implicit defaults behaviour within meson or within the MSVC compiler that some projects may rely on. Feels weird but not sure of a better solution than forcibly adding these to the Path environment variable (the Executable Path property of the project). Added a new windows-only test to windowstests.py ('test_genvslite') to exercise the --genvslite option along with checking that the 'msbuild' command invokes the 'meson compile ...' of the build-type-appropriate-suffixed temporary build dir and checks expected program output. Check and report error if user specifies a non-ninja backend with a 'genvslite' setup, since that conflicts with the stated behaviour of genvslite. Also added this test case to 'WindowsTests.test_genvslite' I had problems tracking down some problematic environment variable behaviour, which appears to need a work-around. See further notes on VSINSTALLDIR, in windowstests.py, test_genvslite. 'meson setup --help' clearly states that positional arguments are ... [builddir] [sourcedir]. However, BasePlatformTests.init(...) was passing these in the order [sourcedir] [builddir]. This was producing failures, saying, "ERROR: Neither directory contains a build file meson.build." but when using the correct ordering, setup now succeeds. Changed regen, run_tests, and run_install utility projects to be simpler makefile projects instead, with commands to invoke the appropriate '...meson.py --internal regencheck ...' (or install/test) on the '[builddir]_[buildtype]' as appropriate for the curent VS configuration. Also, since the 'regen.vcxproj' utility didn't work correctly with '--genvslite' setup build dirs, and getting it to fully work would require more non-trivial intrusion into new parts of meson (i.e. '--internal regencheck', '--internal regenerate', and perhaps also 'setup --reconfigure'), for now, the REGEN project is replaced with a simpler, lighter-weight RECONFIGURE utility proj, which is unlinked from any solution build dependencies and which simply runs 'meson setup --reconfigure [builddir]_[buildtype] [srcdir]' on each of the ninja-backend build dirs for each buildtype. Yes, although this will enable the building/compiling to be correctly configured, it can leave the solution/vcxprojs stale and out-of-date, it's simple for the user to 'meson setup --genvslite ...' to fully regenerate an updated, correct solution again. However, I've noted this down as a 'fixme' to consider implementing the full regen behaviour for the genvslite case. * Review feedback changes - - Avoid use of 'captured_compile_args_per_buildtype_and_target' as an 'out' param. - Factored a little msetup.py, 'run(...)' macro/looping setup steps, for genvslite, out into a 'run_genvslite_setup' func. * Review feedback: Fixed missing spaces between multi-line strings. * 'backend_name' assignment gets immediately overwritten in 'genvslite' case so moved it into else/non-genvslite block. * Had to bump up 'test cases/unit/113 genvslites/...' up to 114; it collided with a newly added test dir again. * Changed validation of 'capture' and 'captured_compile_args_...' to use MesonBugException instead of MesonException. * Changed some function param and closing brace indentation.
2023-06-27Archive shared library in AIX (#11850)Aditya Kamath1-0/+6
* Archive shared library in AIX This code change to ensure we archive shared libraries in AIX. The things we do are: Archive shared library Install archived shared library Build all must build the archived shared library blibpath must have the archived shared library dependency. * Archive shared library in AIX. Made changes as per the review comments given in the first PR request. They are:- Use self.environment.machines[t.for_machine].is_aix() Remove trial spaces Use of val instead of internal Changed comments wherever requested * Space after octothorpe * Fixed failed test case causing build break during install section * Moved AIX specific code to AIXDynamicLinker from backend * Fix indentation, trailing spaces, add type annotations and Linux/macOS build break * Remove some more trailing space issues * Fixed the wrong return type in linkers
2023-06-26linkers: delay implementations import until detect is runEli Schwartz1-1/+2
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-06-14WIP: refactor loggable popen calls for consistencyEli Schwartz1-5/+2
2023-04-21compilers: split code for deciding if debug is needed into a helperDylan Baker1-4/+12
2023-04-21compilers: convert method to get assert control to a booleanDylan Baker1-5/+10
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-20intro: add more details to generated json filesCharles Brunet1-1/+1
This will help with the writing of tools to generate VisualStudio project and solution files, and possibly for other IDEs as well. - Used compilers a about `host`, `build` and `target` machines arere listed in `intro-compilers.json` - Informations lister in `intro-machines.json` - `intro-dependencies.json` now includes internal dependencies, and relations between dependencies. - `intro-targets.json` now includes dependencies, `vs_module_defs`, `win_subsystem`, and linker parameters.
2023-04-11fix various spelling issuesJosh Soref1-3/+3
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-03-23asm: Add sx extensionRenan Lavarec1-1/+1
docs: gcc https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html scons: https://scons.org/doc/3.0.5/HTML/scons-user/apb.html .S Windows: assembly language file ARM: CodeSourcery Sourcery Lite .sx assembly language file + C pre-processor POSIX: assembly language file + C pre-processor
2023-03-16prevent lib prefix warning from pkg-configCharles Brunet1-1/+1
2023-02-27Use caching in Compiler.sizeof() and Compiler.alignment()Andres Freund1-2/+2
2023-02-27Add Compiler.cached_run()Andres Freund1-1/+29
Caching Compiler.run() seems likely to cause problems, but some users, like .sizeof(), we know enough about the program run to make it safe. This commit just adds the Compiler.cached_run(), a subsequent commit makes use of it.
2023-02-25Misleading comment mtribiere1-1/+1
Code moved to detect.py in recent version
2023-02-20nasm: Link with windows CRT libs when nasm is used as linker languageXavier Claessens1-1/+1
2023-02-01remove unneeded type commentEli Schwartz1-1/+1
2022-10-25compilers: Make sure to not use ccache in compiler checksXavier Claessens1-3/+4
ccache was used in all command lines but disabled using CCACHE_DISABLE in Compiler.compile() method. Wrapping invokations still has a cost, especially on Windows. With sccache things are even worse because CCACHE_DISABLE was not respected at all, making configure *extremely* slow on Windows when sccache is installed.
2022-10-25Compilers: Keep ccache and exelist separatedXavier Claessens1-2/+2
Only combine them in the Compiler base class, this will make easier to run compiler without ccache.
2022-10-24Add MASM compilerXavier Claessens1-1/+2
ml and armasm are Microsoft's Macro Assembler, part of MSVC.
2022-10-24Not all compilers support depfileXavier Claessens1-1/+1
2022-10-24Add NASM compilerXavier Claessens1-1/+2
2022-10-23Compilers: Add a preprocessor mode for clike compilersXavier Claessens1-0/+12
A compiler object can now return a list of "modes", they are new compiler object specialized for a specific task.
2022-10-13Add b_thinlto_cache for automatically configuring incremental ThinLTOTatsuyuki Ishi1-4/+12
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-09-27compilers: Cleanup a bit languages/suffixes listsXavier Claessens1-18/+22
Use set where order does not matter, fix is_source() to really mean only source suffixes.
2022-09-09compilers: drop some useless info from CompileResultEli Schwartz1-5/+2
text_mode was never set, nor used, and pid was set but never used.
2022-09-09compilers: fix regression in logging cached compile commandsEli Schwartz1-4/+3
In commit d326c87fe22507b8c25078a7cd7ed88499ba7dc1 we added a special holder object for cached compilation results, with some broken attributes: - "command", that was never set, but used to print the log - "args", that was set to some, but not all, of the information a fresh compilation would log, but never used Remove the useless args attribute, call it command, and use it properly.
2022-09-01env2mfile: reuse logical lists of interesting facts from meson itselfEli Schwartz1-0/+1
Meson internally knows about many languages and tools, and *FLAGS variables, and which languages to use them for. Instead of duplicating this logic, import it from mesonbuild.* This logic was originally standalone, but now that it is merged into the Meson tree we can have a single source of truth.
2022-08-24fix linker regression for compilers that don't accept LDFLAGS directlyEli Schwartz1-1/+5
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-06-06compilers: Add support for stand-alone leak sanitizerMarco Trevisan (TreviƱo)1-1/+1
Leak sanitizer can be enabled without the whole AddressSanitizer, this can be done by passing -fsanitize=leak as documented at [1]. Meson doesn't support this, so add support for it. [1] https://clang.llvm.org/docs/LeakSanitizer.html
2022-06-01compiler: Add missing needs_static_linker to base Compiler classDylan Baker1-0/+3
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-22OptionOverrideProxy: Make it immutable to avoid copiesXavier Claessens1-2/+2
It is always used as an immutable view so there is no point in doing copies. However, mypy insist it must implement the same APIs as Dict[OptionKey, UserOption[Any]] so keep faking it.
2022-02-16flake8: fix various whitespace errors with badly aligned codeEli Schwartz1-1/+1
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-01migrate python 3.5 compatible superclass variable annotations to 3.6Eli Schwartz1-5/+3
As we now require python 3.6, we can declare their types without initializing them.
2021-10-29Remove duplicated CEXE_MAPPING tableXavier Claessens1-5/+0
2021-10-10Fix typos discovered by codespellChristian Clauss1-1/+1
2021-09-28Merge pull request #9014 from bonzini/mixed-language-linkJussi Pakkanen1-8/+20
Use appropriate compiler for the source file for "links" tests with file argument
2021-09-25compilers: Add default search path stdlib_only_link_flagsDylan Baker1-1/+1
This should be done in all cases of language_stdlib_only_link_flags, but I don't have access to all of the compilers to test it. This is required in cases where object files created by gfortran are linked using another compiler with a differen default search path, such as gfortran and clang together.
2021-09-14apply flake8 fixes for unused imports and missing importsEli Schwartz1-2/+2