Commit Graph

620 Commits

Author SHA1 Message Date
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
Michael Hirsch, Ph.D 4c8b41a173 flatten list to subprocess.Popen, necessary for Python 3.8 2019-09-01 21:45:47 +03:00
Gabriel Ganne 4143c7bceb ninjabackend: do not generate scan-build target if it cannnot be run
as what was done with clang-format, test the presence of the tool before
generating a dedicated target. Pass silently if scan-build is not found.

Signed-off-by: Gabriel Ganne <gabriel.ganne@mindmaze.ch>
2019-08-28 20:36:10 +03:00
Jussi Pakkanen 1ea3ddc6ad
Merge pull request #5681 from dcbaker/dynamic-linker-split
split dynamic linker representations from compilers
2019-08-20 23:14:05 +03:00
Jussi Pakkanen 80ef6fd69f Pass optimization flags to rustc properly. Closes: #5788. 2019-08-17 21:14:16 +03:00
Dylan Baker 06dcbd50ee compilers: Dispatch to dynamic linker class
Most of the cuda code is from Olexa Bilaniuk.
Most of the PGI code is from Michael Hirsc
2019-08-14 13:13:23 -07:00
Aleksey Gurtovoy e5b515aa1d ninjabackend: Squish Coco support 2019-08-10 01:00:28 +03:00
Jussi Pakkanen 2e6df380f1
Merge pull request #5644 from bonzini/meson-exe-cmdline
Show command line in `ninja -v` for `capture: true` custom targets and generators
2019-08-03 01:28:27 +03:00
Jussi Pakkanen 7ce2a24f42 Made dist a top level command. 2019-07-23 23:26:46 +03:00
Dylan Baker 24c4c079e7 linkers: Add get_base_link_args method to static linkers
MSVC needs an argument to static linkers for doing LTO, so we need a way
for the static linker to tell us that.
2019-07-23 09:58:24 +00:00
Nirbheek Chauhan 9c2724bce5 Add optional progress bar when generating build.ninja 2019-07-20 17:02:15 +03:00
Paolo Bonzini f95c965043 backends: choose whether to serialize in as_meson_exe_cmdline
This removes more duplicate code between custom targets and generators.
In addition, generators can now have arguments with newlines in them.
2019-07-19 00:17:29 +02:00
Paolo Bonzini 3ef7b23178 backends: hide meson --internal exe cmdline from backends
Return the command line from serialize_executable, which is then
renamed to as_meson_exe_cmdline.  This avoids repeating code that
is common to custom targets and generators.
2019-07-19 00:17:29 +02:00
Xavier Claessens 12d4031f52 Add alias_target() function 2019-07-10 15:01:18 -04:00
James Westman 77c3e6a4aa Fix two errors when cross-compiling with Vala
- AttributeError: 'ValaCompiler' object has no attribute 'get_program_dirs'

  Fixed by adding a `get_program_dirs()` function to the base Compiler
  class, to match `get_library_dirs()`

- KeyError: 'vala_COMPILER'

  Fixed by creating the Vala compile rules for all machines, not just
  the build machine.
2019-06-27 21:28:54 +03:00
Michael Hirsch, Ph.D 5b109c9ad2 correct missing argument for IntelClFortranCompiler
ifort passes all tests

cleanup logic
2019-06-24 14:06:32 -04:00
Michael Hirsch, Ph.D ef53107f14 BUGFIX: Fortran module regex handle more edge cases 2019-06-23 17:27:46 +03:00
Jussi Pakkanen 49e9e0179c Do not quote targetdep, Ninja fails if it contains double quotes. 2019-06-21 17:07:21 +03:00
Michael Hirsch, Ph.D 927ce94d99 fortran depscan: ignore module procedure 2019-06-20 18:31:07 -04:00
Michael Hirsch, Ph.D 2a7ef98aff BUGFIX syntax 2019-06-20 12:31:32 -04:00
John Ericson 07777e15d4 Purge `is_cross` and friends without changing user interfaces
In most cases instead pass `for_machine`, the name of the relevant
machines (what compilers target, what targets run on, etc). This allows
us to use the cross code path in the native case, deduplicating the
code.

