Commit Graph

795 Commits

Author SHA1 Message Date
Jussi Pakkanen 43f0aa17b7 Add swift executable support in Xcode. 2021-05-23 17:59:14 +01:00
Dylan Baker bfd06783bd backends: use a set for processed targets instead of a dict
We're only interested in the keys, not in the value (which was always
set to True), so a set is a better data structure anyway.
2021-05-19 23:28:17 +03:00
Dylan Baker 7659ae50a0 ninjabackend: Fix vala type annotations 2021-05-19 23:28:17 +03:00
Dylan Baker b1b8e777a2 rust: override get_linker_always_args
instead of opencoding what should be there in the rust compile rule
2021-05-19 23:28:17 +03:00
Dylan Baker e7e04c814b Add a rust test for internal c linkage
We have code to support this, but no tests. That seems pretty bad.
And better yet, it doesn't work on MSVC in some cases.
2021-05-18 09:34:36 -07:00
Dylan Baker 11d123332d ninjabackend: fix linking dynamic c libraries with rust
The correct name is "dylib" not "shared"
2021-05-17 15:21:27 -07:00
Marco Trevisan (Treviño) 739e499554 ninjabackend: Add pch includes as early as possible not to be overridden
When pch are used for a target meson will make the compiler to include
the pre-compiled header. While this is useful, this needs to happen
before any other header has been included, otherwise:

 1) we won't take advantage of pch for anything else previously included
 2) gcc will just fail as it won't even try to look for a pre-compiled
    header in this case [1]

This case can happen quite a easily when a dependency provides an
included header in its cflags.

As per this, split _generate_single_compile() in two phases, one is
responsible of initializing the compiler data, while the other is
defining commands for the context.

In this way, when pch can be used, we can insert the pch inclusion
earlier than any other provided by the target.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100462
2021-05-08 21:27:35 +03:00
Jussi Pakkanen 1a31882f59 Xcode: make Swift projects work. 2021-04-25 15:35:13 +03:00
Jussi Pakkanen 48e38fbaeb Xcode: fix custom targets that produce objs and libs. 2021-04-16 18:14:01 +03:00
Jussi Pakkanen e80ff985fb Do not add custom target dir automatically when implicit false. 2021-03-29 18:57:34 +03:00
Xavier Claessens 0638e38bfc clangformat: Add clang-format-check target 2021-03-16 21:01:54 -04:00
Dylan Baker 2be074b1d4 ninjabackend: Use rsp_file_syntax method
This also makes us of the new enum value in the backend, for better type
saftey.
2021-03-14 22:05:55 -07:00
Remi Thebault 89202aaaef change RSP quote style decision logic
Take into account LDC on Windows
Fixes #8494
2021-03-09 21:17:41 +02:00
Jussi Pakkanen 85796229c2 Fix Fortran dep scanner for upper case file extensions. Closes #8395. 2021-03-06 01:53:52 +02:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Dylan Baker d7d80945ea rust: a meson -l argument could be etiher a static or dynamic library
I made an incorrect assumption that -l arguments would always be static
libraries, but they might well be shared libraries.
2021-02-26 14:26:15 -08:00
Dylan Baker 0edd005804 rust: replace for loop with any()
This is a little cleaner, and short circuits correctly, unlike the loop
it replaces
2021-02-23 16:22:56 -08:00
Dylan Baker 6544f151db rust: fix linking with external dependencies
Rust can link with any dependency that uses c linkage, which is pretty
much what we assume across the board anyway.
2021-02-23 16:22:56 -08:00
Jussi Pakkanen 72865a2773 Fix combining C and Fortran. Closes #8377. 2021-02-19 18:18:39 +02:00
Jussi Pakkanen f3727c62c6 Fix VS C++ module support. 2021-02-16 17:05:12 +00:00
Xavier Claessens a155935d24 backends: Always use the command returned by as_meson_exe_cmdline()
Even if the command is not wrapped by meson, it could have been modified
to add java/mono interpreters. This fix potential inconsistency between
wrapped and unwrapped commands.
2021-02-09 19:32:20 +02:00
Jussi Pakkanen 71784e1002 Fix exe wrapper detection for run targets. 2021-02-08 23:19:41 +02:00
Jussi Pakkanen a855bcab1c
Merge pull request #8162 from dcbaker/wip/2021-01/rust-module-bindgen
Add a wrapper to the rust module for bindgen
2021-02-07 16:57:39 +00:00
Jussi Pakkanen 8b82ffa9e4
Merge pull request #8305 from xclaesse/run-target-env
run_target: Add env kwarg
2021-02-07 11:46:41 +00:00
Dylan Baker 4082a3db45 backends/ninja: Implement linking a C ABI target into a rust target 2021-02-06 10:27:04 -08:00
Dylan Baker 456844a4f3 vala: Disable unity builds
Our approach to unity builds with vala is broken, you cannot unify the
generated C files, as they contain duplicate symbols. We would need to
instead combine the files while they are still in their vala form, then
convert that to C and compile the unified C file.

