Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1528533ybg; Tue, 2 Jun 2020 12:27:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZTlxr49F3X/CdwbA/ofuUyiMEBXLYB+77LrLGz3+IFjUPgF6vMkhIZ/kxAdqkhUNO9jLe X-Received: by 2002:a17:906:78b:: with SMTP id l11mr2959359ejc.427.1591126079228; Tue, 02 Jun 2020 12:27:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591126079; cv=none; d=google.com; s=arc-20160816; b=tUJ+TCs3u9zw9bOpI1KhJjnru7Fq3QBe/wmGohw2FDtaQthXChK87IfxHl+uTm3vEV DgtvVuSNal/zpq1ocVWn841ZuPJxlJemrtsRbR8B96T3x64um734m/irK1StJrHtdkOb emfsgH64lmB5kAtEAWvYPsq7Wi5oBlVyD7vUhMk3LLOF1kZL4B4DyyiBIxeJ9jRSPJFY n08ft17wxLNhUACOgFlkj8LHu3+LOeD5wmyeqXryhHNXjG+hIGgZBUNSy1K1rD6fHGrR feP5r2yP3TjorRnedjfnxGF3/aJDsZ5cDC2SJLuNjCdTjlIYZmzR8TKpUUclVqTrIBD1 M1FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OZNHGkENnW7p5QnYC1ZvXQjRimlmYQpqW7KCIXsjMOo=; b=F3MPvN3PaGGEWYBAZqDj0qvfBwDm/y9EUodZ5c5faz2OpHAR7hXkg9sl785budT5C7 4A4wAu/QO7chG2qWDg8uxBp67R8DNPaay/5AIjmA65/h2ptdAB2m708SiQ1KxGe+yVfa 0oVx0ie9bLI48YFtB9BAVE7lBw99yCR3T11ZCbdNxEpCI2C4aM1TjtNjrAwlBRx88bN6 WmIp2fGin13IjKOXEvTsvmjENlwC9HBjttrJ9KDDv0pzgiYjnfIKmHO/ahsYqxjYHGkg 1ehz0df25L5u1W4f+ALDNYBD8zgKjAH5IynB01qCH1sPRL++zluZpL1w8a3dsL9OpnB6 ReTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q1QcQqHU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si1995508ejo.418.2020.06.02.12.27.35; Tue, 02 Jun 2020 12:27:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q1QcQqHU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726580AbgFBTZx (ORCPT + 99 others); Tue, 2 Jun 2020 15:25:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726139AbgFBTZx (ORCPT ); Tue, 2 Jun 2020 15:25:53 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3DE6C08C5C0; Tue, 2 Jun 2020 12:25:52 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id g5so5596449pfm.10; Tue, 02 Jun 2020 12:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OZNHGkENnW7p5QnYC1ZvXQjRimlmYQpqW7KCIXsjMOo=; b=Q1QcQqHUqLNIrpBnRSEF4hH87gVGsH5KuvGMe1FCb8ZApL7UR/mqtCOZgEG3v7DmDI ltyEdb5GHSzAKdt1li0PXnSAE0drq1FC2MliINsjI+iAo7ehYpkZwRbJ4jnNU1PMjTAJ 73NPZls5lYIRVYc0dleTeDnxFwd/dmb5RibQTpXi0vQC8BpYxZJqFYVTM232U/NIYxM5 /6A2O/Ys0N1/ZqKnVJstKXGSs3ZGWzVMtm2IJejGREn1PJnXBuO2GQbTTntQBCIvh/xC gqFsthkZqTAN7ohya/t0ASPyC1B0SucJcF8bmUlnQFDDRDwGRpukvknzkms4PojTiFyn D/pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OZNHGkENnW7p5QnYC1ZvXQjRimlmYQpqW7KCIXsjMOo=; b=o/++C2E/HC7JdBFv3De6P5T/Gy7l5v16VjAI8wF+0E/MBEZjsvRZYe6Py0fQvKbow/ t+xMWuQ9z0VK5mCxYh2ZttOujVD8ThxnBr3g2bNIv17hEfseAt0uF+K/kvtPKpKm8zJ5 A+HfoutXsjW3qvuXtZ/n9OGeJ0yeHC6KWSNi4JB+N5jy9+JMJHKZv6adFb4fs7SLU20U a5YbQkqKUtKkI7rsOJE3hOJLuAyMNf7OUs6uWjKrj3UwX0rciK2QtSX43T4ihDzUSCuN A6g11ZWkh2pPwJVpGS4Sxrv15Hb6ZTiw0spO7uw6EIHTPdHcRsjIsnNmxWlh0tbbvJHG x3vQ== X-Gm-Message-State: AOAM533PWFiudiXpJpJnqsFxDLLW5Wg7rcCcFfM34bIS3pibTA+iyTVh gjq5wCwFsctWck6slgv3bFI= X-Received: by 2002:a17:90a:32d1:: with SMTP id l75mr770318pjb.85.1591125952020; Tue, 02 Jun 2020 12:25:52 -0700 (PDT) Received: from Ryzen-9-3900X.localdomain ([107.152.99.41]) by smtp.gmail.com with ESMTPSA id t2sm2813795pgh.89.2020.06.02.12.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 12:25:51 -0700 (PDT) From: Nathan Chancellor To: Heiko Carstens , Vasily Gorbik , Christian Borntraeger Cc: Nick Desaulniers , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH v2] s390: vdso: Use $(LD) instead of $(CC) to link vDSO Date: Tue, 2 Jun 2020 12:25:24 -0700 Message-Id: <20200602192523.32758-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.27.0.rc2 In-Reply-To: References: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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://github.com/ClangBuiltLinux/linux/issues/1041 Signed-off-by: Nathan Chancellor --- v1 -> v2: * Add -fPIC per GCC's documentation, as pointed out by Nick. 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 bec19e7e6e1c..67c14732c304 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 -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 $@ $< base-commit: e1750a3d9abbea2ece29cac8dc5a6f5bc19c1492 -- 2.27.0.rc2