Commit Graph

146 Commits

Author SHA1 Message Date
Christoph Behle 47c3a26915 Always apply concatenate_string_literal.
get_define always applies concatenate_string_literal to its result.
Remove kwarg concatenate_string_literal from get_define.
2018-06-12 00:14:54 +00:00
Christoph Behle 626b0bcb05 Make concatenate_string_literals static 2018-06-12 00:14:54 +00:00
Christoph Behle 40d121d33e get_define can concatenate string literals.
Added method concatenate_string_literals to CCompiler. Will concatenate
  string literals.
Added keyword argument 'concatenate_string_literals' to Compiler.get_define.
  If used will apply concatenate_string_literals to its return value.
2018-06-12 00:14:54 +00:00
Christoph Behle ce27dd3aee Revert change 2018-06-12 00:14:54 +00:00
Christoph Behle 8ef4216f01 Concatenate string literals in get_define
If get_define returns a list of string_literals concatenate them into
one string.
2018-06-12 00:14:54 +00:00
Paolo Bonzini 1a5a18a3f3 vala: fix extract_all_objects() result
Because vala is not listed in clike_langs, is_source(fname) is returning False
for Vala source files.  Therefore, extract_all_objects() is completely empty
for Vala programs.

Fixes #791
2018-06-10 01:48:45 +00:00
Nirbheek Chauhan 186eed2dc6 find_library: Add a cache for library searching
Otherwise we can end up searching for the same library tens of times,
because pkg-config does not de-duplicate -lfoo args before returning
them.

We use -Wl,--start-group/end-group, so we do not need to worry about
ordering issues in static libraries.
2018-06-07 12:57:56 +00:00
Xavier Claessens 9b791881ed compilers: Use RUSTFLAGS from the env as default rust_args value 2018-06-06 20:02:37 +00:00
Xavier Claessens 218ed2de89 optinterpreter: Remove duplicated list of languages
It is important to keep the list of languages up to date in
optinterpreter, otherwise we could have conflicting options when adding
new languages.
2018-06-06 20:02:37 +00:00
Xavier Claessens aa879b7f0c Fix issues found by flake8 2018-06-06 20:02:37 +00:00
Xavier Claessens b7d442150d Move <lang>_args to coredata.compiler_options 2018-06-06 20:02:37 +00:00
Xavier Claessens fa72cd7173 Move get_args_from_envvars() from environment to compilers 2018-06-06 20:02:37 +00:00
Xavier Claessens 6eeea9dd54 Compilers: Chain-up to parent class in get_options()
Parent class could have common options for all compilers, and we'll soon
add some.
2018-06-06 20:02:37 +00:00
Nirbheek Chauhan 3e1a610702 Add a new option for building with Apple bitcode support
Normally, people would just pass -fembed-bitcode in CFLAGS, but this
conflicts with -Wl,-dead_strip_dylibs and -bundle, so we need it as
an option so that those can be quietly disabled.
2018-06-06 07:53:10 +00:00
Nirbheek Chauhan ad0121d259 Add prog/lib dirs from the mingw cross-compiler to PATH
These directories contain DLLs that the executable may need, such as
libstdc++-6.dll, libwinpthread, etc.
2018-06-05 10:50:22 +00:00
Nirbheek Chauhan ff07314a86 New compiler method: check_header
This checks not only for existence, but also for usability of the
header, which means it does a full compilation and not just
pre-processing or __has_include.

Fixes https://github.com/mesonbuild/meson/issues/2246
2018-05-30 15:25:39 +05:30
Christoph Reiter a87496addd Don't raise StopIteration in generators, no longer allowed with Python 3.7. Fixes #3622
Raising StopIteration from a generator has been deprecated with Python 3.5 and is now
an error with Python 3.7: https://docs.python.org/3.8/library/exceptions.html#StopIteration