This does not fix the linked issue, as this removed the ability to do
vala unity builds, but it does allow running vala with `--unity=on`.

Related: #5280
2021-02-05 16:31:33 -08:00
Dylan Baker d2c7063c1a ninjabackend: add a few annotations 2021-02-05 16:31:33 -08:00
Xavier Claessens f63e168685 ninjabackend: Remove useless call to replace_paths()
Replacements are already done by eval_custom_target_command() and must
be done BEFORE calling as_meson_exe_cmdline() anyway. replace_paths() is
still used by generators.

Make eval_custom_target_command() more readable by handling error in the
final else case instead of in the middle of elif.
2021-02-05 18:17:08 -05:00
Xavier Claessens b52794b24b backend: Do not check for exe wrapper twice
It is already checked by as_meson_exe_cmdline().
2021-02-05 18:17:08 -05:00
Xavier Claessens 522392e755 run_target: Add env kwarg
Re-implement it in backend using the same code path as for
custom_target(). This for example handle setting PATH on Windows when
command is an executable.
2021-02-05 17:53:09 -05:00
Jeff Moguillansky 9226a92fe0 xcode-backend: add implicit includes
Move helper functions get_source_dir_include_args and
get_build_dir_include_args to backend base class
2021-02-04 13:05:17 -08:00
Xavier Claessens 633264984b custom_target: Add env kwarg 2021-01-27 09:00:54 -05:00
Jussi Pakkanen bb6385111a
Merge pull request #8236 from dcbaker/submit/rust-fix-generated-sources-in-subdir
Submit/rust fix generated sources in subdir
2021-01-25 18:24:28 +00:00
Jussi Pakkanen 99b9433bea
Merge pull request #8226 from jonaslb/fortranstatic
Fixes for fortran: Include dirs for link_whole_targets and capital file suffix
2021-01-23 17:33:38 +00:00
Dylan Baker 23d3b98fc1 split mesonlib into a package
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-23 12:48:29 +01:00
Dylan Baker 4550cf9500 ninjabackend: Correctly reference custom_target outputs in subdirs with rust
This was missed in the last iteration of fixing things.
2021-01-21 10:59:15 -08:00
Jonas Lundholm Bertelsen 2636eebd64 Unity build reverts to normal for fortran fix
The `determine_ext_objs` function did not take into account that fortran
(and d) does not support unity builds. This caused failures in some
cases.
2021-01-21 14:46:20 +01:00
Fini Jastrow 49cde9653c ninjabackend: Correct RPATH order
[why]
If we build and test a library we need to make sure that we find the
currently build library object first, before an older system installed
one.
This can be broken if the library in question is installed in a custom
path, and another library we depend on also is installed there.

[how]
Just move the rpath to the current build artifacts to the front.

Solves #8030.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-01-20 19:00:25 +00:00
Jonas Lundholm Bertelsen ea34a92632 When iterating link_targets, include link_whole_targets too (fortran)
This fixes fortran includes and fortran orderdeps for libraries that
were under link_whole_targets.
2021-01-20 18:18:54 +01:00
Jonas Lundholm Bertelsen bd2394e872 Use case-insensitive suffix check for fortran
In Fortran it is common to use capital F in the suffix (eg. '.F90') if
the source file makes use of preprocessor statements. Such files should
probably be treated like all other fortran files by meson.

Case insensitivity for suffixes was already implemented several places
in meson before this. So most likely, the few places changed here were
oversights anyway.
2021-01-20 18:11:02 +01:00
Dylan Baker caa6d5e16b backend/ninja: Add order dependencies for generated sources in rust 2021-01-19 10:14:12 -08:00
Dylan Baker bff0b41525 rust: Accept generated sources for main.rs
There are still caveats here. Rust/cargo handles generated sources by
writing out all targets of a single repo into a single output directory,
setting a path to that via a build-time environment variable, and then
include those files via a set of functions and macros. Meson's build
layout is naturally different, and ninja makes working with environment
variables at compile time difficult.

