From patchwork Thu Apr 23 17:18:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11506105 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 301EB1667 for ; Thu, 23 Apr 2020 17:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1744320857 for ; Thu, 23 Apr 2020 17:18:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kI4TGFfZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729890AbgDWRS2 (ORCPT ); Thu, 23 Apr 2020 13:18:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729873AbgDWRS2 (ORCPT ); Thu, 23 Apr 2020 13:18:28 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EA6AC09B042; Thu, 23 Apr 2020 10:18:27 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id j4so7372806otr.11; Thu, 23 Apr 2020 10:18:27 -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=ox1WLU3YUxcP2R/GVPO/gQRlaX6uwFvhGgYlvzhom8U=; b=kI4TGFfZQrCLM1ubOC/N78oRrvYMQ6BxrVgdxTtoQslDCYMJE3n/662x/Xd0mwXm5G tHiz3Y2sDzdZLmBQUXVx747nAIPALN8pY6wwvpEmyhySXPySpmV97OeZ0tHN/pQPx6an X3BKdzft+rAeeWqIlol73cmETF+wXRXgwrM+SnWCFN+N3XP/TkJfIVxy4RoYkAfjzG/e jTaMG91B0QMA5hGONLzDgaBIPL/0BWBHPobB7zZj8JR0HEZBN6hQIoCClXHlULCFombJ H1yeds+T43FcDhQ47sgLlA6pNXx2Ey8RkOXhG80tR2YQkCGw7DMOxInDns3yzEY/UaSg rNSA== 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=ox1WLU3YUxcP2R/GVPO/gQRlaX6uwFvhGgYlvzhom8U=; b=jNh7wDHUpxUPAJgasFqjn4dKhAxYGu5tPs+E3HTtEyi12+k3FFVJ0XVrAD6nlh36lQ y9xbANvODLJoRLbVbQvO7kk6tuq7oKMkm2Gxh5q1fijpIS8AMhmt8wKU4l+TbCbZi1Xj nKng9J+lCpGiqdUnibG6cMLnZ5qElR54ufOOOsqeSQMqEfzAKXThNtqBYF/HhODY6hmT hMm/cioDE0BYsA86JlaMLkfhFZKdq0MSSiOD3+wjspFahJ46GOghVDtKwWhxZAq8Ssmb w+mGOHEFKxHw6Xf8CZTWU5FjOuZAxPoDnpzMFLNGcgypg0A3MMq6TpZ3dABv1F05xlJa 2DaQ== X-Gm-Message-State: AGi0PubjBLoXEXr9eHo6K94/s11r2Jv02U//fNmvmavwXu/QK8alY31G uEsB00ldsMAtnt0PpGtZTm8PcS7DAbs= X-Google-Smtp-Source: APiQypJsLrMoxkPad47LLuoBzFyGFl+3ifX7fd/TyQ5Wz3cRz5hiX82bq9xWH+v1uQTO6Ss1dknxVg== X-Received: by 2002:aca:6002:: with SMTP id u2mr3861263oib.45.1587662306403; Thu, 23 Apr 2020 10:18:26 -0700 (PDT) Received: from localhost.localdomain ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id y5sm746726otq.38.2020.04.23.10.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 10:18:25 -0700 (PDT) From: Nathan Chancellor To: Thomas Bogendoerfer , Masahiro Yamada Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, linux-kbuild@vger.kernel.org, Nick Desaulniers , Sami Tolvanen , Dmitry Golovin , Sedat Dilek , Nathan Chancellor Subject: [PATCH v3 1/4] kbuild: add CONFIG_LD_IS_LLD Date: Thu, 23 Apr 2020 10:18:04 -0700 Message-Id: <20200423171807.29713-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200419202128.20571-1-natechancellor@gmail.com> References: <20200419202128.20571-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Sami Tolvanen Similarly to the CC_IS_CLANG config, add LD_IS_LLD to avoid GNU ld specific logic such as ld-version or ld-ifversion and gain the ability to select potential features that depend on the linker at configuration time such as LTO. Signed-off-by: Sami Tolvanen Acked-by: Masahiro Yamada [nc: Reword commit message] Signed-off-by: Nathan Chancellor --- v2 -> v3: * Add Masahiro's ack. v1 -> v2: * No changes. Sami, please scream if you are unhappy with how I worded this commit. init/Kconfig | 3 +++ 1 file changed, 3 insertions(+) base-commit: ae83d0b416db002fe95601e7f97f64b59514d936 diff --git a/init/Kconfig b/init/Kconfig index 9e22ee8fbd75e..c15ee42b82726 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -23,6 +23,9 @@ config LD_VERSION config CC_IS_CLANG def_bool $(success,$(CC) --version | head -n 1 | grep -q clang) +config LD_IS_LLD + def_bool $(success,$(LD) -v | head -n 1 | grep -q LLD) + config CLANG_VERSION int default $(shell,$(srctree)/scripts/clang-version.sh $(CC)) From patchwork Thu Apr 23 17:18:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11506109 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 243C61667 for ; Thu, 23 Apr 2020 17:18:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D2C120857 for ; Thu, 23 Apr 2020 17:18:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tjYeQYK8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729901AbgDWRSc (ORCPT ); Thu, 23 Apr 2020 13:18:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729873AbgDWRSb (ORCPT ); Thu, 23 Apr 2020 13:18:31 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE557C09B042; Thu, 23 Apr 2020 10:18:31 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id e26so7429179otr.2; Thu, 23 Apr 2020 10:18:31 -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=HTHjP+xa7tR8VrtaPBa2UF2GKJnEOq+tUvqQYj54eMQ=; b=tjYeQYK8VvbiOPzo8TUxhzj31UiEnUjECsKYPg8mn5f3pCU6P3dt3+oCtTjdQZewcz 17m69DZH8rMnShig9IdmepYlZwDtpBhzBplY3CMc79ihrC7LNS4m8BDjj08bDreDLhRH d3nxrDs7H62FtNQDPxAKa5PWbEojZQvt4UdDYed1nVEGVorLrksg8Aus2lZ1NMOxMGsl +YcuM+B0UlxA8CLrRZrUrTVnulZmafszmH0oaRe7W7DIDDi+4BJuGqlx+hSwF8igluGG xW/PytbBIHoMM7efqzBvjL2Rplh7c3T0M+SuvOZdE49pBtITVuipzKgk75IxwN3ttV2h 3sDQ== 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=HTHjP+xa7tR8VrtaPBa2UF2GKJnEOq+tUvqQYj54eMQ=; b=Z7uqbmhMtSg1kY6GSJHknn4FKnCFMvXNwURodm/r1NFC0FT/+MdPCHtIgEjEXxRaJU hfnM+SxHclIAWrHYGsa8W7sb1+FXPOsphMUo6tKyf4l7m7Nx3xccUcu52p7QJoBpe+TQ FEoyp/kNP0MJeJ36Rz1aimkRdsdlrXfJlyzbaexDKWed6KI6fTzDqqh2NIBjX24hks/a nPK+exFjUGYtHhJ8NA9LnAd0lLYQB+5yzwXiMdQ8jD/x9wXmSJss6tjR78eX/u5WwF+x EpgqAbgavGY2HvM5aK0DK30MYDo/mThNLGs8LRsx1Lj8M1zuG0iewTA1sBG7fQJ1wFVB my5g== X-Gm-Message-State: AGi0PubYfvHEMvsmnFkTac3p3o4313uqVXmijROmZXzZZxXwN5ttH11f 7XUtlgGo81xX2pn7366/lb0QX7x7uQo= X-Google-Smtp-Source: APiQypKPRZpH7thOf4NzXz8RnEP35p9xmtvNx19TRvFX7ugLPZAfE2nSg5h0DwmglietxPfEx+VTlQ== X-Received: by 2002:aca:53cd:: with SMTP id h196mr3919944oib.104.1587662311195; Thu, 23 Apr 2020 10:18:31 -0700 (PDT) Received: from localhost.localdomain ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id y5sm746726otq.38.2020.04.23.10.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 10:18:30 -0700 (PDT) From: Nathan Chancellor To: Thomas Bogendoerfer , Masahiro Yamada Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, linux-kbuild@vger.kernel.org, Nick Desaulniers , Sami Tolvanen , Dmitry Golovin , Sedat Dilek , Nathan Chancellor Subject: [PATCH v3 2/4] MIPS: VDSO: Move disabling the VDSO logic to Kconfig Date: Thu, 23 Apr 2020 10:18:05 -0700 Message-Id: <20200423171807.29713-2-natechancellor@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200423171807.29713-1-natechancellor@gmail.com> References: <20200419202128.20571-1-natechancellor@gmail.com> <20200423171807.29713-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org After commit 9553d16fa671 ("init/kconfig: Add LD_VERSION Kconfig"), we have access to GNU ld's version at configuration time. As a result, we can make it clearer under what configuration circumstances the MIPS VDSO needs to be disabled. This is a prerequisite for getting rid of the MIPS VDSO binutils warning and linking the VDSO when LD is ld.lld. Wrapping the call to ld-ifversion with CONFIG_LD_IS_LLD does not work because the config values are wiped away during 'make clean'. Signed-off-by: Nathan Chancellor --- v2 -> v3: * Fix CONFIG macro in arch/mips/vdso/vdso.lds.S, thanks to Sedat for catching it. v1 -> v2: * New patch. arch/mips/Kconfig | 2 ++ arch/mips/vdso/Kconfig | 18 ++++++++++++++++++ arch/mips/vdso/Makefile | 30 ++---------------------------- arch/mips/vdso/vdso.lds.S | 2 +- 4 files changed, 23 insertions(+), 29 deletions(-) create mode 100644 arch/mips/vdso/Kconfig diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 690718b3701af..45220e4b8a653 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -3275,3 +3275,5 @@ endmenu source "drivers/firmware/Kconfig" source "arch/mips/kvm/Kconfig" + +source "arch/mips/vdso/Kconfig" diff --git a/arch/mips/vdso/Kconfig b/arch/mips/vdso/Kconfig new file mode 100644 index 0000000000000..36a52158d849b --- /dev/null +++ b/arch/mips/vdso/Kconfig @@ -0,0 +1,18 @@ +# For the pre-R6 code in arch/mips/vdso/vdso.h for locating +# the base address of VDSO, the linker will emit a R_MIPS_PC32 +# relocation in binutils > 2.25 but it will fail with older versions +# because that relocation is not supported for that symbol. As a result +# of which we are forced to disable the VDSO symbols when building +# with < 2.25 binutils on pre-R6 kernels. For more references on why we +# can't use other methods to get the base address of VDSO please refer to +# the comments on that file. +# +# GCC (at least up to version 9.2) appears to emit function calls that make use +# of the GOT when targeting microMIPS, which we can't use in the VDSO due to +# the lack of relocations. As such, we disable the VDSO for microMIPS builds. + +config MIPS_LD_CAN_LINK_VDSO + def_bool LD_VERSION >= 225000000 + +config MIPS_DISABLE_VDSO + def_bool CPU_MICROMIPS || (!CPU_MIPSR6 && !MIPS_LD_CAN_LINK_VDSO) diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile index d7fe8408603e8..92b53d1df42c3 100644 --- a/arch/mips/vdso/Makefile +++ b/arch/mips/vdso/Makefile @@ -52,37 +52,11 @@ endif CFLAGS_REMOVE_vgettimeofday.o = -pg -DISABLE_VDSO := n - -# -# For the pre-R6 code in arch/mips/vdso/vdso.h for locating -# the base address of VDSO, the linker will emit a R_MIPS_PC32 -# relocation in binutils > 2.25 but it will fail with older versions -# because that relocation is not supported for that symbol. As a result -# of which we are forced to disable the VDSO symbols when building -# with < 2.25 binutils on pre-R6 kernels. For more references on why we -# can't use other methods to get the base address of VDSO please refer to -# the comments on that file. -# -ifndef CONFIG_CPU_MIPSR6 - ifeq ($(call ld-ifversion, -lt, 225000000, y),y) +ifdef CONFIG_MIPS_DISABLE_VDSO + ifndef CONFIG_MIPS_LD_CAN_LINK_VDSO $(warning MIPS VDSO requires binutils >= 2.25) - DISABLE_VDSO := y endif -endif - -# -# GCC (at least up to version 9.2) appears to emit function calls that make use -# of the GOT when targeting microMIPS, which we can't use in the VDSO due to -# the lack of relocations. As such, we disable the VDSO for microMIPS builds. -# -ifdef CONFIG_CPU_MICROMIPS - DISABLE_VDSO := y -endif - -ifeq ($(DISABLE_VDSO),y) obj-vdso-y := $(filter-out vgettimeofday.o, $(obj-vdso-y)) - ccflags-vdso += -DDISABLE_MIPS_VDSO endif # VDSO linker flags. diff --git a/arch/mips/vdso/vdso.lds.S b/arch/mips/vdso/vdso.lds.S index da4627430aba4..d90b65724d78e 100644 --- a/arch/mips/vdso/vdso.lds.S +++ b/arch/mips/vdso/vdso.lds.S @@ -91,7 +91,7 @@ PHDRS VERSION { LINUX_2.6 { -#ifndef DISABLE_MIPS_VDSO +#ifndef CONFIG_MIPS_DISABLE_VDSO global: __vdso_clock_gettime; __vdso_gettimeofday; From patchwork Thu Apr 23 17:18:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11506111 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AB6113B2 for ; Thu, 23 Apr 2020 17:18:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3287220781 for ; Thu, 23 Apr 2020 17:18:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="boH2xgHE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729911AbgDWRSf (ORCPT ); Thu, 23 Apr 2020 13:18:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729873AbgDWRSf (ORCPT ); Thu, 23 Apr 2020 13:18:35 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D7DEC09B042; Thu, 23 Apr 2020 10:18:35 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id i9so1483360ool.5; Thu, 23 Apr 2020 10:18:35 -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=GILvIx3f4BgcOXSqsviaTizrH5Jn18xvHIx2HxEKgO0=; b=boH2xgHEvJLwuVRAfI6ruW7K6gG7cxpBDf76Wb3CvUghX8huVBdPbFzsn8KXSbt8L5 GSrbXveRLSNQ1XKpMTl6tWxbZOhwu2Q71EtSdaaggQ03zHuTtlEoA3VIfZVLSLBigfrw Oosb/ev9UpkJXNY8Ocxbrq1YJdDNv0zVKewwUtJw5zVCJimidtn9xOFKOY+UPxUV7epR 81poD39/jembYOT9xM66sS44p7wGiHCO30qUlYewUTRpCXThNddvg+YKpi+9LBpjobm7 wwErfQ2d9JDr2aDn3uXX3D3MeZYVCaNU5OYx0BroXhrezDD54nn6bZBO9GMTrnI/4n7r GWuA== 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=GILvIx3f4BgcOXSqsviaTizrH5Jn18xvHIx2HxEKgO0=; b=rCe2v8VYZEEJNUYKM2BtieZfMtm007FxIAEB0DfyUx2rqlSWkF+JzZZLbkYA7LVCf4 T/8ESy7+Lo9XwvuLqUbGwM7agE/USXhiJD6NGyUjoiIwu8u2cyvg2W6VcwXfWV3Yphem hC36+3CpBJsvfTcYvcQn3ZcVxp11QXIXGjSXp55TBbAmPvxMgr9rUxI3Lzez6JVr/mDl +qLAFLAaQmnv+h4wnq7oeSpwJ/eL+2NYVI12qLCX/XhKn5cTE+/79qL/ml2BIlIoBO/H 3ex8LZ5PQvL5t1yJlmMGhGWKuec8R8OCmh3m8kr9uyqmHkjXNjZRKQCHYxYPuTT3UpV3 H7Gw== X-Gm-Message-State: AGi0PuaUTixrHprENnioOA7B0PxOi1bjHR0hn6JQCPJA37s5jfOWFQiT vEsI6Db5lInU53SpE9sAEl8= X-Google-Smtp-Source: APiQypIEvSQvqrAUjKg/5w2LZSQtWpOI62mrEPs+UkTHfg38XF/2xlNzkC7c2s3ipf+OBN7YpsFx6Q== X-Received: by 2002:a4a:a54a:: with SMTP id s10mr4319105oom.73.1587662314470; Thu, 23 Apr 2020 10:18:34 -0700 (PDT) Received: from localhost.localdomain ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id y5sm746726otq.38.2020.04.23.10.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 10:18:33 -0700 (PDT) From: Nathan Chancellor To: Thomas Bogendoerfer , Masahiro Yamada Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, linux-kbuild@vger.kernel.org, Nick Desaulniers , Sami Tolvanen , Dmitry Golovin , Sedat Dilek , Nathan Chancellor Subject: [PATCH v3 3/4] MIPS: VDSO: Use $(LD) instead of $(CC) to link VDSO Date: Thu, 23 Apr 2020 10:18:06 -0700 Message-Id: <20200423171807.29713-3-natechancellor@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200423171807.29713-1-natechancellor@gmail.com> References: <20200419202128.20571-1-natechancellor@gmail.com> <20200423171807.29713-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@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 then the system's default linker, unless told otherwise through -fuse-ld=... We do not use -fuse-ld= because it can be brittle and we have support for invoking $(LD) directly. See commit fe00e50b2db8c ("ARM: 8858/1: vdso: use $(LD) instead of $(CC) to link VDSO") and commit 691efbedc60d2 ("arm64: vdso: use $(LD) instead of $(CC) to link VDSO") for examples of doing this in the VDSO. Do the same thing here. Replace the custom linking logic with $(cmd_ld) and ldflags-y so that $(LD) is respected. Before this patch, LD=ld.lld did nothing: $ llvm-readelf -p.comment arch/mips/vdso/vdso.so.dbg | sed 's/(.*//' String dump of section '.comment': [ 0] ClangBuiltLinux clang version 11.0.0 After this patch, it does: $ llvm-readelf -p.comment arch/mips/vdso/vdso.so.dbg | sed 's/(.*//' String dump of section '.comment': [ 0] Linker: LLD 11.0.0 [ 62] ClangBuiltLinux clang version 11.0.0 Signed-off-by: Nathan Chancellor Reported-by: Thomas Bogendoerfer Signed-off-by: Nathan Chancellor --- v2 -> v3: * New patch. arch/mips/vdso/Makefile | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile index 92b53d1df42c3..da5db947072d5 100644 --- a/arch/mips/vdso/Makefile +++ b/arch/mips/vdso/Makefile @@ -60,10 +60,9 @@ ifdef CONFIG_MIPS_DISABLE_VDSO endif # VDSO linker flags. -VDSO_LDFLAGS := \ - -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 \ - $(addprefix -Wl$(comma),$(filter -E%,$(KBUILD_CFLAGS))) \ - -nostdlib -shared -Wl,--hash-style=sysv -Wl,--build-id +ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \ + $(filter -E%,$(KBUILD_CFLAGS)) -nostdlib -shared \ + --hash-style=sysv --build-id -T CFLAGS_REMOVE_vdso.o = -pg @@ -82,11 +81,7 @@ quiet_cmd_vdso_mips_check = VDSOCHK $@ # quiet_cmd_vdsold_and_vdso_check = LD $@ - cmd_vdsold_and_vdso_check = $(cmd_vdsold); $(cmd_vdso_check); $(cmd_vdso_mips_check) - -quiet_cmd_vdsold = VDSO $@ - cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \ - -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@ + cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check); $(cmd_vdso_mips_check) quiet_cmd_vdsoas_o_S = AS $@ cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $< From patchwork Thu Apr 23 17:18:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11506117 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0489713B2 for ; Thu, 23 Apr 2020 17:18:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E01C720781 for ; Thu, 23 Apr 2020 17:18:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kArGXup8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729922AbgDWRSj (ORCPT ); Thu, 23 Apr 2020 13:18:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729873AbgDWRSi (ORCPT ); Thu, 23 Apr 2020 13:18:38 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6E38C09B042; Thu, 23 Apr 2020 10:18:36 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id 72so7428112otu.1; Thu, 23 Apr 2020 10:18:36 -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=eWIMc/tafff8n4r/ioH7WudEqX5eKJY4/xwKjCeysa8=; b=kArGXup8Vf4fJZuWNPUdQbwhZ7FifQlAfceTOlwuVHUC/OYWb1p7KJPArTUaKcOXga Mv9Y9gxkdvL7oC1hzUwDZ/EocCxG8ckOUNDTactW2YiIzCfBKrO6txmbhl5httcUlK8K iBTT9N68VbXe8FkFBd7bXr7cpLj3f+5YL8qRrpj71musLmviat79JKlDcMErKwNcz6AX BYIe5CCCqhUlPxuh/c7qN9DQNC8kcT/5y4GFlUPI8NFhbc26lbzMmZRQDXK58RXpqRZ6 Fu1g4xr1/+g56fPtO0kKSWLicbSBM0COZGld3VcqJ95HhTapoTZ5basg2o4l8g3IQE0g /H1Q== 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=eWIMc/tafff8n4r/ioH7WudEqX5eKJY4/xwKjCeysa8=; b=Z3xlyeXFxSjU0XA+JO9BZjStdb5gV91EfS/p5nWyHQ7/Qid2EYRQyLqdYX+1gwnl8+ OtYM2IXk9gKXw8WFh/WmFJykUToTju/f60nP1ct6fKXW8Uc8MJ+Wz7IhJ5lIHr9GSGfR OwJWaQvUun4rzR5Lzpggx0e+riEuTUcRbU0HEmN1qvYt0SLdJN1WPwtm3bYZsAlCLcGa OMfWtrMzKlJGk0ooTSDSDGS5fwL0giaa2NGcenu63Fw92DisA6IxbKOZJlSuCsbCcNEK wVJNCxBFZt4B4NtP+U2pvLN+LE6Ezf81Y5LszIt8HNjhizh6tLPm2a63BcAD31hMLAe5 43aw== X-Gm-Message-State: AGi0PuZh5qDjfUbGvHGHg1ph/MVQPQaK7vyn5ZP+JmKq4Mgy9JJYzvkE 8v3IMpRtWsI5t15Rn0KKOjY= X-Google-Smtp-Source: APiQypLHdw9Re8ZNGGoE8MiNgAXFonviP9LlIhN1ClhOhtuOBAsRxzkpDfuVDEM8JJY6OpSlwgyNdQ== X-Received: by 2002:a9d:24e3:: with SMTP id z90mr4304153ota.39.1587662316179; Thu, 23 Apr 2020 10:18:36 -0700 (PDT) Received: from localhost.localdomain ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id y5sm746726otq.38.2020.04.23.10.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 10:18:35 -0700 (PDT) From: Nathan Chancellor To: Thomas Bogendoerfer , Masahiro Yamada Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, linux-kbuild@vger.kernel.org, Nick Desaulniers , Sami Tolvanen , Dmitry Golovin , Sedat Dilek , Nathan Chancellor Subject: [PATCH v3 4/4] MIPS: VDSO: Allow ld.lld to link the VDSO Date: Thu, 23 Apr 2020 10:18:07 -0700 Message-Id: <20200423171807.29713-4-natechancellor@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200423171807.29713-1-natechancellor@gmail.com> References: <20200419202128.20571-1-natechancellor@gmail.com> <20200423171807.29713-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Currently, when linking with ld.lld, this warning pops up: arch/mips/vdso/Makefile:70: MIPS VDSO requires binutils >= 2.25 CONFIG_LD_VERSION is set with scripts/ld-version.sh, which is specific to GNU ld. It returns 0 for ld.lld so CONFIG_MIPS_LD_CAN_LINK_VDSO does not set. ld.lld has a completely different versioning scheme (as it follows LLVM's versioning) and it does not have the issue mentioned in the comment block so it should be allowed to link the VDSO. With this patch, the VDSO successfully links and shows P_MIPS_PC32 in vgettimeofday.o. $ llvm-objdump -Dr arch/mips/vdso/vgettimeofday.o | grep R_MIPS_PC32 00000024: R_MIPS_PC32 _start 000000b0: R_MIPS_PC32 _start 000002bc: R_MIPS_PC32 _start 0000036c: R_MIPS_PC32 _start 00000468: R_MIPS_PC32 _start Reported-by: Dmitry Golovin Signed-off-by: Nathan Chancellor Link: https://github.com/ClangBuiltLinux/linux/issues/785 Link: https://github.com/llvm/llvm-project/commit/e364e2e9ce50c12eb2bf093560e1a1a8544d455a --- v2 -> v3: * No changes. v1 -> v2: * Move into Kconfig so that the warning does not happen. arch/mips/vdso/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/vdso/Kconfig b/arch/mips/vdso/Kconfig index 36a52158d849b..7aec721398d59 100644 --- a/arch/mips/vdso/Kconfig +++ b/arch/mips/vdso/Kconfig @@ -12,7 +12,7 @@ # the lack of relocations. As such, we disable the VDSO for microMIPS builds. config MIPS_LD_CAN_LINK_VDSO - def_bool LD_VERSION >= 225000000 + def_bool LD_VERSION >= 225000000 || LD_IS_LLD config MIPS_DISABLE_VDSO def_bool CPU_MICROMIPS || (!CPU_MIPSR6 && !MIPS_LD_CAN_LINK_VDSO)