Just use return instead.
2018-05-29 21:58:49 +03:00
Matthew Krupcale 45cc001a40 Add support for finding libraries in Fortran projects
* mesonbuild/compilers/c.py: Make the `find_library` method more generic by allowing the user to supply the `code` for compiling and linking.
 * mesonbuild/compilers/fortran.py: Use the methods inherited from `Compiler` base class where appropriate. Also reuse `CComiler` methods where applicable. This should be sufficient to get various compiler/linker arguments as well as to compile and link Fortran programs. This was tested with `gfortran` compiler, and while the other compilers ought to work for simple cases, their methods are primarily inherited from the base `FortranCompiler` class.
 * test cases/fortran/10 find library/gzip.f90: Fortran module with some basic Fortran wrapper interfaces to `gzopen`, `gzwrite`, and `gzclose` C `zlib` functions.
 * test cases/fortran/10 find library/main.f90: Fortran program using the `gzip` Fortran interface module to write some data to a gzip file.
 * test cases/fortran/10 find library/meson.build: Meson build file for this test case. This demonstrates the ability to link the Fortran program against an external library.
2018-05-21 23:17:02 +03:00
Nirbheek Chauhan ed701b5cb0 Revert "Add macOS linker versioning information"
This reverts commit fa6ca16054.

Closes https://github.com/mesonbuild/meson/issues/3550
2018-05-09 23:11:15 +02:00
Jasper Lievisse Adriaanse 3729e127ff add linker flag to handle $ORIGIN on OpenBSD 2018-05-04 23:42:04 +00:00
Jussi Pakkanen a2fdaa9ea0 Can use C++ and FORTRAN in a single target. Closes #2685. 2018-05-02 22:58:07 +03:00
Jussi Pakkanen 1918c0d231 Can combine D and C++ in a single target. Closes #3125. 2018-05-02 22:50:15 +03:00
Xavier Claessens 8c381e1786 has_multi_link_arguments: Some compilers needs -Wl,--fatal-warnings
ld does not treat wrong -z options as fatal by default.
2018-04-30 16:06:24 +00:00
Martin Hostettler 3ad45ef94e CCompiler: Cache result of get_library_dirs().
It is repeatedly used by e.g. guess_external_link_dependencies.
2018-04-27 02:10:21 +00:00
Xavier Claessens 2b93852a2e CCompiler: Do not call to_native() twice
compile() method already does it so links() and compiles() shouldn't do
it too. This fix regression introduced in 3d91a08b.

Closes #3431
2018-04-19 11:37:35 +00:00
Jussi Pakkanen 8ee1e49ae6
Merge pull request #3353 from xclaesse/has-link-argument
Add has_link_argument() and friends
2018-04-17 23:26:53 +03:00
Jussi Pakkanen 88ca3805e7
Merge pull request #1852 from QuLogic/openmp
Add an OpenMP dependency.
2018-04-17 21:39:13 +03:00
Nirbheek Chauhan 695b8f3a03 cc.has_multi_arguments: Convert all -Wno args
Also add a test for it.
2018-04-17 09:55:18 +00:00
Bruce Richardson 162a58b493 fix checks for gcc disable warning flags
GCC does not print a warning or error for unknown options if the options
are to disable warnings. Therefore, when checking for options starting
'-Wno-', also check the opposite enabling option.  This fixes the case
where e.g.  -Wno-implicit-fallthrough is incorrectly reported as supported
by gcc 5.4. To avoid missed warnings when using combinations of flags, such
as in test case "112 has arg", we limit the checking of for the positive
option to where the negative option is checked alone.
2018-04-17 09:55:18 +00:00
Elliott Sales de Andrade 461f3af294 Explicitly check for OpenMP headers. 2018-04-17 02:04:39 -04:00
Elliott Sales de Andrade dbb025a175 Add an OpenMP dependency.
This works similarly to the thread dependency which stores the various
inconsistent flags in each compiler.
2018-04-17 02:04:37 -04:00
Xavier Claessens bd37afeeea Add has_link_argument() and friends
Closes: #3335.
2018-04-16 19:14:02 -04:00
Xavier Claessens bca2ff6def VisualStudioCPPCompiler: Fix -fpermissive still being added
super(VisualStudioCCompiler, self) calls CPPCompiler and that's what we
want to avoid.
2018-04-16 19:11:16 -04:00
Xavier Claessens 3d91a08bbc Compilers: Reduce code duplication between compiles and links
This also fix links() not calling args.to_native() unlike compiles()
2018-04-16 19:08:24 -04:00
Xavier Claessens 521ce883ad has_argument(): reduce code duplication 2018-04-16 19:08:24 -04:00
Jussi Pakkanen c58dd64f8e Merged Arm CC support. 2018-04-16 23:02:09 +03:00
Tom Schoonjans fa6ca16054 Add macOS linker versioning information
This patch exploits the information residing in ltversion to set the
-compatibility_version and -current_version flags that are passed to the
linker on macOS.
2018-04-16 22:26:16 +03:00
Marvin Scholz 5e45f4c621 Do not use -soname when linking with GCC for mingw/cygwin
GNU LD does not use soname when linking a PE/COFF binary, so it makes no
difference, but it breaks when using the llvm linker (lld), which does
not support the soname flag when building PE/COFF binaries for Windows.