Fixes #8157
2021-01-19 10:14:10 -08:00
Dylan Baker 3ae115b57a Replace NinjaBackend is_rust_target with build.uses_rust
we have two functions to do the exact same thing, and they're basically
implemented the same way. Instead, let's just use the BuildTarget one,
as it's more generally available.
2021-01-19 10:12:38 -08:00
Dylan Baker e81acbd606 Use a single coredata dictionary for options
This patches takes the options work to it's logical conclusion: A single
flat dictionary of OptionKey: UserOptions. This allows us to simplify a
large number of cases, as we don't need to check if an option is in this
dict or that one (or any of 5 or 6, actually).
2021-01-04 12:20:58 -08:00
Dylan Baker 71db6b04a3 use OptionKey for builtin and base options
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.
2021-01-04 12:20:40 -08:00
Dylan Baker f9b19e73a5 move OptionKey to mesonlib
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-04 12:20:40 -08:00
Dylan Baker fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Dylan Baker 7142c92285 use OptionKey for backend_options 2021-01-04 12:15:41 -08:00
Dylan Baker e2ef6930ff use OptionKey for coredata.user_options 2021-01-04 12:15:41 -08:00
Jussi Pakkanen 80390dd987 Only do module scanning if C++ version is latest. 2020-12-29 21:42:47 +00:00
Samuel Longchamps 12cfd10e6a Fix network path output in ninja backend on Windows 2020-12-28 22:14:48 +00:00
Jussi Pakkanen 2f836e3acc Extend the C++ module scanner to handle Fortran, too. 2020-12-25 23:28:42 +00:00
Laurin-Luis Lehning 4164efceca Propagate Windows target checks up 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 919278e3e1 Give get_gui_app_args access to the Environment 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 9de09e9aa6 Give get_win_subsystem_args access to env 2020-12-14 11:23:53 -08:00
Jussi Pakkanen f22d54690b Add mypy annotations. 2020-12-13 16:09:50 +02:00
Jussi Pakkanen 26ffd4f8f2 Scan all C++ sources and ignore everything else. 2020-12-13 16:09:50 +02:00
Jussi Pakkanen f390d22787 C++ module compilation works for a simple project. 2020-12-13 14:03:22 +02:00
Jussi Pakkanen 92e94b1e92 Generate dependency scanning hooks in the Ninja file. 2020-12-12 19:14:44 +02:00
Jussi Pakkanen b8cb53791e Generate scanning rules for C++ modules. 2020-12-11 19:21:02 +00:00
Jussi Pakkanen c21b04ba08 Add prelinking support for static libraries. 2020-12-03 22:58:07 +02:00
Jussi Pakkanen cef13b04c2 Bump Ninja requirement to 1.8. 2020-11-26 20:28:55 +02:00
Dylan Baker f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08:00
Paolo Bonzini 0b2865e8b9 ninjabackend: stabilize order of dependencies and order-only dependencies
These do not go into the command line, and therefore do not matter
for the purpose of avoiding unnecessary rebuilds after meson is
rerun.  However, they complicate the task of finding differences
between build lines across meson reruns.

So take the easy way out and sort everything after | and ||.
With this change, there is absolutely no change in QEMU's 40000-line
build.ninja file after meson is rerun.
2020-11-15 14:21:31 +01:00
Dylan Baker 505f824cf1 ninjabackend: Fix a couple of rust bugs
There are two bugs here, first is that we open coded the output args,
instead of using the compiler method. The second is that rust args are
not passed down to the backend invocation.
2020-11-13 08:55:30 -08:00
Alexander Neumann 7d4d25353c ninjabackend: fix matching of empty strings
closes #7977
2020-11-13 17:46:32 +02:00
Dylan Baker a28b430b68 ninjabackend: apply base compile_args to rust targets 2020-11-10 12:09:04 -08:00
Dylan Baker 7860a6aeab rust: implement support for --edition
Using the std option, so now `rust_std=..` will work. I've chosen to use
"std" even though rust calls these "editions", as meson refers to
language versions as "standards", which makes meson feel more uniform,
and be less surprising.

