From 730a7b296fdff8aca58e15829485b3b68262d3c0 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 13 Jan 2020 11:15:36 -0800 Subject: environment: Replace LD with 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 --- docs/markdown/howtox.md | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'docs') diff --git a/docs/markdown/howtox.md b/docs/markdown/howtox.md index f73d6b9..5deaa7e 100644 --- a/docs/markdown/howtox.md +++ b/docs/markdown/howtox.md @@ -28,24 +28,36 @@ native-files and the latter via the cross file only. ## Set dynamic linker +Like the compiler, the linker is selected via the _LD +environment variable, or through the `ld` entry in a native +or cross file. You must be aware of whether you're using a compiler that +invokes the linker itself (most compilers including GCC and Clang) or a +linker that is invoked directly (when using MSVC or compilers that act like +it, including Clang-Cl). With the former `cld` or `CC_LD` should be the value +to pass to the compiler's special argument (such as `-fuse-ld` with clang and +gcc), with the latter it should be an executable, such as `lld-link.exe`. + +*NOTE* In meson 0.53.0 the `ld` entry in the cross/native file and the `LD` +environment variable was used, this resulted in a large number of regressions +and was changed. + ```console -$ CC=clang LD=lld meson +$ CC=clang CC_LD=lld meson ``` or ```console -$ CC=clang-cl LD=link meson +$ CC=clang-cl CC_LD=link meson ``` -Like the compiler, the linker is selected via the LD environment variable, or -through the `ld` entry in a native or cross file. You must be aware of -whehter you're using a compiler that invokes the linker itself (most -compilers including GCC and Clang) or a linker that is invoked directly (when -using MSVC or compilers that act like it, including Clang-Cl). With the -former `ld` or `LD` should be the value to pass to the compiler's special -argument (such as `-fuse-ld` with clang and gcc), with the latter it should -be an exectuable, such as `lld-link.exe`. +or in a cross or native file: + +```ini +[binaries] +c = 'clang' +c_ld = 'lld' +``` ## Set default C/C++ language version @@ -139,7 +151,7 @@ $ ninja coverage-html (or coverage-xml) The coverage report can be found in the meson-logs subdirectory. -Note: Currently, Meson does not support generating coverage reports +Note: Currently, Meson does not support generating coverage reports with Clang. ## Add some optimization to debug builds -- cgit v1.1