Commit Graph

104 Commits

Author SHA1 Message Date
Jussi Pakkanen 3e6fbde94c Add thinlto support. Closes #7493. 2020-11-08 16:00:05 +02:00
Roman Bolshakov 30a102d9a3 linkers: Drop -pie on macOS
Projects that specify b_pie=true clutter build logs with the warning:

  clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]

No option is needed to produce PIE binaries because ld64 is making PIE
executables on 10.7 and above by default, as documented in ld(1).

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
2020-10-04 20:16:49 +03:00
Dylan Baker be99d00e95 linkers: Fix Xilink constructor 2020-10-01 15:06:10 -07:00
Dylan Baker 682d22129c compilers: Tell mypy that the compiler mixins are just that
We do this by making the mixins inherit the Compiler class only when
mypy is examining the code (using some clever inheritance shenanigans).
This caught a bunch of issues, and also lets us delete a ton of code.
2020-09-24 12:14:13 -07:00
Sebastian Meyer 35a5a69355 Some fixes for CompCert
1. Like with gcc's `ld`, also use the `group_start` code to create a
   `--start-group`/`--end-group`
2. xc16 tricked into believing the 'link_whole' was about `--*-group`,
   but it should use gcc's `--whole-archive` instead.
3. Not clear what the get_lib_prefix should really do, but for picolibc
   it seems I want just `''`.

The problem with picolibc was that the `-l` would be prefixed to a lib
like `picolib/libm/libm.a`. Though of course the `-l` would be necessary
for just a plain `m` (that's what I assumed this would be used for).
I think this might need some clarification from the meson devs ;-)
2020-09-18 08:59:39 -07:00
Dylan Baker 3526b36a77 linkers: fully type annotate and fix mypy issues
This makes GnuDynamicLinker not suitable for instantiation, so the tests
need to be changed to use the BFD class.
2020-09-16 20:28:56 -07:00
Dylan Baker 4401668c9a linkers/compilers: Move an emscripten method to the compiler
This needed an attribute the linker doesn't have.
2020-09-16 20:28:56 -07:00
Dylan Baker 67ab2880dd linkers: Make id a class variable for DynamicLinkers
Originally I had this idea that you'd be able to pass the id in to be
able to deduplicate some cases (like ld.gold and ld.bfd). That went away
because it ended up being really un-dry, but this id per instance
remained. Getting rid of it allows us to get rid of a bunch of otherwise
useless super calls, which makes adding type annotations easier.
2020-09-16 20:28:56 -07:00
Dylan Baker fc86df3d2c linkers: Fix argument error
The name of the argument passed was not the name of the argument used.
2020-09-16 20:28:56 -07:00
Sebastian Meyer a24fde6fde
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler

The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.

Squashed commit of the following:

commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date:   Mon Aug 31 14:20:39 2020 +0200

    remove '-fall' from default arguments, also filter -ftls-model=.*

commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date:   Mon Aug 31 14:13:55 2020 +0200

    use regex for filtering ccomp args

commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date:   Mon Aug 31 13:54:36 2020 +0200

    filter some gcc arguments

commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date:   Fri Aug 28 15:03:14 2020 +0200

    fix ccomp meson configuration

commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date:   Thu Aug 27 13:02:19 2020 +0200

    add CompCert to meson (does not fully work, yet)

* remove unused import and s/cls/self/

fixes the two obvious LGTM warnings

* CompCert: Do not ignore unsupported GCC flags

Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.

* remove unused variable

* Only add arguments once.

* Apply suggestions from code review

Co-authored-by: Dylan Baker <dylan@pnwbakers.com>

* Remove erroneous ' ' from '-o {}'.format()

As noticed by @dcbaker

* added release note snippet for compcert

* properly split parameters

As suggested by @dcbaker, these parameters should be properly split into multiple strings.

Co-authored-by: Dylan Baker <dylan@pnwbakers.com>

* Update add_compcert_compiler.md

Added a sentence about the state of the implementation (experimental); use proper markdown

* properly separate arguments

Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-15 21:51:21 +03:00
Jussi Pakkanen 3a25efc056
Merge pull request #7581 from peterh/aix
Add AIX support
2020-08-25 23:58:17 +03:00
Jussi Pakkanen c42298e146
Merge pull request #7447 from scivision/nvc
Add support for NVidia HPC SDK compilers
2020-08-22 18:31:56 +03:00
Peter Harris 0f90299b1c aix: allow both 32-bit and 64-bit objects in a static library
Without the -Xany flag, the ar command will complain when an .o file is
compiled for the non-default bit width. This change is necessary to allow
64-bit builds via a native (or cross) file.
2020-08-12 21:13:07 -04:00
Peter Harris abe72d5c84 aix: detect and support the AIX dynamic linker 2020-08-12 21:13:07 -04:00
Antony Chan 70edf82c6c Make meson recognize the Qualcomm LLVM toolchain
Meson calls `path/to/clang++ --version` to guess which build toolchain the
user has picked to build the source code. For the Qualcomm LLVM toolchain,
the output have an unusual output as shown below:

