Commit Graph

241 Commits

Author SHA1 Message Date
pbl
198d4b83b9 add implib support for ArmclangCompiler (#4420) 2018-10-26 18:57:18 +03:00
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
f1546e289c add cpp_std support for MSVC 2018-10-22 19:14:00 +03:00
31e6b70434 Order rpaths so that internal ones come first. 2018-10-20 13:17:57 +03:00
4d7de6c122 Keep absolute rpaths to libraries outside the build dir. 2018-10-20 13:17:57 +03:00
c453400d59 Add 'b_pie' compiler option
On Android executables must be position independent, many
distributions enable it by default too for security reasons.
2018-10-20 00:47:27 +03:00
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
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
ce2eed32bc d: Allow static library to be passed with -L to dmd/ldc 2018-10-07 23:42:01 +03:00
18204b8ed6 Adding "compiler_type" flag to ARM compilers. 2018-10-07 19:21:26 +03:00
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
e6395c6f44 Merge pull request #4051 from GoaLitiuM/d-debug
D: Add conditional debug compilation flags
2018-10-02 21:49:29 +03:00
07800e29c9 msvc: Don't use /O3 with MSVC
MSVC doesn't support that option, and warns about ignoring an unknown
option.
2018-10-01 12:45:39 -07:00
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
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
8776dac773 Add conditional debug identifiers for D compilers, and enable for debug builds
Also includes parsing the highest integer level for debug and version.
2018-09-27 17:49:48 +03:00
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
cf58f56e16 linker flags --as-needed and --no-undefined aren't meaningful for PE
--as-needed controls ELF-specific functionality (the emission of DT_NEEDED
tags)

--no-undefined is effectively always on for PE/COFF, as the linkage model
always requires symbols to be defined

binutils ld silently ignores these flags for PE targets, but lld warns that
it's ignoring them, so just don't bother emitting them for PE targets.
2018-09-23 11:23:23 +03:00
25d51f583c Updating compilers.py to add functions - get_optimization_args, get_debug_args in ARMCC and ARMCLANG classes. 2018-09-21 23:31:40 +03:00
ce35122263 Fix setting -Doptimization breaking build
Closes #4206
2018-09-19 18:30:15 +03:00
94b5ea2aae ICC does not support -Og 2018-09-17 23:31:55 +03:00
115962e466 Abstract shared GCC/Clang/ICC methods in GnuLikeCompiler 2018-09-17 23:31:55 +03:00
c352434a7a Implement thread linker args for D compilers
D compilers are configured to have highest priority when chosing linker
for targets mixing C/C++/D code and before this change meson would fail
to configure gtest target that uses D library as a dependency.
2018-09-16 20:31:04 +03:00
8f16d0f3c9 Fix ICC on macOS 2018-09-16 18:27:19 +03:00
2b9fb36267 Fix GCC on macOS
* `common/40 has function` still fails due
  to alloca being a GCC builtin.
2018-09-16 18:27:19 +03:00
43268bfb79 D: Fix some compiler arguments not getting passed through properly 2018-09-16 14:58:50 +03:00
b9f229a494 Merge pull request #4175 from GoaLitiuM/d-archfixes
D: Improve target architecture handling
2018-09-16 14:40:55 +03:00
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
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
5b0ad0f8ad Refactor D target architecture handling
The stored architecture matches the same format accepted by dub.
2018-09-14 05:18:50 +03:00
de7c3cbbc5 Fix flake8 'imported but unused' reports
$ flake8 | grep F401
./mesonbuild/compilers/d.py:19:1: F401 '.compilers.GCC_CYGWIN' imported but unused
./test cases/unit/35 dist script/replacer.py:3:1: F401 'sys' imported but unused
2018-09-13 20:33:17 +03:00
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
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
644809fe59 Make sure static library files are passed properly to the linker 2018-09-06 05:18:08 +03:00
040dd03a7a Fix remaining soname and rpath issues on OSX 2018-09-06 05:18:08 +03:00
fd4c996a67 Remove translation of file paths
This would also pass all the source and object files to linker, which is not desirable.
2018-09-06 05:18:07 +03:00
d2483d4412 Refactor D argument translation function 2018-09-06 05:18:00 +03:00
6e160995b0 Improve D link argument handling 2018-09-06 03:57:45 +03:00
289c1bf919 D: Fix linking errors with static D libraries on Windows 2018-09-05 20:27:47 +03:00
5240b26fb8 D: Use the documented syntax for various arguments 2018-09-05 20:26:11 +03:00
9bcd498a2f Merge pull request #4084 from FFY00/pr-fix-dub-dependencies
dub: enhance dependency handling
2018-09-03 19:30:52 +03:00
3d86a24b55 Remove unnecessary -lquadmath from FORTRAN flags. 2018-09-02 18:25:09 +03:00
bead8287a5 Improve support for macOS dylib versioning
We now use the soversion to set compatibility_version and
current_version by default. This is the only sane thing we can do by
default because of the restrictions on the values that can be used for
compatibility and current version.

Users can override this value with the `darwin_versions:` kwarg, which
can be a single value or a two-element list of values. The first one
is the compatibility version and the second is the current version.

Fixes https://github.com/mesonbuild/meson/issues/3555
Fixes https://github.com/mesonbuild/meson/issues/1451
2018-08-29 15:51:23 -07:00
124cedde38 dub: enhance dependency handling
fixes #4032: meson now checks properly for the compiler used to compile dub dependencies

fixes #3568: applied the following patch https://paste.debian.net/1039317/

meson now adds flags for native dependencies required by dub modules

meson now checks for the D version implemented by the compiler used to build dub dependencies (execpt gdc which doesn't support this)
2018-08-29 20:22:01 +01:00
28c1f31d7e Make -std= fallback remapping more robust
* The current version matching logic is brittle
  with respect to Clang. LLVM and Apple Clang use
  slightly different but nowadays overlapping
  version ranges. Instead, we now just check whether
  the compiler supports the given `-std=` variant
  and try its respective fallback instead of
  testing version ranges.
2018-08-29 20:57:35 +03:00
cc37a66077 Deduplicate build-tree RPATHs on macOS
* Currently, RPATHs coming from dependencies and
  `build_rpath` provided by the user might contain
  the same path. Apple's `install_name` tool is
  allergic to providing the same argument twice
  when removing RPATHs:

    error: install_name_tool: "-delete_rpath /usr/lib" specified more than once
2018-08-28 23:26:08 -07:00
8dd2e42de3 CompilerArgs: -Wl,-lfoo is also a valid way to pass a library
Treat it the same as -lfoo by deduping and adding to --start/end-group

Reported at https://gitlab.gnome.org/GNOME/glib/issues/1496

We don't do any advanced transformation for MSVC or de-dup because
this is a very rare syntax.
2018-08-28 19:10:30 +03:00
1ffc8de5e8 Merge pull request #3981 from GoaLitiuM/d-win-fixes
Fix D support on Windows
2018-08-27 22:30:23 +03:00
23e6200c14 My bad. 2018-08-23 21:16:28 -07:00
79aec5f342 CompilerArgs: Allow calling to_native() multiple times
Add a keyword argument to to_native() to operate on a copy so that we
can call it multiple times instead of modifying the original compiler
args while iterating.

This is used in the unit test, and might be used in Meson at some
point too.
2018-08-23 19:16:02 -07:00