Commit Graph

206 Commits

Author SHA1 Message Date
Dylan Baker 63f4f9481e Add new compiler.get_argument_syntax method
Some compilers try very had to pretend they're another compiler (ICC
pretends to be GCC and Linux and MacOS, and MSVC on windows), Clang
behaves much like GCC, but now also has clang-cl, which behaves like MSVC.

This method provides an easy way to determine whether testing for MSVC
like arguments `/w1234` or gcc like arguments `-Wfoo` are likely to
succeed, without having to check for dozens of compilers and the host
operating system, (as you would otherwise have to do with ICC).
2018-11-03 18:10:36 +02:00
Josh Gao edda80cc75 Generalize gnulike-targeting-windows checks.
Replace several checks against GCC_MINGW or (GCC_MINGW, GCC_CYGWIN) with
is_windows_compiler instead, so that clang and other gcc-like compilers
using MinGW work appropriately with vs_module_defs, c_winlibs, and
cpp_winlibs.

Fixes #4434.
2018-10-30 20:25:32 +02:00
Marvin Scholz 2256e6314b compilers/c: Fix allow undefined link arg for PE/COFF
For PE/COFF it is not possible to allow undefined symbols, so do not
try to use the option to do so.

While gcc ld silently ignores it, this is not the case for the llvm
linker.

Fix #4415
2018-10-25 19:30:42 +03:00
David Seifert a28eddb822 Use relative build-tree RPATHs on macOS
* This helps with reproducibility on macOS in the same way
  `$ORIGIN` improves reproducibility on Linux-like systems.
* This makes the build-tree more resilient to users injecting
  rpaths via `LDFLAGS`. Currently Meson on macOS crashes when
  a build-tree rpath and a user-provided `-Wl,-rpath` in
  LDFLAGS collide, leading to `install_name_tool` failures.
  While this still does not solve the root cause, it makes
  the occurrence much less likely, as users will generally
  pass absolute `-Wl,-rpath` arguments into Meson.
