Commit Graph

374 Commits

Author SHA1 Message Date
Dylan Baker a55e3434c5 environment: Fix initialization of compilers that don't use a
_guess_linker method

Fixes #6448
2020-01-23 01:59:31 +02:00
Dylan Baker 255fa5a320 tests: Add a test case for finding ld 2020-01-22 23:39:33 +02:00
Dylan Baker 730a7b296f environment: Replace LD with <LANG>LD
The rust code is ugly, because rust is annoying. It doesn't invoke a
linker directly (unless that linker is link.exe or lld-link.exe),
instead it invokes the C compiler (gcc or clang usually) to do it's
linking. Meson doesn't have good abstractions for this, though we
probably should because some of the D compilers do the same thing.
Either that or we should just call the c compiler directly, like vala
does.

This changes the public interface for meson, which we don't do unless we
absolutely have to. In this case I think we need to do it. A fair number
of projects have already been using 'ld' in their cross/native files to
get the ld binary and call it directly in custom_targets or generators,
and we broke that. While we could hit this problem again names like
`c_ld` and `cpp_ld` are far less likely to cause collisions than `ld`.
Additionally this gives a way to set the linker on a per-compiler basis,
which is probably in itself very useful.

Fixes #6442
2020-01-22 23:39:33 +02:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Dylan Baker a8caf988c6 environment: Fix detection of icc on macOS
Which wouldn't call the function to detect c_args and friends.
2020-01-07 00:51:29 +02:00
Jussi Pakkanen 7ec3af95e5
Updated linker MR (#6407)
* environment: Fix passing always args to a number of less common linkers

These are mostly (oops xilink) proprietary linkers I can't use for
various reasons.

Fixes: #6332

* Add intelfix from scivision.

* Ifort fix from scivision.

* PGI fix from scivision.

* Cuda fix from scivision.

* Fix linker passing for armclang.
2020-01-06 16:49:34 +02:00
Dylan Baker 47dfe34c85 Consider compiler arguments in linker detection logic
If a user passes -fuse-ld=gold to gcc or clang, they expect that they'll
get ld.gold, not whatever the default is. Meson currently doesn't do
that, because it doesn't pass these arguments to the linker detection
logic. This patch fixes that. Another case that this is needed is with
clang's --target option

This is a bad solution, honestly, and it would be better to use $LD or a
cross/native file but this is needed for backwards compatability.

Fixes #6057
2019-12-12 10:57:27 -08:00
Dylan Baker 87766b3727 Allow setting <lang>_args before the compiler is detected
This is required to be able to pass compiler and linker arguments to the
methods that try to guess what linker to use.
2019-12-12 10:52:07 -08:00
Jussi Pakkanen 17dd9e5bff
Merge pull request #6207 from dcbaker/linker-option
Add a way to select the dynamic linker meson uses
2019-12-11 23:29:33 +02:00
Jussi Pakkanen 63bea704dd Clean stray .o file that LDC creates during tests. 2019-12-05 21:06:58 +02:00
Dylan Baker d856118006 environment: Fix selecting the linker with rustc 2019-12-03 13:08:42 -08:00
Dylan Baker 8091b4c744 Intel: Dump worthless Xild abstractions
This dumps xild on mac and linux. After a lot of reading and banging my
head I've discovered we (meson) don't care about xild, xild is only
useful if your invoke ld directly (not through icc/icpc) and you want to
do ipo/lto/wpo. Instead just make icc report what it's actually doing,
invoking ld or ld64 (for linux and mac respectively) directly. This
allows us to get -fuse-ld working on linux.
2019-12-03 13:08:42 -08:00
Dylan Baker 0ae911d893 environment: Add a special error case for getting GNU link.exe
Since I spent three days banging my head against this it seems
reasonable that other people might also run into this problem. It can
happen if you're trying to use microsoft's link.exe, but also have the
dmd bin directory at the tail of your %PATH%, among other reasons.
2019-12-02 16:39:06 -08:00
Dylan Baker ab5ea9e8b6 environment: unify platform detection logic
I noticed this while I was here, it's not much, just a small cleanup to
the platform detection logic.
2019-12-02 16:39:06 -08:00
Dylan Baker 8761ca7b7d environment: Remove duplicate argument from _guess_nix_linker
Since we pass the whole compiler class (as a type()) we don't need to
also pass it's LINKER_PREFIX attribute, we can just get it from the
type we're passing.
2019-12-02 16:39:06 -08:00
Dylan Baker ef9aeb188e Allow selecting the dynamic linker
This uses the normal meson mechanisms, an LD environment variable or via
cross/native files.

Fixes: #6057
2019-12-02 16:39:06 -08:00
Dylan Baker 5a83cb0d33 Fix detection of D linker in MSVC environments
Rather than trying to figure out if we're using MSVC based on
environment variables, then trying to get the C compiler and test some
attributes, get the C compiler and see if it's MSVC. This is much more
reliable and we were already doing it anyway.
2019-12-02 13:39:37 -08:00
Luca Bacci 2362bdbbf9 Fix regular expression for MSVC target arch detection
Make it work regardless of MSVC output language

Fixes #6128
See PR #6265
2019-11-30 21:52:58 +02:00
Eric Le Bihan 815563841a Fix cross-compilation of D programs
Since version 9.1, GCC provides support for the D programming language. Thus it
is easy to build a cross-compiler for D, such as aarch64-unknown-linux-gnu-gdc.

However to cross-compile a Meson project using D, using a cross build definition
such as the following is not enough:

```
[binaries]
d = '/path/to/aarch64-unknown-linux-gnu-gdc'
exe_wrapper = '/path/to/qemu-aarch64-static'

[properties]
needs_exe_wrapper = true

[host_machine]
system = 'linux'
cpu_family = 'aarch64'
cpu = 'cortex-a53'
endian = 'little'
```

Indeed, "exe_wrapper" is not be taken into account. Build will fail with:

```
Executables created by D compiler /path/to/aarch64-uknown-linux-gnu-gdc are not runnable.
```

This patch fixes this by reworking:

- detect_d_compiler() to properly get exe_wrapper and D compilers and detect the
one available.
- Dcompiler to properly handle exe_wrapper.
2019-11-19 16:32:12 +02:00
Jan Tojnar 3a050093a4 environment: Only check compiler basename for compiler name
Nix uses absolute paths to compilers in Nix store with Meson.
Those store paths contain a hash, which can contain short strings
like icl, resulting in incorrectly matching the compiler.

https://github.com/NixOS/nixpkgs/issues/73417#issuecomment-554077964
2019-11-16 21:30:36 +02:00
Luca Bacci ad20067ed2 Raise an exception if we cannot detect the MSVC compiler target architecture 2019-11-12 20:31:37 +02:00
Wolfgang Stöggl f037e7ef45 Fix typos found by codespell
- Typos were found by codespell v1.16.0
2019-11-06 09:55:30 -05:00
Jussi Pakkanen f5c8893281
Merge pull request #6123 from scivision/bugfix-fortran
bugfix: fortran compiler assertionerror from 0c22798
2019-11-02 23:35:38 +02:00
Aleksey Gurtovoy 48e6db89ab Ask Ninja to expand rsp files in compile_commands.json 2019-11-02 16:16:09 +02:00
Michael Hirsch, Ph.D 50225c14e2
fix PGI Windows 'ar' linker 2019-10-31 23:53:47 -04:00
Michael Hirsch, Ph.D 9c1bab67af
bugfix: fortran compiler assertionerror from 0c22798 2019-10-31 23:22:37 -04:00
GoaLitiuM 4f83c47880 d: Prefer MSVC and LLVM linker over optlink when available
The optlink linker is slowly getting phased out now since DMD ships with the LLVM linker, so it can be used when Visual Studio is not installed.
2019-10-21 16:22:39 +03:00
Matt Turner 7685d49b04 environment: Add missing space between words 2019-10-15 21:47:58 +03:00
Dylan Baker b268327166 environment: Fix detection of xild with icc 2019-10-14 08:26:57 -07:00
Michael Hirsch, Ph.D 17f766105f intel-cl: correct argument order 2019-10-10 10:00:28 -07:00
Michael Hirsch, Ph.D 508662f277 BUGFIX: environment.py CudaCompiler missing info arg
fixes regression for systems with nvcc installed--perhaps why not previously caught on CI.
Just a simple typo--missing a positional argument to CudaCompiler()

0c22798b1a is the first bad commit File
  "meson\mesonbuild\environment.py", line 1066, in detect_cuda_compiler
    return CudaCompiler(ccache + compiler, version, for_machine, is_cross, exe_wrap, host_compiler=cpp_compiler,
    linker=linker)# Please enter the commit message for your changes. Lines starting
TypeError: __init__() missing 1 required positional argument: 'info'# with '#' will be ignored, and an empty message aborts the commit.
2019-10-10 10:00:28 -07:00
Jussi Pakkanen b6af3f3810
Merge pull request #5833 from dcbaker/remove-compiler-type
Remove compiler type
2019-10-09 19:53:56 +03:00
Dylan Baker 65fc4149c5 environment: Detect sun4u and sun4v as sparc64
Solaris returns these values.

Fixes #6006
2019-10-09 19:49:57 +03:00
Dylan Baker afbed79baa compilers: replace uses of mesonlib.is_<os>() with self.info.is_<os>()
Since these are cross compilation safe, while the former is not.
2019-10-07 12:08:20 -07:00
Dylan Baker 0c22798b1a compilers: replace CompilerType with MachineInfo
Now that the linkers are split out of the compilers this enum is
only used to know what platform we're compiling for. Which is
what the MachineInfo class is for
2019-10-07 12:08:20 -07:00
Dylan Baker ff4a17dbef compilers: Add a specific type for AppleClangC
This allows us to detect use classes rather than methods to determine
what C standards are available.
2019-10-07 10:44:56 -07:00
Jussi Pakkanen 0b4d1e8afd Cross build is defined by the existance of a cross file. 2019-10-06 17:46:16 +03:00
Olexa Bilaniuk 2057ffccc3 Correct obviously-wrong test for gold linker. 2019-09-30 20:54:08 +03:00
Ting-Wei Lan 24bd029437 environment: LLVM 9 is now a stable release 2019-09-29 00:11:16 +08:00
Ting-Wei Lan 0390b673f1 Find clang-format with alternative names
This is similar to what we currently do for scan-build except there is
no environment variable to choose a specific clang-format to run. If an
environment variable is needed for better control, we can add it later.
2019-09-29 00:11:15 +08:00
Ting-Wei Lan 08ce1fb541 Move the list of LLVM version suffixes to a common place
Both scan-build and llvm-config need the same list of LLVM version
suffixes. It is better to keep the list at a common place instead of
having several copies in different files, which is likely to become
out-of-sync when the list is updated.
2019-09-29 00:11:13 +08:00
Andrei Alexeyev 3fd460bce7 Fix GNU-like LLD being misdetected as MSVC-like LLD
Affects the latest version of the llvm-mingw toolchain
2019-09-27 08:20:07 -07:00
Ting-Wei Lan 74d5136e59 environment: Don't make special case for scan-build on Linux
Versioning of executables is not related to the operating system kernel.
It is possible for a Linux distribution to support multiple versions of
LLVM in a way similar to FreeBSD. For example, on Debian, you can use
'apt install clang-tools-7' to install the versioned 'scan-build-7'
executable without bringing the unversioned 'scan-build' into the
environment. Therefore, we should not skip the version list on Linux.
It also makes it consistent with the behavior of llvm dependency, which
does not change the search list depending on the operating system.

This commit also fixes the version suffix for Debian. Debian stops using
the minor version number on the executable after version 7, so it should
be 'scan-build-7', not 'scan-build-7.0'.

This is a follow-up of https://github.com/mesonbuild/meson/pull/5918.
2019-09-25 22:52:19 +03:00
Aleksey Gurtovoy 6ac5db50c9 CUDA support on Windows 2019-09-24 14:22:20 -07:00
Gabriel Ganne e7197895b2 uniform scan-build detection process
Detect scan-build the same way when trying to launch it and when
generating the target.
The detection method is:
  1. look within SCANBUILD env variable
  2. shutil.which('scan-build')
  3. *on non-linux platforms only*: go through all the possible
     name candidates and test them individually.

The third step is added following this comment
https://github.com/mesonbuild/meson/pull/5857#issuecomment-528305788
However, going through a list of all the possible candidates is neither
easily maintainable nor performant, and is therefore skipped on
platforms that should not require such a step (currently, only Linux
platforms).

This is a follow-up to the issue raised by @lantw44 during PR:
https://github.com/mesonbuild/meson/pull/5857
2019-09-14 05:51:36 +03:00
Alan Coopersmith 3d74987c81 compilers: Recognize Solaris 11.4 linker
Solaris 11.3 & earlier sent the --version output to stderr, but
Solaris 11.4 moved it to stdout in an attempt to be more compatible
with the GNU tools, so look for it in both streams of output.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-09-10 22:43:34 -07:00
Andrei Alexeyev d768a76ab2 Workaround for mingw-llvm linker (lld) misdetection
llvm-mingw uses a wrapper script to inject (among other things) a
-target argument into the clang command, which breaks -Wl,--version.
This confuses Meson into thinking the linker is some unknown version of
Apple ld, which breaks builds.

This patch makes it detect and recover from the issue.

Fixes #5910
2019-09-10 13:23:22 -07:00
Dylan Baker 15f8165bde environment: merge successive is_windows blocks 2019-09-09 21:22:26 -07:00
Dylan Baker 52aba19b17 environment: gcc/g++ and clang/clang++ are valid objc/objc++ compilers to try 2019-09-09 21:22:26 -07:00
Alan Coopersmith e5a67b4248 If ar is unrecognized, try gar for GNU ar
Needed on Solaris, where native ar doesn't recognize all the flags
that meson uses, but GNU ar does.
2019-09-09 21:22:26 -07:00