Fixes: #5100
2020-11-05 21:24:20 +02:00
Jussi Pakkanen 1a0603835e Add win_subsystem kwarg. Closes #7765. 2020-10-07 18:55:25 +03:00
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Dylan Baker e437bdd0a9 compilers/swift: Add type annotations 2020-10-01 15:05:01 -07:00
Jussi Pakkanen 400ec2d685
Merge pull request #7762 from jon-turney/meson-exe-output-improve
Improve the output for meson wrapped commands
2020-09-29 19:28:51 +03:00
Dylan Baker bb3fe3c451 compilers/mixins/clike: fix mypy issues 2020-09-24 12:14:13 -07:00
Jon Turney c72625c2a7
Improve description of meson wrapped custom commands
I've always found ninja reporting 'a meson_exe.py custom command'
unclear and confusing. Instead say we are invoking a custom command,
wrapped by meson, and why.
2020-09-20 12:57:44 +01:00
Dylan Baker cb0265a6b2 pylint: Catch cases of `if len(container)` which should be replaced by `if container`
Unfortunately this doesn't catch other abuses of len(continauer) like,
`len(container) <comparator> 0`, see: https://github.com/PyCQA/pylint/issues/3751
2020-09-18 14:49:58 -07:00
Martin Storsjö 9d8906363e Support identifying msvc dependency prefix with a path starting with a backslash 2020-09-18 05:30:49 +00:00
Nirbheek Chauhan faba48d853 backends: Treat build target as generator only when it's the first arg
Otherwise it might be an argument to a script that just inspects the
binary itself.
2020-09-17 22:25:37 +00:00
Nirbheek Chauhan 9fb839687b minstall: Add version field to install data
And check the install data in the same way that mtest checks
serialisation data.

Fixes https://github.com/mesonbuild/meson/issues/2354
2020-09-10 12:38:05 +00:00
Jon Turney 7996ca3d55 ninja: Generate all STATIC_LINKER rules
Don't stop generating STATIC_LINKER rules at the first MachineChoice
which isn't available (i.e. generate a STATIC_LINKER rule, even if
STATIC_LINKER_FOR_BUILD isn't needed)

Also warn about internal errors which lead to non-existent rule
references, rather than exploding with a KeyError.
2020-09-10 07:20:41 +00:00
Daniel Mensinger 23818fc5a3
typing: more fixes 2020-09-08 20:15:58 +02:00
Jussi Pakkanen 97177bc12a
Merge pull request #7689 from scivision/fortran_inc
correct Fortran include algorithm
2020-09-06 20:28:39 +03:00
Paolo Bonzini 492afe50a4 environment: use ExternalProgram to find ninja
This allows the NINJA environment variable to support all the Windows special
cases, especially allowing an absolute path without extension.

Based on a patch by Yonggang Luo.

Fixes: #7659
Suggested-by: Nirbheek Chauhan <nirbheek@centricular.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-09-04 15:38:12 +02:00
Michael Hirsch 34f7fee741
fortran: make include scanning also work for CMake subprojects
also fixed PEP8

I originally implemented the "include" scanning,
but hadn't made a test for this case
2020-09-02 22:59:04 -04:00
Paolo Bonzini 71d33a5721 backends: do not look for extra paths unnecessarily
extra_paths only matter for the host machine if using an exe_wrapper.
However, because CustomTarget.for_machine is always MachineChoice.HOST,
they were computed unnecessarily in as_meson_exe_cmdline.

Defer computation of extra_paths until after we have found out if the
custom target executable is really for the host or the build machine,
so that we can use exe_for_machine; for_machine then becomes unused
and can be removed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-08-31 23:01:05 +03:00
Jussi Pakkanen e9a71ebf60
Merge pull request #7607 from bonzini/speedup
Various speedups from profiling QEMU's meson.build
2020-08-22 18:40:03 +03:00
Xavier Claessens 1c403e20e7 Interpreter: Fix c_stdlib usage
- Exceptions raised during subproject setup were ignored.
- Allow c_stdlib in native file, was already half supported.
- Eliminate usage of subproject variable name by overriding
  '<lang>_stdlib' dependency name.
2020-08-18 14:47:38 -04:00
Paolo Bonzini cbde13850f ninjabackend: avoid lambdas
The lambda in NinjaBuildElement.write is quite expensive, totalling 0.3s
just to do a couple function calls.  Since it is used just once, simply
inline it.

On a QEMU build, the total time spent in write from this series goes from
5.321s to 3.238s, though part of it can be attributed to previous patches.
2020-08-18 08:11:25 +02:00
Paolo Bonzini b14601da7b ninjabackend: optimize length_estimate
Optimize the regular expression so that the variable expansion part
always ends up in group 1, and the trailer after the variable is discarded
in the same match.  Do not use re.sub to remove braces, and do not bother
building the expanded command, just adjust the estimated length on the fly.

functools.reduce is extremely slow, so I am keeping ' '.join(chunk).

On a QEMU build the time spend in the function goes from 1.072s to 0.757s.
2020-08-18 08:11:25 +02:00
Paolo Bonzini 3d4fb02e29 ninjabackend: optimize ninja_quote
Use regular expressions to quickly weed out strings that require quoting
On a QEMU build the time spent in ninja_quote goes from 1.978s to 1.281s,
with str.replace being kicked completely out of the profile.
2020-08-18 08:11:19 +02:00
Nirbheek Chauhan 9fdb97733b ninjabackend: Fix coverage rule generation
Without the parenthesis, the command evaluates to `[]` if
`use_llvm_cov` is `False`.

Also fix tests to actually check whether or not coverage reports are
generated.

Fixes https://github.com/mesonbuild/meson/issues/7553
2020-08-15 08:41:52 +00:00
Marcel Hollerbach 903d5dd8a7 ninjabackend: check if target has compiler attribute
otherwise we are getting errors like:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/mesonmain.py", line 131, in run
    return options.run_func(options)
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/msetup.py", line 245, in run
    app.generate()
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/msetup.py", line 159, in generate
    self._generate(env)
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/msetup.py", line 215, in _generate
    intr.backend.generate()
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/backend/ninjabackend.py", line 518, in generate
    self.generate_coverage_rules()
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/backend/ninjabackend.py", line 991, in generate_coverage_rules
    self.generate_coverage_command(e, [])
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/backend/ninjabackend.py", line 975, in generate_coverage_command
    for compiler in target.compilers.values():
AttributeError: 'RunTarget' object has no attribute 'compilers'

This extends the 109 generatecode test case to also define a test, so
coverage can really detect something.
2020-07-28 17:59:03 +03:00
Nirbheek Chauhan 07e62fb42b Don't spam about usage of rspfiles to stdout
Put it in the log file if necessary. Users don't need to know this.
It's very spammy.
2020-07-22 10:11:09 -04:00
Martin Storsjö 43129a11ed Fix a comment about cross compilation with clang-cl [skip ci]
This comment was added in 0fbd09609f, where the case of a forward
slash was added for the case when cross compiling.
2020-07-19 14:58:23 +03:00
Nirbheek Chauhan 848fcb6a53 Enable target override_options for llvm-ir
This was missed somehow when the feature was added a few years ago.
2020-07-13 15:28:51 +00:00
Dylan Baker 93c3ec7e2d compilers: Return CompilerArgs from compiler instance
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-22 12:06:10 -07:00
Dylan Baker 9d0ad66c29 compilers: Split CompilerArgs into a separate module
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-06-22 12:06:10 -07:00
Cary Converse a198e5d191 coverage: llvm-cov support 2020-06-17 23:02:50 -04:00
Nirbheek Chauhan eab0e5a8b3 windows: Canonicalize `:` in filenames
Fixes https://github.com/mesonbuild/meson/issues/7265
2020-06-14 14:55:49 +00:00
Jussi Pakkanen 801dc03070
Merge pull request #7245 from dankegel/response-files-when-needed-tidied
Make ninja backend only use response files when needed, on linux too
2020-06-08 00:33:46 +03:00
Dan Kegel 10e6a989ba ninja: response file threshold now more accurate, overridable, portable. 2020-06-05 14:15:32 -07:00
Jon Turney 5ca37e7961 ninja: Add ninja variable DEPFILE_UNQUOTED with unquoted DEPFILE value
It's assumed that where we use DEPFILE in command or rspfile_content, it
can be quoted by quoting the ninja variable (e.g. $DEPFILE ->
'$DEPFILE')

This is nearly always true, but not for gcc response files, where
backslash is always an escape, even inside single quotes.

So this fails if the value of DEPFILE contains backslashes (e.g. a
Windows path)

Do some special casing, adding DEPFILE_UNQUOTED, so that the value of
depfile is not shell quoted (so ninja can use it to locate the depfile
to read), but the value of DEPFILE used in command or rspfile_content is
shell/response file quoted)

(It would seem this also exists as a more general problem with built-in
ninja variables: '$out' appearing in command is fine, unless one of the
output filenames contains a single quote.  Although forbidding shell
metacharacters in filenames seems a reasonable way to solve that.)

(How does this even work, currently? Backslashes in the value of all
ninja variables, including DEPFILE were escaped, which protected them
against being treated as escapes in the gcc response file.  And
fortunately, the empty path elements indicated by a double backslash in
the value of depfile are ignored when ninja opens that file to read it.)
2020-06-05 14:15:32 -07:00
Jon Turney abf8bf488e ninja: Specifically implement gcc rspfile style quoting
This differs from sh-quoting in that a backslash *always* escapes the
following character, even inside single quotes.  Yes, really.

https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libiberty/argv.c#l176
2020-06-05 14:15:32 -07:00
Jon Turney aca93df184 backend: There is no need for 'compiler-specific escaping' anymore
Now that all command-line escaping for ninja is dealt with in the ninja
backend, escape_extra_args() shouldn't need to do anything.

But tests of existing behaviour rely on all backslashes in defines being
C escaped: This means that Windows-style paths including backslashes can
be safely used, but makes it impossible to have a define containing a C
escape.
2020-06-05 14:15:32 -07:00
Jon Turney eb60c041f9 ninja: Implement Windows-style command line quoting
We avoided having to get this right previously, as we'd always use a
response file if possible.

But this is so insane, I can't imagine it's right.

See also: subprocess.list2cmdline() internal method
2020-06-05 14:15:32 -07:00
Jon Turney fbacf87af5 ninja: Quoting in rspfile depends on the compiler, not the shell
In certain exotic configurations, the style of quoting expected in the
response file may not match that expected by the shell.

e.g. under MSYS2, ninja invokes commands via CreateProcess (which
results in cmd-style quoting processed by parse_cmdline or
CommandLineToArgvW), but gcc will use sh-style quoting in any response
file it reads.

Future work: The rspfile quoting style should be a method of the
compiler or linker object, rather than hardcoded in ninjabackend.

(In fact, can_linker_accept_rsp() should be extended to do this, since
if we can accept rsp, we should know the quoting style)
2020-06-05 14:15:32 -07:00
Jon Turney 9cec5f3521 ninja: Push ninja and shell quoting down into NinjaRule
Rather than ad-hoc avoiding quoting where harmful, identify arguments
which contain shell constructs and ninja variables, and don't apply
quoting to those arguments.

This is made more complex by some arguments which might contain ninja
variables anywhere, not just at start, e.g. '/Fo$out'

(This implementation would fall down if there was an argument which
contained both a literal $ or shell metacharacter and a ninja variable,
but there are no instances of such a thing and it seems unlikely)

$DEPFILE needs special treatment.  It's used in the special variable
depfile, so it's value can't be shell quoted (as it used as a filename
to read by ninja).  So instead that variable needs to be shell quoted
when it appears in a command.

(Test common/129, which uses a depfile with a space in it's name,
exercises that)

If 'targetdep' is not in raw_names, test cases/rust all fail.
2020-06-05 14:15:32 -07:00
Jon Turney 92ee8932cd ninja: Refcount rsp and non-rsp rule usage separately
We need to count rsp and non-rsp references separately, which we need to
do after build statement variables have been set so we can tell the
difference, which introduces a bit of complexity.
2020-06-05 14:15:32 -07:00
Jon Turney 9967a2276d ninja: Expose response file rules in compdb
Possibly this should now be done by marking rules as being wanted in compdb, rather
than listing the rule names...
2020-06-05 14:15:32 -07:00
Jon Turney f9c03dfd29 ninja: Only use response files when needed
Writing rsp files on Windows is moderately expensive, so only use them
when the command line is long enough to need them.

This also makes the output of 'ninja -v' useful more often (something
like 'cl @exec@exe/main.c.obj.rsp' is not very useful if you don't have
the response file to look at)

For a rule where using a rspfile is possible, write rspfile and
non-rspfile versions of that rule.  Choose which one to use for each
build statement, depending on the anticpated length of the command line.
2020-06-05 14:15:32 -07:00
Jon Turney 50f98f3726 ninja: Rename 'rule' -> 'rulename' in NinjaBuildElement
Rename 'rule' to 'rulename' in the NinjaBuildElement class, we're going
to want a reference to the NinjaRule object as well.
2020-06-05 14:15:32 -07:00
Marcel Hollerbach cca06e4c33 ninjabackend: cache calls to normpaths
calls to normpaths are expansive. We should cache the results. This
safes 2s in the configure time of efl.
2020-06-05 09:02:23 +02:00
Daniel Mensinger a340b413ef ninja: Always use to_native on CompilerArgs (fixes #7167) 2020-05-27 20:23:58 +03:00
georgev93 6f199db95b Use --internal script call to call delwithsuffix when cleaning up the gcno and gcda files in a coverage enabled build. Otherwise, meson will crash when running from an MSI installation. 2020-05-26 02:48:57 +03:00
Jussi Pakkanen 751ea3df72
Merge pull request #7103 from dankegel/bug4027-rpath-remember
Let .pc files and LDFLAGS provide rpaths.
2020-05-18 23:17:34 +03:00
Dan Kegel d7235c5905 Let .pc files specify rpath.
Fixes #4027
2020-05-16 20:25:58 +00:00
Nirbheek Chauhan b1e3440e59 ninjabackend: Treat GNOME gir/typelib as libraries
When classifying generated sources, we were treating gir/typelib files
generated by gobject-introspection as headers. This is bad because it
serializes the build by adding order-only dependencies to every target
even though sources will never actually use them for anything.

Treat them as libraries, which is somewhat more accurate.
2020-05-15 08:39:25 +00:00
Nirbheek Chauhan a25f0741e8 ninjabackend: Use order-only gen-header deps for gen-sources
We do not need to *always* rebuild generated sources when a generated
header changes. We will get that information from the compiler's
dependency file, and ninja will track it for us. This is exactly the
same as static sources.

However, we do need an order-only dependency on all generated headers,
because we cannot know what headers will be needed at compile time
(which is when the compiler's dependency file is generated).

This fixes spurious rebuilds and relinking in many cases.
2020-05-15 08:39:25 +00:00
Michael Brockus 3ac437cecf
rm python2 %s from backends.py and ninjabackend.py 2020-05-03 14:00:15 +03:00
John Ericson 278c294aa4 Compiler options per lang
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-04-20 23:23:15 +03:00
Michael e04b0ae6b6 fix ninja version inconsistent 2020-04-20 19:31:21 +03:00
Marc-André Lureau a54506fe46 Handle BuildTarget as custom_target() argument #6914 2020-04-11 23:18:43 +03:00
ClausKlein 00104b1081 Remove my notes from sources
changes acording review comments
2020-03-19 19:11:10 +02:00
ClausKlein f72c990bfd Use os.path.normpath() for include paths
This make relative pathes shorter an too give a chance to
de-duplicate -isystem flags just like -I flags.

Fix common test case 203 for OSX build host too
2020-03-19 19:11:10 +02:00
Dylan Baker 06b1a317d2 Make use of unholder
We have a lot of cases of code like:
```python
if hasattr(var, 'held_object'):
    var = var.held_object`
```

replace that with the unholder function.
2020-03-05 09:58:52 -08:00
Jussi Pakkanen 0fbd09609f Clang-cl cross fix from Dale Curtis. Closes #5639. 2020-02-27 23:50:03 +02:00
Nirbheek Chauhan 3320e13d91 unit tests: Add a test for the symbolchecker script
When a source file for a library is changed without adding new extern
symbols, only that library should be rebuilt. Nothing that uses it
should be relinked.

Along the way, also remove trailing `.` in all Ninja rule
descriptions. It's very confusing to see messages like:

```
Linking target mylib.dll.
```

It's confusing that the period at the end of that is not part of the
filename. Instead of removing that period manually in the tests (which
feels wrong!) just don't print it at all.
2020-02-22 06:49:34 +05:30
Nirbheek Chauhan 5dcbf10a1b ninjabackend: Pass the import library to SHSYM
We actually use this while linking on Windows, and hence we need to
extract symbols from this file, and not the DLL.

However, we cannot pass it instead of the DLL because it's an optional
output of the compiler. It will not be written out at all if there are
no symbols in the DLL, and we cannot know that at configure time. This
means we cannot describe it as an output of any ninja target, or the
input of any ninja target. We must pass it as an argument without
semantic meaning.
2020-02-22 06:49:34 +05:30
Nirbheek Chauhan 72c6cbd990 ninjabackend: Minor refactoring 2020-02-22 06:49:34 +05:30
Nirbheek Chauhan be486a2ec8 ninjabackend: List PDBs in output list for targets
This is more correct, and forces the target(s) to be rebuilt if the
PDB files are missing. Increases the minimum required Ninja to 1.7,
which is available in Ubuntu 16.04 under backports.

We can't do the same for import libraries, because it is impossible
for us to know at configure time whether or not an import library will
be generated for a given DLL.
2020-02-22 06:49:34 +05:30
Nirbheek Chauhan 77d163a0e9 symbolextractor: Print one warning when no implementation found
So people know why all their binaries are getting relinked. Do this
only once per build-dir by writing a file to meson-private.
2020-02-16 03:11:51 +05:30
Daniel Mensinger 668610c0d2 backend: refactor: set self.interpreter in the constructor 2020-01-28 21:18:25 +02:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Jussi Pakkanen 17dd9e5bff
Merge pull request #6207 from dcbaker/linker-option
Add a way to select the dynamic linker meson uses
2019-12-11 23:29:33 +02:00
Daniel Mensinger fa4de71faf lgtm: Fix unused variable 2019-12-05 00:22:10 +02:00
Dylan Baker d856118006 environment: Fix selecting the linker with rustc 2019-12-03 13:08:42 -08:00
Dylan Baker 7658e67f92 backends/ninja: apply linker arguments when using rust
This will be required to make switching the linker work with rust.
2019-12-02 13:39:37 -08:00
Daniel Mensinger 9435f11b17
ci: Add CI command to include text files in the CI log 2019-11-19 15:21:13 +01:00
Jussi Pakkanen 35e809fc5e Store run target names in build.
This way we can easily check that we only provide builtin targets such
as clang-format if the user has not provided their own.
2019-11-10 23:45:42 +02:00
Wolfgang Stöggl f037e7ef45 Fix typos found by codespell
- Typos were found by codespell v1.16.0
2019-11-06 09:55:30 -05:00
Aleksey Gurtovoy 48e6db89ab Ask Ninja to expand rsp files in compile_commands.json 2019-11-02 16:16:09 +02:00
Marc-André Lureau 1ed70e22b9 Add source tags targets 2019-10-22 20:48:24 +03:00
Jussi Pakkanen d3b389f349 Add clang-tidy target. Closes #2383. 2019-10-01 22:02:51 +03:00
Jussi Pakkanen 5a52983f16 Refactor clang tool generation to its own function. 2019-10-01 22:02:51 +03:00
Ting-Wei Lan 0390b673f1 Find clang-format with alternative names
This is similar to what we currently do for scan-build except there is
no environment variable to choose a specific clang-format to run. If an
environment variable is needed for better control, we can add it later.
2019-09-29 00:11:15 +08:00
Aleksey Gurtovoy 7dbabdc7b6 Correctly handle platform-specific LDFLAGS options 2019-09-27 00:57:21 +03:00
Aleksey Gurtovoy 6ac5db50c9 CUDA support on Windows 2019-09-24 14:22:20 -07:00
Gabriel Ganne e7197895b2 uniform scan-build detection process
Detect scan-build the same way when trying to launch it and when
generating the target.
The detection method is:
  1. look within SCANBUILD env variable
  2. shutil.which('scan-build')
  3. *on non-linux platforms only*: go through all the possible
     name candidates and test them individually.

The third step is added following this comment
https://github.com/mesonbuild/meson/pull/5857#issuecomment-528305788
However, going through a list of all the possible candidates is neither
easily maintainable nor performant, and is therefore skipped on
platforms that should not require such a step (currently, only Linux
platforms).

This is a follow-up to the issue raised by @lantw44 during PR:
https://github.com/mesonbuild/meson/pull/5857
2019-09-14 05:51:36 +03:00
Jussi Pakkanen d67d5411bb
Merge pull request #5823 from scivision/linker-pgi-linux
PGI compiler fixes
2019-09-05 23:45:54 +03:00
Aleksey Gurtovoy 75daed27bc mesonlib.split_args/quote_arg/join_args 2019-09-05 23:42:47 +03:00
Michael Hirsch, Ph.D 25653cac07
PGI: windows workaround not-msvc-like enough function 2019-09-05 11:54:09 -04:00