```
clang version 8.0.12
Snapdragon LLVM ARM Compiler 8.0.12 (based on llvm.org 7.0+)
Target: arm-unknown-linux-gnueabi
Thread model: posix
Repository: (ssh://git-hexagon-aus.qualcomm.com:...)
InstalledDir: /pkg/qct/software/llvm/release/arm/8.0.12/bin
```

Another unusual pattern is the output of `path/to/ld.qcld --version`:

```
ARM Linker from Snapdragon LLVM ARM Compiler Version 8.0.12
ARM Linker based on LLVM version: 8.0
```

The Meson logic is modified accordingly so that Meson can correctly
determine toolchain as "LLVM aarch64 cross-compiler on GNU/Linux64 OS".

This is the expected output of
`meson --native-file native_file.ini --cross-file cross_file.ini build/aarch64-debug/`:

```
...
C++ compiler for the host machine: ... (clang 8.0.12 "clang version 8.0.12")
C++ linker for the host machine: ... ld.lld 8.0.12
...
```
2020-08-02 10:39:44 -07:00
Jussi Pakkanen b6ea3eec1f
Merge pull request #7422 from alanc/solaris-fixes
Solaris fixes revisited
2020-07-14 20:46:19 +03:00
Nirbheek Chauhan 21da2c9040 Fix native builds on Windows ARM64 machines
I made the mistake of always selecting the debug CRT for compiler
checks on Windows 4 years ago:
https://github.com/mesonbuild/meson/pull/543
https://github.com/mesonbuild/meson/pull/614

The idea was to always build the tests with debugging enabled so that
the compiler doesn't optimize the tests away. But we stopped doing
that a while ago, and also the debug CRT has no relation to that.

We should select the CRT in the same way that we do for building
targets: based on the options.

On Windows ARM64, the debug CRT for ARM64 isn't always available, and
the release CRT is available only after installing the runtime
package. Without this, we will always try to pick the debug CRT even
when --buildtype=debugoptimized or release.
2020-07-13 15:28:38 +00:00
Michael Hirsch, Ph.D f985bb7383
add Nvidia HPC SDK compilers 2020-07-13 00:16:52 -04:00
Alan Coopersmith 5b82bb8689 SolarisDynamicLinker: Check if linker supports -z type=pie
As suggested by dcbaker in
https://github.com/mesonbuild/meson/pull/7370#discussion_r445145889

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-07-07 22:08:38 -07:00
Alan Coopersmith 28d1bb9016 SolarisDynamicLinker: add get_asneeded_args() & get_pie_args()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-06-22 15:02:19 -07:00
Dylan Baker 93c3ec7e2d compilers: Return CompilerArgs from compiler instance
Since the CompileArgs class already needs to know about the compiler,
and we really need at least per-lanaguage if not per-compiler
CompilerArgs classes, let's get the CompilerArgs instance from the
compiler using a method.
2020-06-22 12:06:10 -07:00
Nirbheek Chauhan 47c477711b apple: -headerpad args are ignored when bitcode is enabled
Causes spammy warnings from the linker:

ld: warning: -headerpad_max_install_names is ignored when used with -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES)
2020-06-11 07:10:43 +00:00
Dan Kegel 877dcdbcca gnulike linkers (and ar) accept rsp files. 2020-06-05 14:15:32 -07:00
Dan Kegel d7235c5905 Let .pc files specify rpath.
Fixes #4027
2020-05-16 20:25:58 +00:00
Andrei Alexeyev 9492eec55f Do not pass rpath flags to wasm-ld 2020-05-08 22:29:05 +03:00
Michael c53b637959 switch python2 %s for python3 .format 2020-04-21 00:16:21 +03:00
John Ericson 3a4388e51d Fix legacy env var support with cross
Fix #3969
2020-03-23 17:51:36 +02:00
alanNz 7460292810 -Add xc16 and c2000 C,Cpp toolchain support 2020-03-21 00:47:24 +02:00
Jussi Pakkanen 88e40c7081
Merge pull request #6356 from dcbaker/fix-d-compiler-abstractions
Fix d compiler abstractions
2020-03-12 00:57:52 +02:00
Dylan Baker 23b5f9b351 linkers: Allow optlink to be invoked indirectly 2020-03-09 16:55:08 -07:00
Dylan Baker 06bbf6cf93 linkers: Move import_library_args to from VS compiler to linker
This is the argument to name the implib when using the Visual Studio
Linker. This is needed by LDC and DMD when using link.exe or
lld-link.exe on windows, and is really a linker argument not a compiler
argument.
2020-03-09 16:55:08 -07:00
Dylan Baker 654f427759 compilers/linkers: Add a representation for wasm-ld
Emscripten does have a stand alone linker, wasm-ld. This patch adds the
linker, adds detection for the linker, and removes the IsLinkerMixin for
emscripten. This is a little more correct, and makes the code a lot
cleaner and more robust.
2020-02-27 16:35:02 -08:00
Jussi Pakkanen 9c604320a0
Merge pull request #6637 from mesonbuild/nirbheek/implement-symbolextractor-windows
Implement symbolextractor on windows + some cleanups/fixes
2020-02-23 20:23:03 +02:00
Nirbheek Chauhan be486a2ec8 ninjabackend: List PDBs in output list for targets
This is more correct, and forces the target(s) to be rebuilt if the
PDB files are missing. Increases the minimum required Ninja to 1.7,
which is available in Ubuntu 16.04 under backports.