2018-10-14 23:56:59 +03:00
gsobala 0ea626b89d Added .so to list possible darwin dynamic library suffixes (#4364)
Occasionally Darwin libraries can be .so rather than .dylib e.g. tensorflow_cc.so
tensorflow_cc is a c++ API for Tensorflow (https://github.com/FloopCZ/tensorflow_cc)
which was primarily written for Linux but is also compilable on Darwin. Possibly
through laziness, possibly just to have consistent filenames, the developers did not
opt to change the suffix from the Linux default when this is compiled on Darwin.

Also, the Darwin linker will find libraries with a .so suffix if they are
in its path. find_library() needs to match the linker behaviour.
2018-10-13 07:00:06 -07:00
Mohammed Amer Khalidi 18204b8ed6 Adding "compiler_type" flag to ARM compilers. 2018-10-07 19:21:26 +03:00
Bruce Richardson 386e5b876f Verify library directories as either 32-bit or 64-bit
In get_library_dirs() we are trusting the compiler to return a correct
list of directories to search for libraries, based on whether or not
we are compiling 64-bit or 32-bit. Unfortunately, this is often not the
case, as 64-bit libraries often are returned when compiling with -m32 on
a 64-bit OS.

Since system directories do not contain a mix of libraries, the solution
here is to check each directory, by picking a .so file in the directory
and checking whether its 64-bit or 32-bit. If we can't determine if we
want 32-bit or 64-bit, just skip the checks and assume the directory is
good.
2018-10-03 01:01:10 +03:00
Dylan Baker 6cf7d2492b compilers/c: don't return -pthread for MacOS with any compiler
With GCC, Clang, or ICC, and for C++

Fixes #2628
2018-10-01 12:34:46 -07:00
Marvin Scholz 843b0b1d50 compilers: Do not use -pthread with clang for darwin
Using the -pthread argument is not needed with clang when compiling for
darwin, and it results in the warning:

  warning: argument unused during compilation: '-pthread'
2018-09-28 12:54:10 -07:00
Martin Storsjö 48b6520764 Don't add rpath linker flags when building for MinGW
GNU binutils ld silently ignores -rpath flags when targeting windows
(and it is already commented within ninjabackend.py that rpath as
concept doesn't exist on windows), and build_rpath_args in
VisualStudioCCompiler also returns an empty array. Therefore skip
this flag altogether.

This fixes linking with lld in MinGW mode, which doesn't support the
rpath flag.
2018-09-25 02:43:19 +03:00
David Seifert 115962e466 Abstract shared GCC/Clang/ICC methods in GnuLikeCompiler 2018-09-17 23:31:55 +03:00
David Seifert 8f16d0f3c9 Fix ICC on macOS 2018-09-16 18:27:19 +03:00
David Seifert 0e89b03be6 Do not use relative RPATHs on macOS with ICC/GCC
* Currently, absolute rpaths on macOS are only used
  with Clang, which breaks Meson builds when using
  ICC or GCC from Homebrew or MacPorts.
2018-09-16 00:47:32 +03:00
David Seifert 69ec001b06 Use enum instead of `int` for compiler variants
* Enums are strongly typed and make the whole
  `gcc_type`/`clang_type`/`icc_type` distinction
  redundant.
* Enums also allow extending via member functions,
  which makes the code more generalisable.
2018-09-16 00:47:32 +03:00
Nirbheek Chauhan 1af704a509 Sprinkle functools.lru_cache() in a few more places
This improves the backend generation time for gst-build from 7.4s to
6.6s. This is probably all the low-hanging fruit we can get, further
improvements will probably require refactoring, moving to pathlib.Path
or reimplementing CompilerArgs:

   222045    0.551    0.000    1.324    0.000 compilers.py:666(__iadd__)
     3691    0.230    0.000    0.885    0.000 ninjabackend.py:99(write)
   233560    0.441    0.000    0.701    0.000 posixpath.py:75(join)
      882    0.141    0.000    0.636    0.001 backends.py:509(generate_basic_compiler_args)
   256301    0.248    0.000    0.576    0.000 compilers.py:562(_can_dedup)
    37369    0.035    0.000    0.466    0.000 compilers.py:652(extend_direct)
    74650    0.067    0.000    0.431    0.000 compilers.py:641(append_direct)
   158153    0.089    0.000    0.405    0.000 ninjabackend.py:129(<lambda>)
      845    0.064    0.000    0.391    0.000 ninjabackend.py:279(get_target_generated_sources)
    58161    0.070    0.000    0.317    0.000 backends.py:217(get_target_generated_dir)
   216825    0.175    0.000    0.275    0.000 ninjabackend.py:48(ninja_quote)
      845    0.058    0.000    0.255    0.000 ninjabackend.py:2289(guess_external_link_dependencies)
      845    0.068    0.000    0.239    0.000 backends.py:793(get_custom_target_provided_libraries)
    52101    0.030    0.000    0.237    0.000 compilers.py:716(append)
  1319326    0.231    0.000    0.231    0.000 {built-in method builtins.isinstance}
  1189117    0.229    0.000    0.229    0.000 {method 'startswith' of 'str' objects}
     3235    0.102    0.000    0.228    0.000 compilers.py:614(to_native)

Note: there are 845 build targets.
2018-09-11 10:19:42 -07:00
Dylan Baker 51e9db370a Add method to check for C/C++ function attributes
It's fairly common on Linux and *BSD platforms to check for these
attributes existence, so it makes sense to me to have this checking
build into meson itself. Autotools also has a builtin for handling
these, and by building them in we can short circuit cases that we know
that these don't exist (MSVC).

Additionally this adds support for two common MSVC __declspec
attributes, dllimport and dllexport. This implements the declspec
version (even though GCC has an __attribute__ version that both it and
clang support), since GCC and Clang support the MSVC version as well.
Thus it seems reasonable to assume that most projects will use the
__declspec version over teh __attribute__ version.
2018-09-07 11:52:15 -07:00
Ole André Vadla Ravnås 6cd71a8033 compilers: Reduce sizes of MSVC linked binaries
- For optimization=s add /O1: Use Maximum Optimization (Favor Size),
  and remove /Os as it's implied by /O1.
- Because we add /O1, this implies /Gy, i.e. Function-Level Linking, so
  unused code can be omitted.
- Add /Gw: Optimize Global Data, so unused data can be omitted.

With buildtype=minsize on x86 this reduces the size of a statically
linked Vala compiler binary from 5 MB down to just 1.87 MB.
2018-08-22 22:58:13 +03:00
Nirbheek Chauhan bb5f2ca3da find_library: Allow undefined symbols while linking
Shared libraries may not always be linkable without the use of other
libraries, so don't make it a linker error.
2018-08-22 12:24:43 -07:00
Bruce Richardson 8c9296e8e6 find_library: Use _build_wrapper to get library dirs
This means that we will take into account all the flags set in the
cross file when fetching the list of library dirs, which means we
won't incorrectly look for 64-bit libraries when building for 32-bit.

Signed-off-by: Nirbheek Chauhan <nirbheek@centricular.com>

Closes https://github.com/mesonbuild/meson/issues/3881
2018-08-22 12:24:43 -07:00
Jussi Pakkanen d83f77109a
Convert buildtype to optimization and debug options (#3489) 2018-08-18 20:39:47 +03:00
Jon Turney 94f09a8454 Explicitly set the Windows subsystem for ninja/VisualC 2018-08-15 06:17:58 -07: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
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
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
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
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 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
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 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 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 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
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
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 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 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
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
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
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
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 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
makise-homura 546f81e0f9 Fixed lchmod detection for lcc C/C++ compilers 2018-03-21 16:42:15 +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
Nirbheek Chauhan 8842839bb4 pkgconfig deps: Warn when a static library isn't found
A hard error makes this feature useless in most cases since a static
library usually won't be found for every library, particularly system
libraries like -lm. Instead, warn so the user can provide the static
library if they wish.

This feature will be expanded and made more extensible and more usable
in the future.

Closes https://github.com/mesonbuild/meson/issues/2785
2018-02-20 19:26:51 +02:00
Jon Turney 0774f319e8 Don't use --export-dynamic on Cygwin
After PR #2662, running test case common/125 shared module/ on Cygwin gets
me:

$ ninja -C _build
ninja: Entering directory `_build'
[7/7] Linking target prog.exe.
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld: warning: --export-dynamic is not supported for PE+ targets, did you mean --export-all-symbols?

Also, fix doc for correct version of first apperance.

Future work: Notwithstanding the hint that ld gives, these options are not
equivalent, and it's not clear we should be using it here:
--export-all-symbols is the default behaviour, and if the exports are
restricted by explicit annotations or a .def file, this option might be
overriding that...
2018-02-08 23:51:06 +02:00
Aleksey Filippov 2cf85ae16f Use os.path: basename() and dirname() instead of split()
According to Python documentation[1] dirname and basename
are defined as follows:
    os.path.dirname() = os.path.split()[0]
    os.path.basename() = os.path.split()[1]
For the purpose of better readability split() is replaced
by appropriate function if only one part of returned tuple
is used.

[1]: https://docs.python.org/3/library/os.path.html#os.path.split
2018-01-30 07:08:22 +11:00
Ting-Wei Lan ec50073644 Print warning when linker arguments are passed to has_argument
has_argument and other similar methods of compiler objects only support
checking compiler flags. If they are used to check linker flags, the
results are very likely to be wrong and developers should be warned.
2018-01-30 06:34:34 +11:00
Nikita Churaev de8018a17d Add `export_dynamic` argument to `executable`. (#2662) 2018-01-09 21:36:13 +02:00
Jussi Pakkanen b6dd50db31
Merge pull request #2791 from behlec/compiler-version
Add more version information to compiler
2017-12-20 20:42:01 +02:00
Christoph Behle c772841af7 Fix: More information for C compilers.
Add full version to gnu and icc C compiler.
2017-12-19 19:58:19 +01:00
Jussi Pakkanen 8eaa0a2732 Use -MD instead of -MMD for reliability. 2017-12-18 21:19:18 +02:00
Christoph Behle c6acf75617 More version information for compilers.
See issue #2762
Adds full_version to class Compiler. If set full_version will be printed
additionally.
Added support for CCompiler and CPPCompiler
Added support for gcc/g++, clang/clang++, icc.
2017-12-16 14:52:08 +01:00
Ismael González d946b03496 Use LC_ALL=C in CCompiler.get_library_dirs
Use LC_ALL=C in CCompiler.get_library_dirs to fix wrong results with non
English locales.
2017-12-13 21:30:22 +02:00
Dylan Baker fc547ad05e haiku: do not add pthread arguments
Haiku has pthreads, but they are part of the standard C library, and do
not need either special compiler or linker flags.
2017-12-07 09:35:12 -08:00
Jussi Pakkanen 4ae0cadb7f Renamed UserStringArrayOption to UserArrayOption for short. 2017-12-07 00:00:34 +02:00
Nirbheek Chauhan 45dbc0d30e find_library: Prefer .dll.a and .lib over .dll for shared
We can't know if the .lib is a static or import library, but that's
a problem in general too. The only way to figure out if a specific
file is an import or a static library is to dump its symbols and check
if it starts with __imp or not.

Even then, some libs are hybrid import and static, i.e., they contain
references to DLLs for some symbols and also provide implementations
for other symbols so this is a difficult problem.

Closes https://github.com/mesonbuild/meson/issues/2659
2017-12-03 10:06:11 +05:30
Jussi Pakkanen fa6f01d096 Use absolute paths for rpaths on OSX. 2017-11-26 17:34:01 +02:00
Jussi Pakkanen 655137a74b Add headerpad linker argument on OSX. 2017-11-26 17:34:01 +02:00
Nirbheek Chauhan d2a250412c compilers: Improve manual library searching
We can now specify the library type we want to search for, and whether
we want to prefer static libraries over shared ones or the other way
around. This functionality is not exposed to build files yet.
2017-11-11 23:06:48 +05:30
Niklas Claesson 09ccd0eeaa C/C++: Get default include dirs from compilers 2017-10-01 18:35:33 +02:00
Niklas Claesson 488e57332f VisualC: Add support for msvc toolset version 2017-10-01 18:35:33 +02:00
Jussi Pakkanen cf6693a4eb Linker flag for Windows GUI applications was missing on MSVC. 2017-09-26 21:46:32 +03:00
Jussi Pakkanen bea6b1a6f6 Merge pull request #2187 from centricular/fix-pcap-dependency
Fix pcap dependency, str.strip() now takes an argument, add cc.get_return_value()
2017-09-22 22:04:18 +03:00
Luke Shumaker bb25260f00 flake8: Perform suggested whitespace/formatting changes
This only touches newlines, spaces, and (occaisionally) commas.  Anything
else is left for another commit.
2017-09-21 11:59:03 -04:00
Nirbheek Chauhan 59473e9ed7 Add a new compiler method: get_return_value()
This method accepts a single function that takes no arguments and
returns a single value which can be a value that can be cast to
a 64-bit signed integer, or a string, and returns that value.

Mostly useful for running foolib_version() functions that return the
currently-available version of libraries.
2017-09-20 13:36:42 +05:30
Alexis Jeandet e553d0807b Last round with listify function refactoring.
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
2017-09-18 22:25:34 +02:00
Gabríel Arthúr Pétursson 0ad448f890 Pass -fpch-preprocess to GCC when precompiled headers are used
CCache requires this flag when building with precompiled headers.
Without it, the preprocessor fails and CCache fallbacks to running the
real compiler.

Users still need to set 'sloppiness' to 'pch_defines,time_macros' in
their ccache.conf file for CCache to cache builds that use precompiled
headers. See the CCache manual for more info:

	https://ccache.samba.org/manual.html#_precompiled_headers
2017-08-13 21:24:28 +03:00
Jussi Pakkanen 0ab9f23061 Add thread flags to checks if needed. Closes #2106. 2017-08-01 19:09:07 -04:00
Nirbheek Chauhan de2d59cc27 find_library: Ignore libs on MSVC properly
In addition to filtering libs out while generating the command-line, we
must also filter them out in find_library() otherwise these libs will be
detected as "found" on Windows with MSVC.

Closes https://github.com/mesonbuild/meson/issues/1509
2017-07-23 02:12:00 +03:00
Jussi Pakkanen 2269b7f60b Add build_rpath as new property allowing people to specify rpath entries that are used in the build tree but will be removed on install. 2017-07-21 19:40:54 +03:00
Jussi Pakkanen ce77fb89b9 Renamed test case number to avoid dupes. 2017-07-17 19:53:00 +03:00
Jussi Pakkanen 181510bd6e Fix checks on MinGW and VS2010. 2017-07-17 19:19:24 +03:00
Jussi Pakkanen 8396c4f3e6 Added VS support to simd detector. 2017-07-17 19:15:04 +03:00
Guillaume Poirier-Morency fab5634916 Add 'Compiler.get_display_language'
Use this when we print language-related information to the console and
via the Ninja backend.
2017-06-26 14:15:44 -04:00
Alistair Thomas 117f4ab8b5 Split out languages from compilers.py 2017-06-23 00:42:41 +01:00