As one can see, environment got bigger as more information is kept
structured there, while ninjabackend got a smaller. Overall a few amount
of lines were added, but the hope is what's added is a lot simpler than
what's removed.
2019-06-09 13:13:25 -04:00
John Ericson 32e827dcdc Use `env.machines.*` to avoid some `is_cross`
This is a small example of the `is_cross` removal the that abstraction
enables.
2019-06-09 13:13:20 -04:00
Marcel Hollerbach 5465fc5e28 ninjabackend: refactor _generate_single_compile
when we are generating the include directories for a build target, then
we are iterating over all include directories, check if they are . or ..
and if not, generate a compile args object for it. However, the join
calls and the generation of the compile object is quite expensive, if we
cache the results of this, then we can _generate_single_compile from 60%
to roughly 50%.
2019-06-03 20:37:27 +03:00
Jussi Pakkanen 79d530e325 Generators can have extra target dependencies. Closes #4131. 2019-05-20 23:38:13 +03:00
Jon Turney 3ff758f22d Switch from build.compiler to environment.coredata.compiler in backends
Switch from build.compiler to environment.coredata.compiler and likewise
from build.cross_compiler to environment.coredata.cross_compiler in
backends. (Only seems to be actually used in ninja backend).
2019-05-20 11:29:17 -07:00
Jon Turney 6d6f6ad5fa Remove a pointless conditional
After #4445, the code in both branches of this conditional is the same.
2019-05-20 11:29:17 -07:00
Dylan Baker b935359978 backends/ninja: Ifort is msvc-like but doesn't have showincludes 2019-05-13 11:22:31 -07:00
Dylan Baker 541523eeba compilers: Split C-Like functionality into a mixin classes
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-03 10:36:50 -07:00
Daniel Mensinger 236221061a
Fixed unnecessary .items() 2019-04-29 12:23:13 +02:00
Daniel Mensinger 3581839f4c
Fix unused variables warnings 2019-04-29 12:22:50 +02:00
Daniel Mensinger e75211d321
Fix builtin variable names 2019-04-29 12:17:40 +02:00
Jon Turney 0debaab8d1
ninja: Suppress unused rules in output
Don't bother outputting any rules which aren't referenced by any build
statement.
2019-04-27 15:57:01 +01:00
Jon Turney 091459cbdf
ninja: Expand comment on shell-unquoted ninja variables 2019-04-27 15:57:01 +01:00
Jon Turney e4d4ac773a
ninja: Push concatenation of command down into NinjaRule
Pass the command line to NinjaRule() as a list of strings, not already
concatenated as a string.
2019-04-27 15:57:01 +01:00
Jon Turney 798cacd30a
ninja: Remove unneeded outfile args (build statements)
After the previous commit, outfile is now passed down to lots of things
which don't use it, as they only create built statements, rather than
writing them out.  Remove these unnecessary args.
2019-04-27 15:56:51 +01:00
Jon Turney c4304d25f9
ninja: Store build statements
Store the build statements and then write them all out, rather than
writing them out as we go.

Construct a NinjaBuildElement for the 'PHONY' target, rather than
writing it literally to the build.ninja file.
2019-04-27 15:54:17 +01:00
Jon Turney 45d1dff592
ninja: Remove unneeded outfile args (rules)
After the previous commit, outfile is now passed down to lots of things
which don't use it, as they only create rules, rather than writing them
out.  Remove these unnecessary args.
2019-04-27 15:42:14 +01:00
Jon Turney 1303389700
ninja: Store rules
Store the rules and then write them all out, rather than writing them
out as we go.

Store the rule broken down into parts which do and don't go into
rspfile, so we can construct either a rsp or non-rsp version of the
rule.
2019-04-27 15:39:32 +01:00
Jon Turney 7bc1db2d7b
ninja: Move things which aren't rules or build statements up to generate() 2019-04-23 11:22:51 +01:00
Jon Turney 42e9028868
ninja: Remove use of unset ninja variable 'aliasing'
Setting this variable to contain additional commands to symlink shlib
aliases was removed in commit c0bf3e8d, so it's always unset now, and
thus does nothing.
2019-04-23 11:22:49 +01:00
Dylan Baker add821db64 Don't use mutable types as default arguments
This isn't safe given the way python implements default arguments.
Basically python store a reference to the instance it was passed, and
then if that argument is not provided it uses the default. That means
that two calls to the same function get the same instance, if one of
them mutates that instance every subsequent call that gets the default
will receive the mutated instance. The idiom to this in python is to use
None and replace the None,

def in(value: str, container: Optional[List[str]]) -> boolean:
   return src in (container or [])

if there is no chance of mutation it's less code to use or and take
advantage of None being falsy. If you may want to mutate the value
passed in you need a ternary (this example is stupid):

def add(value: str, container: Optional[List[str]]) -> None:
    container = container if container is not None else []
    container.append(value)

