Commit Graph

131 Commits

Author SHA1 Message Date
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
Aleksey Filippov 2febb99eee Fix b_ndebug=if-release option
Provide get_{type}_options_for_target() methods that unite {type} and builtin options.
2018-03-21 17:30:06 +00:00
makise-homura 546f81e0f9 Fixed lchmod detection for lcc C/C++ compilers 2018-03-21 16:42:15 +03:00
makise-homura 3b254c6e49 Fixed failure if compiler messages is not in UTF-8
For example, Elbrus lcc does output in KOI8-R, if LC_ALL=C, and
there is no English counterpart for original Russian message.
2018-03-20 17:03:32 +03:00
makise-homura 08bd07f860 Added specific get_library_dirs function for lcc 2018-03-20 16:25:08 +03:00
David Seifert 7eb187c5f2 Add -Wl,-dead_strip_dylibs support
* `-Wl,-dead_strip_dylibs` is the analogue
  of `-Wl,--as-needed` on macOS.
2018-03-19 23:37:14 +02:00
makise-homura 6230c2a2f6 Fixed indentation and space issues found by SideCI 2018-03-19 23:39:06 +03:00
makise-homura 7cc41baa98 Added Elbrus lcc compilers support as inheritance from gcc ones 2018-03-19 23:30:00 +03:00
Bedarkar, Malhar 831d1e4c2e - Updating cpp_std options similar to other compiler classes
- Updating environment.py for selecting '--vsn' option for armcc only.
- Updating build type arguments from GitHub pull request - 3157

Change-Id: Id3151e7715ec1016afdbd65391bb0d414ec7de13
2018-03-14 22:42:06 -05:00
Aleksey Filippov e4faf396e6 Do not use bare except [flake8]
Use more specific exception types where appropriate.
This patch does not change bare except calls if exception is re-raised.
2018-03-11 23:36:04 +00:00
Somasekhar Penugonda a470835778 Meson Github pull request - 3186 requested changes
- Fixing flake8 error in compilers.py - [E124] closing bracket does not match visual indentation
- Updating ARMCCompiler constructor in c.py to raise error as per comments
2018-03-07 17:42:53 -06:00
Bedarkar, Malhar a2ee76228e First cut of ARMCC support for MESON.
Change-Id: I15d8258e84d392baaccb8f670e33eefcfe8cd49a
2018-03-05 18:26:39 -06:00
Jon Turney 2f6ed47077 Fix various flake8 indentation reports
$ flake8 | grep -E '(E123|E127|E128)'
./run_unittests.py:1358:37: E127 continuation line over-indented for visual indent
./run_unittests.py:1360:37: E127 continuation line over-indented for visual indent
./mesonbuild/minit.py:311:66: E128 continuation line under-indented for visual indent
./mesonbuild/minit.py:312:66: E128 continuation line under-indented for visual indent
./mesonbuild/minit.py:313:66: E128 continuation line under-indented for visual indent
./mesonbuild/compilers/cpp.py:115:63: E127 continuation line over-indented for visual indent
./msi/createmsi.py:156:13: E123 closing bracket does not match indentation of opening bracket's line
./msi/createmsi.py:188:13: E123 closing bracket does not match indentation of opening bracket's line
2018-03-03 21:35:53 +00:00
Jussi Pakkanen ea3b54d402 Use include_directories for D impdirs.
Change the code to store D properties as plain data. Only convert them
to compiler flags in the backend. This also means we can fully parse D
arguments without needing to know the compiler being used.
2018-02-25 19:42:15 +02:00
Jussi Pakkanen dd74f3fb55 Hide banner when invoking csc. 2018-02-25 02:48:39 +02:00
Thibault Saunier c48b9594ff Add support for Visual Studio csc c# compiler 2018-02-25 01:10:52 +02:00