Commit Graph

123 Commits

Author SHA1 Message Date
Dylan Baker c6ec13e6bf
Only try to get RSP syntax if RSP is supported (#8804) 2021-05-30 00:24:53 +03:00
Dylan Baker 320412b3bb compilers/linkers: Add a methhod for getting the rspfile syntax 2021-03-14 22:05:55 -07:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Eli Schwartz 4340bf34fa
various python neatness cleanups
All changes were created by running

"pyupgrade --py3-only --keep-percent-format"

and committing the results. I have not touched string formatting for
now.

- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
2021-03-04 17:11:26 -05:00
Peter Harris c0b448d3ca aix: avoid -bsvr4 flag
The svr4 linker flag causes issues, especially when compiling c++.
Replace '-z' options with the equivalent non-svr4 flags. When using
-blibpath, we must be careful to include the default system library
path, or the resulting executables will not be able to find libc.

This patch was suggested by @andreaskem in #7581.
2021-02-14 09:16:08 -08:00
Dylan Baker 4b0b44afac move handling of CFLAGS and friends to environment
This has a bunch of nice features. It obviously centralizes everything,
which is nice. It also means that env is only re-read at `meson --wipe`,
not `meson --reconfigure`. And it's going to allow more cleanups.
2021-01-11 11:15:06 -08:00
Dylan Baker a2055ad18b import MachineChoice from mesonlib
there are a couple of places importing it from envconfig, which is not
correct. It's defined in mesonlib, and then imported into envconfig.
2021-01-11 11:15:06 -08:00
Dylan Baker fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Alan Coopersmith fdfc239cda linkers: add rpath_dirs_to_remove support to SolarisDynamicLinker
Applies the changes made to GnuLikeDynamicLinkerMixin by
commit d7235c5905 to SolarisDynamicLinker

This makes test_build_rpath pass with the Solaris linker, where before
this change it failed with:

New rpath must not be longer than the old one.
 Old: $ORIGIN/sub:/foo/bar
 New: /baz:$ORIGIN/sub:/foo/bar
FAILED: meson-install

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-12-22 20:21:31 +00:00
Martin Storsjö c9685ac561 Fix the subsystem options for lld in mingw mode
lld in gnu like mode (e.g. for mingw) needs these options in
the same for as gnu ld, thus remove the lld specific code bit
and move the code for gnu like options into GnuLikeDynamicLinkerMixin.

This unbreaks linking with lld for mingw targets after
2fb4d1f751.
2020-12-15 11:46:17 -08:00
Laurin-Luis Lehning b9b2e0223e Less restrictive get_win_subsystem_args implementations 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 4164efceca Propagate Windows target checks up 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 919278e3e1 Give get_gui_app_args access to the Environment 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 4053babf9c Slight consistency changes to get_gui_app_args 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 76b577af11 Oversight in VisualStudioLikeLinkerMixin 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 9de09e9aa6 Give get_win_subsystem_args access to env 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 2fb4d1f751 Make win_subsystem a linker property 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning bab1087422
Add support for driving lld-link indirectly through clang on Windows 2020-12-13 16:34:50 +02:00
Jussi Pakkanen c8af3c8d29 Revert "Add thinlto support. Closes #7493."
This reverts commit 3e6fbde94c.
2020-11-17 17:51:23 +02:00
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