We can't do the same for import libraries, because it is impossible
for us to know at configure time whether or not an import library will
be generated for a given DLL.
2020-02-22 06:49:34 +05:30
Dylan Baker 48f3e72493 linkers: Update the linker names to be more consistent
This makes two basic changes, 1 it moves the name of the linker into the
linker class, this should reduce the number of errors and typos, and
ensure that a linker always has one name. This then renames the linkers
to have more consistent names.

Posix/gnu linkers are called ld.<name>: ld.gold, ld.lld, ld.solaris.

Apple linkers are renamed ld64.
2020-02-21 05:15:25 +05:30
Dylan Baker a9cd197c7b linkers: typing -> T fixup
There was a particularly old MR merged, from before the typing -> T
standardization in meson.
2020-02-18 12:18:49 -08:00
Andrei Alexeyev 49ae886620 Don't pass --allow-shlib-undefined to lld if it's not supported
Fixes builds with llvm-mingw
2020-02-18 11:28:43 -08:00
Dmitry Kozlyuk 8b60fb709c msvc: add prefix to build type arguments 2020-02-15 23:53:47 +05:30
alanNz 1682058dec -Fixed Renesas RX Family compiler to work with latest meson, updated cross-file, fixed assembly file use 2020-01-30 22:11:26 +02:00
Nirbheek Chauhan b293852d07 vs: Write checksums in PE binaries (DLLs and EXEs)
This is needed for detecting data corruption, and its absence (or
an incorrect value) is also used as a hint by anti-viruses that the
binary may be malware.

Flag is only supported by MSVC `link.exe`, not `lld-link.exe`

https://docs.microsoft.com/en-us/cpp/build/reference/release-set-the-checksum
2020-01-22 19:34:05 +05:30
Nirbheek Chauhan 89b132f240 linkers: Accept both str and List[str] for _apply_prefix
Simplifies some usage.
2020-01-22 19:34:05 +05:30
Nirbheek Chauhan 38db769aaf linkers: Clarify a comment about rspfiles 2020-01-22 19:34:05 +05:30
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Dylan Baker 9e21942780 linkers: Remove get_allow_undefined_args from link.exe
PE DLLs don't work like elf or mach-o, there's no way to define symbols
at run time, they must all be defined as import or export at link time.
As such there's no value in being able to have undefined symbols in
MSVC, nor does meson expose an option to change them

Fixes: #6342
2019-12-18 21:57:03 +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
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
Dylan Baker c00e17b35a Partially revert "lgtm: fix Missing call to __init__ during object initialization"
This partially reverts commit fe853ee516.

In particular this reverts the changes to the DynamicLinker __init__
methods. Frankly this is *bad* because it allows a mixin class (which
should not be directly instantiated) to be directly instantiated, and
complicates the init process. It also increases the amount of code for
zero gain, and makes the code less resilient to refactors.
2019-12-05 22:15:40 +02:00
Daniel Mensinger fe853ee516 lgtm: fix Missing call to __init__ during object initialization
Either mark the missing calls as intentional, or explicetly call
the right __init__ method and avoid mixing super() and explicit
base calss calls.
2019-12-05 00:22:10 +02:00
Dylan Baker afe00f4217 linkers: make constructor signature of VisualStudioLike linkers the same 2019-12-03 13:08:42 -08:00
Dylan Baker a1bfd22120 linkers: Correct MSVC-like linkers invoke directly flag
This is returning the inverse of the correct value, which happens to
work out because in general the compilers that a link.exe-like linker is
paired with accepts the same arguments.
2019-12-03 13:08:42 -08:00