Commit Graph

218 Commits

Author SHA1 Message Date
David Seifert 8f16d0f3c9 Fix ICC on macOS 2018-09-16 18:27:19 +03:00
David Seifert 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
GoaLitiuM 43268bfb79 D: Fix some compiler arguments not getting passed through properly 2018-09-16 14:58:50 +03:00
Jussi Pakkanen b9f229a494
Merge pull request #4175 from GoaLitiuM/d-archfixes
D: Improve target architecture handling
2018-09-16 14:40:55 +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
GoaLitiuM 5b0ad0f8ad Refactor D target architecture handling
The stored architecture matches the same format accepted by dub.
2018-09-14 05:18:50 +03:00
Jon Turney 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
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
GoaLitiuM 644809fe59 Make sure static library files are passed properly to the linker 2018-09-06 05:18:08 +03:00
GoaLitiuM 040dd03a7a Fix remaining soname and rpath issues on OSX 2018-09-06 05:18:08 +03:00
GoaLitiuM 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
GoaLitiuM d2483d4412 Refactor D argument translation function 2018-09-06 05:18:00 +03:00
GoaLitiuM 6e160995b0 Improve D link argument handling 2018-09-06 03:57:45 +03:00
GoaLitiuM 289c1bf919 D: Fix linking errors with static D libraries on Windows 2018-09-05 20:27:47 +03:00
GoaLitiuM 5240b26fb8 D: Use the documented syntax for various arguments 2018-09-05 20:26:11 +03:00
Jussi Pakkanen 9bcd498a2f
Merge pull request #4084 from FFY00/pr-fix-dub-dependencies
dub: enhance dependency handling
2018-09-03 19:30:52 +03:00
Jussi Pakkanen 3d86a24b55 Remove unnecessary -lquadmath from FORTRAN flags. 2018-09-02 18:25:09 +03:00
Nirbheek Chauhan 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
FFY00 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
David Seifert 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
David Seifert 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
Nirbheek Chauhan 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
Jussi Pakkanen 1ffc8de5e8
Merge pull request #3981 from GoaLitiuM/d-win-fixes
Fix D support on Windows
2018-08-27 22:30:23 +03:00
Jussi Pakkanen 23e6200c14 My bad. 2018-08-23 21:16:28 -07:00
Nirbheek Chauhan 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
Ole André Vadla Ravnås a7e6c1aaa4 compilers: Handle dupes in the --start/end-group logic
The index calculated through `self.index()` may find the same flag
earlier in the list and end up putting `--end-group` in the wrong spot.
2018-08-23 19:16:02 -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
Xavier Claessens 576f3bb1bf UserArrayOption: Allow duplicates when used as <lang>_args option
Closes: #4021.
2018-08-20 16:16:38 -04:00
GoaLitiuM fd2c3b4c77 Handle proper linking of MSVC runtime libraries
DMD expects mscrtlib arguments while compiling, whereas LDC2 expects these while linking.
2018-08-20 22:27:31 +03:00
GoaLitiuM b208cbda81 Remove optimization related arguments from buildtype args, inline release builds
Dub enables inlining by default for release builds, so meson should do it as well.
2018-08-20 22:27:31 +03:00
GoaLitiuM 4a1d64cb6c Fix import libraries and static library naming 2018-08-20 22:27:31 +03:00
GoaLitiuM 7ab938d9af Ignore unix related compiler arguments on Windows 2018-08-20 22:27:31 +03:00
GoaLitiuM 79f05b189a Follow target platform defined in MSVC environment for Windows D compilation 2018-08-20 22:27:31 +03:00
David Seifert e0120b4586 Remap -std=c++14 dialect names for older compilers
* GCC 4.8 and Clang 3.2, 3.3, 3.4 only understand
  `-std={c,gnu}++1y` for enabling C++14 dialects.
  GCC 4.8 is especially important as it is the basis
  of RHEL/CentOS 7.
2018-08-20 20:26:18 +03:00
GoaLitiuM e677f2f552 Pass -install-name arguments to linker 2018-08-20 20:25:25 +03:00
GoaLitiuM c2a872c4fc Fix D soname arguments for Windows and OSX 2018-08-20 20:25:25 +03:00
GoaLitiuM 12d5c6114e Fix wrong DMD optimization levels 2018-08-20 19:20:29 +03:00
Jussi Pakkanen d83f77109a
Convert buildtype to optimization and debug options (#3489) 2018-08-18 20:39:47 +03:00
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