Commit Graph

176 Commits

Author SHA1 Message Date
Jon Turney d57498a4fd Unconditionally use get_gui_app_args()
Add get_gui_app_args() to the Compiler class so it can be unconditionally
used
2018-08-15 06:17:58 -07:00
Jon Turney 94f09a8454 Explicitly set the Windows subsystem for ninja/VisualC 2018-08-15 06:17:58 -07:00
Jussi Pakkanen d742e2e891
Merge pull request #4001 from mikezackles/cpp2a
Add support for c++2a and gnu++2a (closes #3997)
2018-08-11 21:25:51 +03:00
Jussi Pakkanen f91b463bf4
Merge pull request #3831 from mesonbuild/symvisibility
Add gnu_symbol_visibility keyword argument
2018-08-11 19:59:34 +03:00
Nirbheek Chauhan ae5ebd258f PkgConfigDependency: Don't try to resolve internal compiler libs
-lc -lm -ldl -lrt -lpthread are special linker arguments that should
never be resolved to on-disk libraries.

Closes https://github.com/mesonbuild/meson/issues/3879
2018-08-11 04:16:18 -07:00
Zachary Michaels 8417c1a20f Add support for c++2a and gnu++2a 2018-08-09 11:09:21 -07:00
Jussi Pakkanen fb2cdd0fe2 Call it gnu_symbol_visibility instead. 2018-08-09 19:46:49 +03:00
Jussi Pakkanen 6a0e674043 Add kwarg for specifying symbol visibility. 2018-08-09 19:46:49 +03:00
Nirbheek Chauhan 475efb9354 msvc: Don't add dynamic link args, they're ignored
And they print a linker warning about unknown args.
2018-08-09 18:39:19 +03:00
Nirbheek Chauhan 6c8f81333a PkgConfigDependency: Fix library path search order
We were searching the library paths in the reverse order, which meant
that we'd pick libraries from the wrong prefix.

Closes https://github.com/mesonbuild/meson/issues/3951
2018-08-08 05:45:45 -07:00
Jussi Pakkanen e75f6e4305
Merge pull request #3850 from mesonbuild/nirbheek/exe-wrapper-compiler-fallbacks
Be more permissive about not-found exe_wrapper
2018-07-31 19:33:06 +03:00
Thomas Hindoe Paaboel Andersen e2c36457c5 Avoid concatenating two options in list
'c++17' and 'gnu++98' were concatenated due to a missing comma
2018-07-13 20:00:50 +03:00
Alberto Sartori 8bee30367e Implement get_link_whole_for() for IntelCompiler (#3863)
closes #3862
2018-07-10 13:23:51 -07:00
Nirbheek Chauhan 47c68a5993 find_library: Validate and sort globbed shared library files
We need to pick the library with the highest version, which is what
the OpenBSD linker also does.

https://github.com/mesonbuild/meson/issues/3570#issuecomment-403638752
2018-07-10 12:42:52 -07:00
Nirbheek Chauhan 8cfb8fd02c
Fix searching of shared libraries on OpenBSD (#3851)
* get_library_naming: Use templates instead of suffix/prefix pairs

This commit does not change functionality, and merely sets the
groundwork for a more flexibly naming implementation.

* find_library: Fix manual searching on OpenBSD

On OpenBSD, shared libraries are called libfoo.so.X.Y where X is the
major version and Y is the minor version. We were assuming that it's
libfoo.so and not finding shared libraries at all while doing manual
searching, which meant we'd link statically instead.

See: https://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs

Now we use file globbing to do searching, and pick the first one
that's a real file.

Closes https://github.com/mesonbuild/meson/issues/3844

* find_library: Fix priority of library search in OpenBSD

Also add unit tests for the library naming function so that it's
absolutely clear what the priority list of naming is.

Testing is done with mocking on Linux to ensure that local testing
is easy
2018-07-09 09:45:02 -07:00
Nirbheek Chauhan e8dae2b966 cross: Be more permissive about not-found exe_wrapper
We used to immediately try to use whatever exe_wrapper was defined in
the cross file, but some people generate the cross file once and use
it for several projects, most of which do not even need an exe wrapper
to build.

Now we're a bit more resilient. We quietly fall back to using
non-exe-wrapper paths for compiler checks and skip the sanity check.
However, if some code needs the exe wrapper, f.ex., if you run a built
executable using custom_target() or run_target(), we will error out
during setup.

Tests will, of course, continue to error out when you run them if the
exe wrapper was not found. We don't want people's tests to silently
"pass" (aka skip) because of a bad CI setup.

Closes https://github.com/mesonbuild/meson/issues/3562

This commit also adds a test for the behaviour of exe_wrapper in these
cases, and refactors the unit tests a bit for it.
2018-07-09 05:39:40 +05:30
Nirbheek Chauhan 416a00308f cross: Use ExternalProgram for cross-file exe_wrapper
We already have code to fetch and find binaries specified in a cross
file, so use the same code for exe_wrapper. This allows us to handle
the same corner-cases that were fixed for other cross binaries.
2018-07-09 04:09:46 +05:30
Jon Turney b387ab1ee1 Fix flake8 issues (#3834)
* Fix flake8 whitespace reports

$ flake8 | grep -E '(E203|E221|E226|E303|W291|W293)'
./mesonbuild/coredata.py:337:5: E303 too many blank lines (2)

* Fix flake8 'variable assigned value but unused' reports

$ flake8 | grep -E F841
./mesonbuild/modules/gnome.py:922:9: F841 local variable 'target_name' is assigned to but never used

* Fix flake8 'imported but unused' reports

$ flake8 | grep F401
./mesonbuild/compilers/__init__.py:128:1: F401 '.c.ArmclangCCompiler' imported but unused
./mesonbuild/compilers/__init__.py:138:1: F401 '.cpp.ArmclangCPPCompiler' imported but unused
./mesonbuild/modules/__init__.py:4:1: F401 '..mlog' imported but unused

PR #3717 imports ARMCLANG compilers in __init__, but does not add them to
__all__, so they are not re-exported by the compilers package like
everything else.

* More details about flake8 in Contributing.md

Mention that Sider runs flake8
Suggest seting flake8 as a pre-commit hook
2018-07-05 18:08:04 +00:00
Nirbheek Chauhan f18af09189 find_library: Only run link test on system dirs
Paths provided to us by the user or by pkg-config can be (and must be)
assumed to be usable since they might not be usable standalone.

Closes https://github.com/mesonbuild/meson/issues/3832
2018-07-04 10:39:14 +00:00
Bruce Richardson 755ec53a6b prune nonexistent dirs from library search path
Rather than storing in the cache of search paths the full list returned
from the compiler and having each call ignore the non-existent ones, remove
from the list all non-existent ones before returning to the caching function.
2018-07-03 12:50:17 +00:00
Bruce Richardson af546b52ca fix find_library when cross-compiling 32-bit on 64-bit systems
When find_library is used to find dependencies, meson checks all paths for
libraries with all prefixes that could match. This means that when we are
compiling with -m32 on a 64-bit system, meson will find 64-bit libraries and
assumes that they will work. Naturally that is not the case.

The obvious fix is to do a test link against those libraries, but the extra
wrinkle here is that we need to do a "whole link" so as to test the static
libs. A check with gcc+ld on linux shows that unless there are unresolved
symbols from the main.c file, the static library is never checked so we avoid
the error from an incompatible library.
2018-06-30 11:16:03 +00:00
Matthias Klumpp 7618fa81d3 d: Don't fail if -link-defaultlib is manually added to the LDC link args 2018-06-30 00:28:39 +03:00
Jussi Pakkanen 1a6765e631 Return a better warning if compiled executable is invalid. 2018-06-24 21:19:49 +03:00
Vasu Penugonda 7140afc0a8 Added ARMCLANG compiler support for C/C++ (#3717) 2018-06-21 00:55:39 +03:00
Nirbheek Chauhan 58ae2c9a8c Rename clike_langs to clink_langs for clarity
D is not a 'c-like' language, but it can link to C libraries. The same
might be true of Rust in the future and Go when we add support for it.

This contains no functionality changes.
2018-06-20 11:27:08 +00:00
Nirbheek Chauhan d737488150 dependencies: Don't assume self.compiler is a C compiler
All dependencies were using find_library, has_header, get_define, etc on
self.compiler assuming that it's a compiler that outputs and consumes
C-like libraries. This is not true for D (and in the future, for Rust)
since although they can consume C libraries, they do not use the
C ecosystem.

For such purposes, we now have self.clib_compiler. Nothing uses
self.compiler anymore as a result, and it has been removed.
2018-06-20 11:27:08 +00:00
Christoph Behle 5ef38d880f Add missing stubs to Compiler.
Added missing stubs to class Compiler for the methods:
  * compute_int
  * has_members
  * has_type
  * symbols_have_underscore_prefix
2018-06-18 07:52:15 +00:00
Christoph Behle 9e0397805e Use stub to report misuse of get_define
Instead of checking on the call site add a stub to Compiler which raises
an exception.
2018-06-18 07:52:15 +00:00
Nirbheek Chauhan 96b7fdb723 macos: Rewrite install_name for dependent built libraries on install
On macOS, we set the install_name for built libraries to
@rpath/libfoo.dylib, and when linking to the library, we set the RPATH
to its path in the build directory. This allows all built binaries to
be run as-is from the build directory (uninstalled).

However, on install, we have to strip all the RPATHs because they
point to the build directory, and we change the install_name of all
built libraries to the absolute path to the library. This causes the
install name in binaries to be out of date.

We now change that install name to point to the absolute path to each
built library after installation.

Fixes https://github.com/mesonbuild/meson/issues/3038
Fixes https://github.com/mesonbuild/meson/issues/3077

With this, the default workflow on macOS matches what everyone seems
to do, including Autotools and CMake. The next step is providing a way
for build files to override the install_name that is used after
installation for use with, f.ex., private libraries when combined with
the install_rpath: kwarg on targets.
2018-06-18 06:33:23 +00:00
Nirbheek Chauhan e3757e3d3c pkgconfig deps: Also resolve paths to shared libraries
This allows us to more aggressively de-dup them, and also sets RPATHs
to all libraries that are not in the system linker paths so that
binaries can be run uninstalled without any special steps.

These RPATHs will be wiped on install, so they do not affect
reproducible builds.

De-duping:
Fixes https://github.com/mesonbuild/meson/issues/2150
Fixes https://github.com/mesonbuild/meson/issues/2118
Fixes https://github.com/mesonbuild/meson/issues/3071

RPATHs:
Fixes https://github.com/mesonbuild/meson/issues/314
Fixes https://github.com/mesonbuild/meson/issues/2881

Also fixes the uninstalled usage portions of:
https://github.com/mesonbuild/meson/issues/3038
https://github.com/mesonbuild/meson/issues/3077
2018-06-18 06:33:23 +00:00
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