public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Nathan Chancellor <natechancellor@gmail.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-s390@vger.kernel.org, clang-built-linux@googlegroups.com
Subject: [PATCH AUTOSEL 5.4 16/24] s390/vdso: Use $(LD) instead of $(CC) to link vDSO
Date: Tue, 23 Jun 2020 13:35:51 -0400	[thread overview]
Message-ID: <20200623173559.1355728-16-sashal@kernel.org> (raw)
In-Reply-To: <20200623173559.1355728-1-sashal@kernel.org>

From: Nathan Chancellor <natechancellor@gmail.com>

[ Upstream commit 2b2a25845d534ac6d55086e35c033961fdd83a26 ]

Currently, the VDSO is being linked through $(CC). This does not match
how the rest of the kernel links objects, which is through the $(LD)
variable.

When clang is built in a default configuration, it first attempts to use
the target triple's default linker, which is just ld. However, the user
can override this through the CLANG_DEFAULT_LINKER cmake define so that
clang uses another linker by default, such as LLVM's own linker, ld.lld.
This can be useful to get more optimized links across various different
projects.

However, this is problematic for the s390 vDSO because ld.lld does not
have any s390 emulatiom support:

https://github.com/llvm/llvm-project/blob/llvmorg-10.0.1-rc1/lld/ELF/Driver.cpp#L132-L150

Thus, if a user is using a toolchain with ld.lld as the default, they
will see an error, even if they have specified ld.bfd through the LD
make variable:

$ make -j"$(nproc)" -s ARCH=s390 CROSS_COMPILE=s390x-linux-gnu- LLVM=1 \
                       LD=s390x-linux-gnu-ld \
                       defconfig arch/s390/kernel/vdso64/
ld.lld: error: unknown emulation: elf64_s390
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

Normally, '-fuse-ld=bfd' could be used to get around this; however, this
can be fragile, depending on paths and variable naming. The cleaner
solution for the kernel is to take advantage of the fact that $(LD) can
be invoked directly, which bypasses the heuristics of $(CC) and respects
the user's choice. Similar changes have been done for ARM, ARM64, and
MIPS.

Link: https://lkml.kernel.org/r/20200602192523.32758-1-natechancellor@gmail.com
Link: https://github.com/ClangBuiltLinux/linux/issues/1041
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
[heiko.carstens@de.ibm.com: add --build-id flag]
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/vdso64/Makefile | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile
index bec19e7e6e1cf..4a66a1cb919b1 100644
--- a/arch/s390/kernel/vdso64/Makefile
+++ b/arch/s390/kernel/vdso64/Makefile
@@ -18,8 +18,8 @@ KBUILD_AFLAGS_64 += -m64 -s
 
 KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS))
 KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin
-KBUILD_CFLAGS_64 += -nostdlib -Wl,-soname=linux-vdso64.so.1 \
-		    -Wl,--hash-style=both
+ldflags-y := -fPIC -shared -nostdlib -soname=linux-vdso64.so.1 \
+	     --hash-style=both --build-id -T
 
 $(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_64)
 $(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_64)
@@ -37,8 +37,8 @@ KASAN_SANITIZE := n
 $(obj)/vdso64_wrapper.o : $(obj)/vdso64.so
 
 # link rule for the .so file, .lds has to be first
-$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) FORCE
-	$(call if_changed,vdso64ld)
+$(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) FORCE
+	$(call if_changed,ld)
 
 # strip rule for the .so file
 $(obj)/%.so: OBJCOPYFLAGS := -S
@@ -50,8 +50,6 @@ $(obj-vdso64): %.o: %.S FORCE
 	$(call if_changed_dep,vdso64as)
 
 # actual build commands
-quiet_cmd_vdso64ld = VDSO64L $@
-      cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $(filter %.lds %.o,$^) -o $@
 quiet_cmd_vdso64as = VDSO64A $@
       cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
 
-- 
2.25.1


  parent reply	other threads:[~2020-06-23 17:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23 17:35 [PATCH AUTOSEL 5.4 01/24] sata_rcar: handle pm_runtime_get_sync failure cases Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 02/24] ata/libata: Fix usage of page address by page_address in ata_scsi_mode_select_xlat function Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 03/24] drm/amd/display: Use kfree() to free rgb_user in calculate_user_regamma_ramp() Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 04/24] riscv/atomic: Fix sign extension for RV64I Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 05/24] hwrng: ks-sa - Fix runtime PM imbalance on error Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 06/24] arm64/sve: Eliminate data races on sve_default_vl Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 07/24] ibmvnic: Harden device login requests Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 08/24] net: alx: fix race condition in alx_remove Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 09/24] test_objagg: Fix potential memory leak in error handling Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 10/24] rocker: fix incorrect error handling in dma_rings_init Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 11/24] mvpp2: ethtool rxtx stats fix Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 12/24] pinctrl: qcom: spmi-gpio: fix warning about irq chip reusage Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 13/24] pinctrl: tegra: Use noirq suspend/resume callbacks Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 14/24] s390/ptrace: pass invalid syscall numbers to tracing Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 15/24] s390/ptrace: fix setting syscall number Sasha Levin
2020-06-23 17:35 ` Sasha Levin [this message]
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 17/24] s390/vdso: fix vDSO clock_getres() Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 18/24] arm64: sve: Fix build failure when ARM64_SVE=y and SYSCTL=n Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 19/24] kbuild: improve cc-option to clean up all temporary files Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 20/24] recordmcount: support >64k sections Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 21/24] kprobes: Suppress the suspicious RCU warning on kprobes Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 22/24] blktrace: break out of blktrace setup on concurrent calls Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 23/24] block: update hctx map when use multiple maps Sasha Levin
2020-06-23 17:35 ` [PATCH AUTOSEL 5.4 24/24] RISC-V: Don't allow write+exec only page mapping request in mmap Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200623173559.1355728-16-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=gor@linux.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox