Commit Graph

343 Commits

Author SHA1 Message Date
Eli Schwartz d880f995ea Revert "Do not automatically set warning flags if buildtype is 'plain'"
This reverts commit 8ee1c9a07a.

No rationale was given for this change prior to merging. After the fact
it was described as desired by distro packagers, however as a distro
packager I believe this commit hurts me.

From a distro packaging perspective, we primarily care about one thing:
previously building code should still build. Hence, -Werror is bad for
our use case. meson handles this via -D werror which is different from
-D warning_level and as long as the former is disabled, warnings in the
build do not cause harm (but may attract review attention for upstream
to fix).

buildtype is a completely unrelated concern, and the intention for
=plain is to disable debug or optimization settings that result in
codegen differences and thus different built artifacts. This must not
happen in distro builds because the *distributed programs* should
conform to policy settings.

Unfortunately, completely disabling warnings happens silently, and
cannot be overridden even if you really, really believe you know what
you're doing. It is thematically broken, since use of
add_project_arguments() to add more -W flags is not likewise ignored.
But if you try to add -Wall in that manner, meson will lecture you to
use warning_level which you cannot do. And if you have custom warning
flags which depend on options enabled by judicious use of -Wall via
default_options: 'warning_level=1', then you end up with generated
warnings complaining about your command line rather than your code, such
as:

cc1: warning: ‘-Wformat-y2k’ ignored without ‘-Wformat’ [-Wformat-y2k]
cc1: warning: ‘-Wformat-extra-args’ ignored without ‘-Wformat’ [-Wformat-extra-args]
cc1: warning: ‘-Wformat-zero-length’ ignored without ‘-Wformat’ [-Wformat-zero-length]
cc1: warning: ‘-Wformat-contains-nul’ ignored without ‘-Wformat’ [-Wformat-contains-nul]
cc1: warning: ‘-Wformat-security’ ignored without ‘-Wformat’ [-Wformat-security]

which then break the build with -Werror.

Throughout all this, a buildtype of "plain" does *not* disable -D
werror=true, which is the part where distro builds actually break down!

Users who both wish to disable debug/optimization codegen, *and* disable
warning commentary, are encouraged to do so by doing both, not by doing
one and having the other be assumed.

Fixes #7399
2020-09-11 18:22:57 +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
Nirbheek Chauhan fb7099c6cf mtest: Check version in the test data after loading
Same as coredata.dat and build.dat loading. Also, do not assert if
things change. Raise the appropriate exception.

Fixes https://github.com/mesonbuild/meson/issues/7613
2020-09-10 08:18:16 +00:00
Daniel Mensinger 23818fc5a3
typing: more fixes 2020-09-08 20:15:58 +02:00
James Hilliard 646ae846be backends: check external rpaths for all languages using ldflags
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2020-09-06 21:07:14 +03:00
Paolo Bonzini fa5c2363eb introspect: add test dependencies info to test/benchmark JSON
Add the ids of any target that needs to be rebuilt before running the
tests as computed by the backend, to the introspection data for tests and benchmarks.
This also includes anything that appears on the test's command line.

Without this information, IDEs must update the entire build before running
any test.  They can now instead selectively build the test executable
itself and anything that is needed to run it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-09-04 14:45:20 +02: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
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
Jussi Pakkanen bbf8533a97
Merge pull request #7494 from keszybz/fix-two-warnings
Fix two warnings
2020-07-30 16:39:04 +03:00
James Hilliard 1ce4258c21 backends: fix rpath match pattern
Since -Wl,-rpath= is not the only valid rpath ldflags syntax we
need to try and match all valid rpath ldflags.

In addition we should prevent -Wl,--just-symbols from being used to
set rpath due to inconsistent compiler support.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2020-07-30 16:36:11 +03:00
Zbigniew Jędrzejewski-Szmek 1123f4f311 Avoid warning about multiple outputs when building private directory name
Fixup for b4b1a2c5a1.

A warning would be printed for any rule with multiple outputs, for
example:
WARNING: custom_target 'coredump.conf.5' has more than one output! Using the first one.
WARNING: custom_target 'dnssec-trust-anchors.d.5' has more than one output! Using the first one.
WARNING: custom_target 'halt.8' has more than one output! Using the first one.

Fixes https://github.com/systemd/systemd/issues/16461.
2020-07-28 19:51:58 +02: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
Nirbheek Chauhan eab0e5a8b3 windows: Canonicalize `:` in filenames
Fixes https://github.com/mesonbuild/meson/issues/7265
2020-06-14 14:55:49 +00:00
Jon Turney b91355a29b Include the dep itself in extra_paths for Windows
This is needed in the case where a custom_target directly depends on a
shared library, and somehow loads it.

(Specifically this can be the case with gtkdoc, when it invokes
gtkdoc-scangobj, which will build and run it's own code to load a shared
library, to introspect it)
2020-06-13 18:48:35 +00:00
Jon Turney 1b7855c36d Handle multiple substitutions in eval_custom_target_command()
Handle command arguments which contain multiple substitutions correctly
in Backend.eval_custom_target_command()

In particular, gnome.gtkdoc() makes arguments of the form '--cflags
-I@SOURCE_ROOT@ -I@BUILD_ROOT' (where these arguments are then passed
down to a compiler invocation)

Normally, these are subsequently made right by
NinjaBackend.replace_paths(), but if Backend.as_meson_exe_cmdline()
decides that the command needs to be pickled, that doesn't happen.

(Although having two places where this substitution might happen smells
really bad)
2020-06-13 18:48:35 +00: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
Jussi Pakkanen 589a6249f0
Merge pull request #5986 from dcbaker/fix-tests-with-cross-binary-arguments
Fix tests with cross binary arguments
2020-05-19 00:23:19 +03:00
Jussi Pakkanen b4b1a2c5a1 Build private directory name from output file name. 2020-05-19 00:22:45 +03:00
Dylan Baker 0ec94ca062 backends: Consider arguments passed to a test when cross compiling
Otherwise a wrapper script which takes an executable as an argument will
mistakenly run when that executable is cross compiled. This does not
wrap said executable in an exe_wrapper, just skip it.

Fixes #5982
2020-05-18 13:53:58 -07:00
Dylan Baker cb6662b572 backends: ensure that test executables can be run when passed as arguments
If an executable is passed as an argument to a script in the build
directory that it resides in then it will not execute (on *nix) due to a
lack of ./. Ie, `foo` must be called as `./foo`. If it is called from a
different directory it will work. Ie `../foo` or `bar/foo`.

Fixes #5984
2020-05-18 13:53:58 -07: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 f8cfb74e9b Let LDFLAGS specify rpath.
Fixes #2567
2020-05-16 20:26:03 +00:00
Dan Kegel d7235c5905 Let .pc files specify rpath.
Fixes #4027
2020-05-16 20:25:58 +00:00
Ole André Vadla Ravnås 859dc4255a Fix outdated cross-compilation checks 2020-05-13 15:51:54 +00:00
Jussi Pakkanen 4ea7c6ee12
Merge pull request #7064 from dcbaker/gtest-protocol
Add support for Gtest as a test protocol
2020-05-06 23:57:44 +03:00
Dylan Baker 083c5f6357 Add native support for gtest tests
Gtest can output junit results with a command line switch. We can parse
this to get more detailed results than the returncode, and put those in
our own Junit output. We basically just throw away the top level
'testsuites' object, then fixup the names of the tests, and shove that
into our junit.
2020-05-04 11:33:19 -07:00
Michael Brockus 3ac437cecf
rm python2 %s from backends.py and ninjabackend.py 2020-05-03 14:00:15 +03:00
Dylan Baker 0c51762463 backend/backends: Fix type annotation 2020-04-30 13:59:49 -07:00
Dylan Baker 28e3ce67ae Convert test protocol into an enum
This gives us better type safety, and will be important as we add more
test methods
2020-04-30 13:54:46 -07:00
Dylan Baker 793c3d706e backends/backends: sort and cleanup imports 2020-04-30 13:35:55 -07: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
Daniel Mensinger d4449ed613 backend: Fix file name confilcts by using the complete path 2020-04-16 17:54:27 +00:00
Marc-André Lureau a54506fe46 Handle BuildTarget as custom_target() argument #6914 2020-04-11 23:18:43 +03:00
Xavier Claessens 4d7ccd1399 Make werror per subproject option 2020-03-24 22:48:55 +02:00
John Ericson 3a4388e51d Fix legacy env var support with cross
Fix #3969
2020-03-23 17:51:36 +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 47759550e5 Add unity block size option. 2020-02-12 22:31:08 +02:00
Xavier Claessens 0bf3c4ac4d backends: Remove unused method 2020-02-06 14:11:24 -05:00
Daniel Mensinger d0c7b51693 mintro: use interpreter data for buildsystem-files (fixes #6390) 2020-01-28 21:18:25 +02:00
Daniel Mensinger 668610c0d2 backend: refactor: set self.interpreter in the constructor 2020-01-28 21:18:25 +02:00
Jussi Pakkanen 9e07f8d8e6 Check for bad timestamps that cause eternal configure loops. 2020-01-27 18:27:20 +02:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Xavier Claessens 212a05b87e Remove duplicated object files in static libraries
When a static library link_whole to a bunch of other static libraries,
we have to extract all their objects recursively. But that could
introduce duplicated objects. ar is dumb enough to allow this without
error, but once the resulting static library is linked into an
executable or shared library, the linker will complain about duplicated
symbols.
2019-10-21 01:08:05 +03:00
Jakub Adam 1bf1782476 Fix *.pdb files missing in meson introspect --installed output
On Windows, make sure the introspect command lists all Program database
(PDB) files containing debugging information that Meson will install.
2019-10-09 15:50:20 +02:00
Dylan Baker f724cc2042 backends: Add needs_exe_wrapper to test serialization
We need to know if the test actually needs an exe wrapper to run or not.
2019-09-28 18:11:06 +03:00
Aleksey Gurtovoy 6ac5db50c9 CUDA support on Windows 2019-09-24 14:22:20 -07:00
David Seifert e19a49b895 Fix static archives stripping (#5905)
* Do not strip static archives

Stripping static archives without more fine-grained options (e.g. `-g`)
leads to failures such as

    ld: libfoo.a: error adding symbols: archive has no index; run ranlib to add one

because GNU strip removes *every* symbol in a static archive by default.
Given that static archives are not final build artifacts (unlike
executables and shared libraries), stripping them gains little and only
causes more edge case failures.

* Gentoo's portage only strips debug information:
  86f211e3a5/bin/estrip (L322)
* Fedora also only strips debug information:
  e9c13c6565/scripts/brp-strip-static-archive (L18)
* Debian also only does some very light stripping:
  72ed1d3261/dh_strip (L374)

Fixes #4138

* Add test case for static archive stripping
2019-09-08 19:48:57 -04:00
Peter Hutterer 4ebce2c3f2 Add test priorities to force test start order 2019-08-24 21:26:41 +03:00
Dylan Baker 110b562930 Vs backend compiler selection (#5448)
* backends/vs: Only set platform_toolset if it isn't already set

* interpreter: set backend up after the compiler

Otherwise we won't be able to check which VS toolchain to use.

* docs/using-visual-studio: wrap lines

* docs: recommend the py launcher instead of python3 for windows

* set backend.environment when building a dummy version

* backends/vs: Add support for clang-cl with vs2017 and vs2019 backends

* backends/vs: Add support for ICL (19.x) with vs2015 and vs2017 backends
2019-08-24 02:32:56 +03:00