I've used or everywhere I'm sure that the value will not be mutated by
the function and erred toward caution by using ternaries for the rest.
2019-04-23 02:03:19 +03:00
makise-homura 54f9ec4510 Fix concatenation of library dirs 2019-04-19 18:02:01 +03:00
Paolo Bonzini b9774b4485 generator: add dependency on generator in source tree
If find_program() returns a file from the source directory, anything
that uses it should add the file to the dependencies, so that they are
rebuilt whenever the script changes.  Generator is not doing that.

While at it, I am doing two related fixes:

- Generator is not checking whther the generator actually was found,
resulting in a Python error involving NoneType if it isn't.  To minimize
backwards compatibility issues, I am only raising the error when
g.process() is acutally called.

- the error message for custom_target with a nonexisting program
erroneously mention a not-found external program "nonexistingprogram".
The new error is similar to the one I am adding for generators.
2019-04-16 01:46:31 +00:00
Dylan Baker 6ad7fbf950 dependencies/misc: don't special case threads
Instad of having special casing of threads in the backends and
everywehre else, do what we did for openmp, create a real
dependency. Then make use of the fact that dependencies can now have
sub dependencies to add threads.
2019-04-05 16:41:08 -07:00
Michael Hirsch, Ph.D 8763d1a584 cleanup rebase of fortraninclude..submod 2019-03-25 08:28:33 -04:00
Michael Hirsch, Ph.D cc4e0b5027 DRY Fortran submodule regex 2019-03-25 08:28:33 -04:00
Michael Hirsch, Ph.D c8342b794b no \b for no-gap non-stantard submodule declaration 2019-03-25 08:28:33 -04:00
Michael Hirsch, Ph.D 41edb6d68f tolerate no-space submodule (non-standard syntax) 2019-03-25 08:28:33 -04:00
Michael Hirsch, Ph.D 434599cc12 Squashed commit of the following:
commit b02b2d6d0d462310b313588ca7705d391e830eeb
Author: Michael Hirsch, Ph.D <scivision@users.noreply.github.com>
Date:   Sun Mar 10 03:51:09 2019 -0400

    cleanup

commit 3311ff5fb12577c78671bf2ff2787d28b86ba5fa
Author: Michael Hirsch, Ph.D <scivision@users.noreply.github.com>
Date:   Sun Mar 10 03:50:30 2019 -0400

    more robust

commit 8030dcb76698b148ee47ecded1f33b6d3821cca2
Author: Michael Hirsch, Ph.D <scivision@users.noreply.github.com>
Date:   Sun Mar 10 03:30:05 2019 -0400

    inwork compiles OK but needs smod filenames
2019-03-25 08:28:32 -04:00
Michael Hirsch, Ph.D 2a830743cc allow fortran submodule to have same name as module 2019-03-25 08:28:32 -04:00
Jussi Pakkanen 8361da5c52 Fix setup so test suite runs with rustc + MSVC. Closes: 5099 2019-03-24 20:56:06 +02:00
Jussi Pakkanen 4e5edff60f Fix Rust global and local args. Closes #5101. 2019-03-22 20:59:33 +02:00
Jussi Pakkanen 3a613564d3
Merge pull request #5116 from dcbaker/openmp-de-specialize
dependencies/openmp: Don't special case OpenMP
2019-03-21 01:21:37 +02:00
Dylan Baker ac627bcea7 replace library type strings with an enum
This patch creates an enum for selecting libtype as static, shared,
prefer-static, or prefer-shared. This also renames 'static-shared'
with 'prefer_static' and 'shared-static' with 'prefer_shared'. This is
just a refactor with no behavioral changes or user facing changes.
2019-03-20 18:45:56 +02:00
Dylan Baker 1f342a2081 dependencies/openmp: Don't special case OpenMP
Currently we specialcase OpenMP like we do threads, with a special
`need_openmp` method. This seems like a great idea, but doesn't work
out in practice, as well as it complicates the opemp
implementation. If GCC is built without opemp support for example, we
still add -fopenmp to the the command line, which results in
compilation errors.

This patch discards that and treats it like a normal dependency,
removes the need_openmp() method, and sets the compile_args attributes
from the compiler.

Fixes #5115
2019-03-19 12:48:22 -07:00
Michael Hirsch, Ph.D 6d215476c0
functionalize per-file Fortran dep scan
allow recursion for Fortran include

qualify include by file extension

correct suffix
2019-03-14 01:43:25 -04:00
Niklas Claesson dd2c44cdf6 Add static as keyword to find_library 2019-03-11 20:56:52 +02:00
Nicolas Schneider ded0defc3f auto generate msvc pch source file if none is provided by the user 2019-03-01 21:50:31 +02:00
Michael Hirsch, Ph.D 39e6dc5885 correct Fortran self-dep logic
corrected, generalized self-referential Fortran fix

