Commit Graph

151 Commits

Author SHA1 Message Date
John Ericson 19f81d3e33 Never access environment.properties downstream
Instead use coredata.compiler_options.<machine>. This brings the cross
and native code paths closer together, since both now use that.

Command line options are interpreted just as before, for backwards
compatibility. This does introduce some funny conditionals. In the
future, I'd like to change the interpretation of command line options so

 - The logic is cross-agnostic, i.e. there are no conditions affected by
   `is_cross_build()`.

 - Compiler args for both the build and host machines can always be
   controlled by the command line.

 - Compiler args for both machines can always be controlled separately.
2019-02-02 13:59:14 -05:00
Michael Hirsch, Ph.D 4e31ca3abe correct naming to CudaCompiler, pep8 2019-01-29 22:06:11 +02:00
Michael Hirsch, Ph.D 8636f31d9c BUGFIX: broken/missing Fortran code/unit tests 2019-01-27 20:57:21 +02:00
Jussi Pakkanen e1b50309df All the fixes needed to make work against current master. 2019-01-21 23:59:20 +02:00
Beau Johnston 54b6afa675 added cuda compiler 2019-01-21 23:35:38 +02:00
Michael Hirsch, Ph.D 72486afd08 Add PGI C and C++ compilers (#4803) 2019-01-21 20:09:36 +02:00
Michael Hirsch, Ph.D 9bb21be59b
FlangFortranCompiler inherit ClangCompiler 2019-01-16 17:06:44 -05:00
Michael Hirsch, Ph.D 9a318d3d5a
better handle link args: PGI and Flang
correct flang, pgi options
2019-01-16 17:06:44 -05:00
Michael Hirsch, Ph.D b40c1af900
Flang Fortran compiler added. 2019-01-16 17:06:43 -05:00
Michael Hirsch, Ph.D fff88b354a restore PGI compile functioning 2019-01-15 20:27:31 +02:00
Daniel Mensinger 9742927903
Absolute path generation refactoring 2019-01-06 12:19:32 +01:00
John Ericson 2b22576fb6 Remove cross_info; cross file is parsed up front and discarded 2019-01-02 16:22:47 -05:00
Jussi Pakkanen 6c76ac8017 Handle strings in cross file args. Closes #4671. 2019-01-02 22:28:22 +02:00
Jussi Pakkanen c220816350
Merge pull request #4573 from jon-turney/msys2-clang
More clang for Windows support
2018-12-21 00:01:31 +02:00
Dylan Baker b335ca2818 compilers/icc: Add even more diag-errors to actually error on
This is a classy compiler.
2018-12-16 16:42:25 +02:00
Jon Turney 541307a426
Windows clang supports `-mwindows` to set subsystem
Promote get_gui_app_args from class GnuCompiler to GnuLikeCompiler
2018-12-09 20:40:24 +00:00
Martin Storsjö 05e75ab3e7 Reinstate "compilers/c: Fix allow undefined link arg for PE/COFF"
This reinstates 2256e6314b, which was
lost in refactoring in 9f9cfd2139.
2018-12-09 16:24:58 +02:00
Jussi Pakkanen c44a5a1aec Deduplicate export-dynamic and pthread. Closes #4567. 2018-12-06 16:20:54 +02:00
Jussi Pakkanen 2c91ca3d6a Remove linkerlike args from compile checks. Closes #4542. 2018-11-27 22:17:38 +02:00
Dylan Baker 9f9cfd2139 compilers: Move get_allow_undefined_link_args to Compiler
This allows each implementation (gnu-like) and msvc to be implemented in
their respective classes rather than through an if tree in the CCompiler
class. This is cleaner abstraction and allows us to clean up the Fortran
compiler, which was calling CCompiler bound methods without an instance.
2018-11-15 18:42:25 -08:00
Dylan Baker a480de1cb5 compilers: ICC should error when an unknown __attribute__ is tested 2018-11-15 18:42:25 -08:00
Dylan Baker f46adb44bf compilers: Enable PGO for ICC
ICC doesn't use the same -fprofile-generate/-fprofile-use that GCC and
Clang use, instead it has -prof-gen and -prof-use. I've gone ahead and
added the threadsafe option to -prof-gen, as meson currently doesn't
have a way to specify that level of granularity and GCC and Clang's
profiles are threadsafe.
2018-11-15 18:42:25 -08:00
Dylan Baker 28fd725d61 compilers: fix compiler.compile for Intel Compilers
has_arguments is the wrong thing to fix, since all checks that require
compiler options are based on compiles, it's the right thing to modify.
2018-11-15 18:42:25 -08:00
Dylan Baker 484fca9866 compilers: Fix the set of features that ICC exposes 2018-11-15 18:34:12 -08:00
Dylan Baker de175aac00 compilers: Use keyword only arguments for compiler interfaces
Because we need to inherit them in some cases, and python's
keyword-or-positional arguments make this really painful, especially
with inheritance. They do this in two ways:

1) If you want to intercept the arguments you need to check for both a
   keyword and a positional argument, because you could get either. Then
   you need to make sure that you only pass one of those down to the
   next layer.

2) After you do that, if the layer below you decides to do the same
   thing, but uses the other form (you used keyword by the lower level
   uses positional or vice versa), then you'll get a TypeError since two
   layers down got the argument as both a positional and a keyword.

All of this is bad. Fortunately python 3.x provides a mechanism to solve
this, keyword only arguments. These arguments cannot be based
positionally, the interpreter will give us an error in that case.

I have made a best effort to do this correctly, and I've verified it
with GCC, Clang, ICC, and MSVC, but there are other compilers like Arm
and Elbrus that I don't have access to.
2018-11-13 00:40:13 +02:00
Phillip Cao 76333d2a1e Add prefix option for link args 2018-11-08 00:02:24 +13:00
Phillip Cao 68c83cb213 Add support for Renesas CC-RX toolchain 2018-11-08 00:02:22 +13:00
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 beb1f00f3b Hoist gen_vs_module_defs_args from Gnu to GnuLike.
Support vs_module_defs when cross-compiling to Windows with clang.

Fixes #4434.
2018-10-30 20:25:32 +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
Jan Alexander Steffens (heftig) e4da09b8f9 get_base_compile_args: Add -fprofile-correction to -fprofile-use
This allows using the imperfect profiles generated by multithreaded
programs. Without the argument, GCC fails to load them.

Clang just ignores the argument AFAICT.

Fixes https://github.com/mesonbuild/meson/issues/2159
2018-10-28 19:20:31 +02:00
pbl 198d4b83b9 add implib support for ArmclangCompiler (#4420) 2018-10-26 18:57:18 +03:00
Jussi Pakkanen 31e6b70434 Order rpaths so that internal ones come first. 2018-10-20 13:17:57 +03:00
Jussi Pakkanen 4d7de6c122 Keep absolute rpaths to libraries outside the build dir. 2018-10-20 13:17:57 +03:00
Xavier Claessens 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
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
Mohammed Amer Khalidi 18204b8ed6 Adding "compiler_type" flag to ARM compilers. 2018-10-07 19:21:26 +03:00
Martin Storsjö 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
Jon Turney 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
Mohammed Amer Khalidi 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
David Seifert ce35122263 Fix setting `-Doptimization` breaking build
Closes #4206
2018-09-19 18:30:15 +03:00
David Seifert 94b5ea2aae ICC does not support `-Og` 2018-09-17 23:31:55 +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 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
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
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
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