Fix #3179
2018-04-16 03:10:11 +00:00
Jussi Pakkanen 86f725c1e5
Merge pull request #3115 from makise-homura/e2k-lcc-support
Support lcc compiler for e2k (Elbrus) architecture
2018-04-15 17:18:44 +03:00
Martin Hostettler aff597fb99 ninjabackend: Try to guess library dependencies for linker invocation.
The linkers currently do not support ninja compatible output of
dependencies used while linking. Try to guess which files will be used
while linking in python code and generate conservative dependencies to
ensure changes in linked libraries are detected.

This generates dependencies on the best match for static and shared
linking, but this should not be a problem, except for spurious
rebuilding when only one of them changes, which should not be a problem.

Also makes sure to ignore any libraries generated inside the build, to
keep the optimisation working where changes in a shared library only
cause relink if the symbols have changed as well.
2018-04-15 07:29:21 +00:00
Martin Hostettler 642e17aa6b compilers: is_library: Also detect .so files with version (using soregex) 2018-04-15 07:29:21 +00:00
Nirbheek Chauhan 2e5b2813d5 compilers: Cache compiler checks where we don't want the output
This caching is only for a single run, so it doesn't help reconfigure.
However, it is useful for subproject setups where different subprojects
will run the same compiler checks.

The cache is also per compiler instance and is not used for functions
that want to read or run the outputted object file or binary.

For gst-build, this halves the number of compiler checks that are run
and reduces configuration time by 20%.
2018-04-14 22:14:11 +03:00
Daniel Schulte 57654bf367 Deduplicate dependencies resolved to absolute paths
If paths are absolute the order of search directories is not relevant as the path is already resolved.
2018-04-13 01:05:25 +00:00
Rico Tzschichholz 5a0884dab3 vala: Don't pass -o and -C at the same time
Fixes "warning: --output and -o have no effect when -C or --ccode is set"

get_always_args() adds -C which is already disabling the direct compilation
ability of valac for which -o is used.
2018-04-11 21:42:42 +03:00
Xavier Claessens 8a70e7cff5 Remove arbitrary [-1024,1024] limit in cross_compute_int()
Copy the algorithm used by autoconf.

It computes the upper and lower limits by starting at [-1,1] and
multiply by 2 at each iteration. This is even faster for small numbers
(the common case), for example it finds value 0 in just 2 compilations
where old algorithm would check for 1024, 512, ..., 0.
2018-04-08 16:56:33 +03:00
Somasekhar Penugonda 7f89083363 Fix for issue in cpp.py
Change-Id: Iad9623d20eb5086528dacefce5d2f4f9bb9d0312
2018-03-31 19:23:31 -05:00
Somasekhar Penugonda e62b8109eb Updates to CPP support and update review changes 2018-03-27 17:04:26 -05:00
Thierry Reding c4192a04fd Support data types larger than 128 bytes
Recent versions of systemd (starting with v238) started to check for the
existence of the statx structure using the cc.sizeof() operation. The cc
compiler implementation fails to detect this structure because it's size
limit is 128, meaning it will fail for any type larger than 128 bytes in
the following way during cross-compilation checks:

        meson.build:10:2: ERROR: Cross-compile check overflowed

Increase the size limit for data types to 1024 bytes, which should give
plenty of room for even large data structures. This is obviously not
guaranteed to be an upper bound, but given the binary search algorithm
implemented in the cross-compile check, raising the limit too high may
significantly increase the time required for this check on smaller data
types.

Signed-off-by: Thierry Reding <treding@nvidia.com>
2018-03-25 17:22:05 +03:00
Aleksey Filippov 8b1e9a6f6a Enable b_ndebug on VisualStudioCCompiler 2018-03-23 21:10:04 +02:00
Alexis Jeandet e89008b657 Added get_asneeded_args method to Intel compiler.
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
2018-03-23 21:08:37 +02:00