further refine logic
2019-02-27 14:08:08 +02:00
Michael Hirsch, Ph.D 32a344b949 Fortran: handle self-referential files 2019-02-26 19:16:50 +02:00
Andrei Alexeyev 2d0841c624 Improve handling of gui_app
This does two things:

 * On windows GCC-like compilers, the subsystem is always explicitly
 specified (either -mwindows or -mconsole). MSVC is already explicit.

 * The gui_app linker flags are now added after those mandated by
 external dependencies. This is because some misguided libraries (such
 as SDL) think that hijacking `main()` and forcing `-mwindows` in link
 flags is clever. We must unconditionally override such misuses to let
 gui_app work as intended.
2019-02-18 22:08:36 +02:00
jml1795 80f16cac8f Fix console log from generator with multiple output nodes 2019-02-18 22:02:15 +02:00
John Ericson d87744138a Remove remaining cross-specific compiler-args code
Since the consolidation of flags in `compiler_options.*`, this
cross/native special casing is not needed.
2019-02-15 09:17:24 -08:00
John Ericson c83b426b0f Remove a useless `cross_args` which is always empty 2019-02-15 09:17:24 -08:00
John Ericson d451a4bd97 Remove get_cross_extra_flags
This is no longer needed, we just remove conditionals around it.
2019-02-15 09:17:24 -08:00
Andrei Alexeyev cc8af259c8 ninja: Always treat PCHs as an implicit dependency
In addition to MSVC, which was worked around previously, GCC also does
not list includes from the PCH in the depfile by default, unless
-fpch-deps is given. I think it's best to stay safe and not rely on any
particular behavior from the compiler here.
2019-02-13 21:24:43 +02:00
Michael Hirsch, Ph.D 627d0d1f3e BUGFIX: ignore non-ascii Fortran characters 2019-02-11 21:26:15 +02:00
Michael Hirsch, Ph.D eccc59874d BUGFIX: handle Fortran 2003 "use" syntax 2019-02-09 00:34:02 +02:00
Jussi Pakkanen 711f73e386
Merge pull request #4860 from nioncode/fixPch
Fix missing PCH dependencies
2019-02-09 00:31:00 +02:00
Michael Hirsch, Ph.D 70e6f4198c Fortran 2008 submodule (#4874) 2019-02-05 22:41:44 +01:00
John Ericson 19f81d3e33 Never access environment.properties downstream
Instead use coredata.compiler_options.<machine>. This brings the cross
and native code paths closer together, since both now use that.

Command line options are interpreted just as before, for backwards
compatibility. This does introduce some funny conditionals. In the
future, I'd like to change the interpretation of command line options so

 - The logic is cross-agnostic, i.e. there are no conditions affected by
   `is_cross_build()`.

 - Compiler args for both the build and host machines can always be
   controlled by the command line.

 - Compiler args for both machines can always be controlled separately.
2019-02-02 13:59:14 -05:00
Nicolas Schneider 3cbc7c7bd9 msvc: fix PCH staleness 2019-02-01 22:28:53 +01:00
Nicolas Schneider 2044bc53b3 use same compiler args for pch as for regular target
Fixes #999, #1415, #2361.
2019-02-01 22:28:52 +01:00
Nirbheek Chauhan 50b863032e find_library: Check arch of libraries on Darwin
macOS provides the tool `lipo` to check the archs supported by an
object (executable, static library, dylib, etc). This is especially
useful for fat archives, but it also helps with thin archives.

Without this, the linker will fail to link to the library we mistakenly
'found' like so:

ld: warning: ignoring file /path/to/libfoo.a, missing required architecture armv7 in file /path/to/libfoo.a
2019-01-31 20:36:49 +00:00
Michael Hirsch, Ph.D cccffaa29d BUGFIX: allow fc.run(code) to work, pick only Fortran module 2019-01-29 23:25:23 +02:00
Robert Bragg f2223fcf54 ninjabackend: Adding missing shell quotes for compiler arguments
Since trying to cross compile for Windows from Linux (WSL) and having
paths like this:

  '-L/mnt/c/Program Files (x86)/Microsoft Visual Studio/2017/\
    Community/VC/Tools/MSVC/14.15.26726/lib/x64'

I found that the spaces and brackets in the paths weren't properly
escaped by the Ninja backend.
2019-01-07 23:03:18 +02:00