From patchwork Wed Nov 29 23:29:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 13473636 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B695FC4167B for ; Wed, 29 Nov 2023 23:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xM6aFz1z40vklUdruGZymsUrXXzvUtaxgA1O+QTrAxU=; b=CO1kAkQHAZ9NWs mssYVtXaSU+Mn7q6LqWoNRG5AW0c5esbvU7zrHqq2pCrJ76iQfaU+4GiV4ihXNPFLQc64Jh+16uiB JmCNUEpMW1PU9ckvQZjkt99N6hKOTmaPDMw8gwyysND0Sy9o1X4niRb2Umq1wOyruH/X99Dh/Yebi QgCjkAV+wDe1ZA8VEmKwH/9FjO/Fb6oLOE5HTA+pP6YlFKvR8JrtqwZYk3PjCtzUO7u6+Poqjkl1x opaJVyyspG3oXJE6qPDirDwns36WCsImogCamg1smvI0hpo2PJ/iMl0v7Tv3Aqf/3rmjh+dE1PCnk wMtY+4Xx8frpkKdrzOAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8U0P-009VZ7-0s; Wed, 29 Nov 2023 23:30:09 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8U0L-009VYG-2H for linux-riscv@lists.infradead.org; Wed, 29 Nov 2023 23:30:07 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F35A761D58; Wed, 29 Nov 2023 23:30:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DD30C433C8; Wed, 29 Nov 2023 23:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701300604; bh=zsE7SX0g2vjeQkJDJuTcq0Y0j0eQ3wWtetQ4VKglZQk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fYZz+QBIMFmpmpYy4fFVG+7hRNcZCJ07pdSZhHJuAVWnKxV2ZuMgJOb63FbYwZ1gP Lc6VPD0l2+9rH6pir8fcPq/kAiEzcOuhB899+xRoUaJthE5dUsdY4lWU/DQ2o8YdiM N0XnfwkpchTb1azx2uFVALyCE7MRWR92+mxPLM6oHnENMfqaN8WGmQAKmVACmkVJAj JODfwpLgNBLzShP0mSzUQgg5oBA2XfBMK3fFTcXlnU7Slm8L5jwlN5tb5vV/XNVr4M 2KuJfwMQ1mQcW3VBu0XIDr3oIyk/cRrKXhZi1HcNskUSdJojzl+QjJifppyosKNqUv b/minoy0f/Wew== From: Nathan Chancellor Date: Wed, 29 Nov 2023 16:29:47 -0700 Subject: [PATCH 1/2] riscv: Hoist linker relaxation disabling logic into Kconfig MIME-Version: 1.0 Message-Id: <20231129-riscv-restrict-dwarf5-llvm-v1-1-ec0d368fb538@kernel.org> References: <20231129-riscv-restrict-dwarf5-llvm-v1-0-ec0d368fb538@kernel.org> In-Reply-To: <20231129-riscv-restrict-dwarf5-llvm-v1-0-ec0d368fb538@kernel.org> To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, conor@kernel.org Cc: maskray@google.com, ndesaulniers@google.com, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1665; i=nathan@kernel.org; h=from:subject:message-id; bh=zsE7SX0g2vjeQkJDJuTcq0Y0j0eQ3wWtetQ4VKglZQk=; b=owGbwMvMwCUmm602sfCA1DTG02pJDKnpJ6sd9f7fiWc6sav8zfStjCWH+mV8XsX9l7z3S8By3 n7ZY05HO0pZGMS4GGTFFFmqH6seNzScc5bxxqlJMHNYmUCGMHBxCsBEdPgYGZ4fvVg8+fTx/LPf l5e5r/0d92bV5S9prmucHEUmccm4uTUw/A8rr5GdfW3/TPeO7UkTXi4xdFl9auJtfSY13haNZOk KNVYA X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_153005_814421_139EF197 X-CRM114-Status: UNSURE ( 8.97 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Certain configurations may need to be disabled if linker relaxation is in use, such as DWARF5 with ld.lld < 18. Hoist the logic of whether or not linker relaxation is in use into Kconfig so decisions can be made at configuration time. Signed-off-by: Nathan Chancellor Reviewed-by: Fangrui Song --- arch/riscv/Kconfig | 5 +++++ arch/riscv/Makefile | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 95a2a06acc6a..72be1d8122a3 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -181,6 +181,11 @@ config HAVE_SHADOW_CALL_STACK # https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769 depends on $(ld-option,--no-relax-gp) +config RISCV_USE_LINKER_RELAXATION + def_bool y + # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985 + depends on !LD_IS_LLD || LLD_VERSION >= 150000 + config ARCH_MMAP_RND_BITS_MIN default 18 if 64BIT default 8 diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index a74be78678eb..e383aa9e2757 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -43,8 +43,7 @@ else KBUILD_LDFLAGS += -melf32lriscv endif -ifeq ($(CONFIG_LD_IS_LLD),y) -ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y) +ifndef CONFIG_RISCV_USE_LINKER_RELAXATION KBUILD_CFLAGS += -mno-relax KBUILD_AFLAGS += -mno-relax ifndef CONFIG_AS_IS_LLVM @@ -52,7 +51,6 @@ ifndef CONFIG_AS_IS_LLVM KBUILD_AFLAGS += -Wa,-mno-relax endif endif -endif ifeq ($(CONFIG_SHADOW_CALL_STACK),y) KBUILD_LDFLAGS += --no-relax-gp From patchwork Wed Nov 29 23:29:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 13473635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A0C6C4167B for ; Wed, 29 Nov 2023 23:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SPsTQKjJtP8sLHFwYUanGqBRFhDwxqYZRK7r3pLjHW4=; b=Lc9CfMDemNT8C0 mwRz8Icdhy5Up2r0GhVaDpVr1ia28f0hcZlwHI7JfMHBvujhDTTB5TDUTaEcxcCok14KhSQ7UURxo bbOlc+IjxqHwNXZd0FcAC7nB0j7eBGOj6ZJ3yUs+REcbfiwOi2T0R17uWr2MBaYGmpUj+EhXzqb6M n7sWVLQ6AsYHlCvrbOpMSo10lnshJZJ0/MoBV43yW2Y3vHb99sBiOIaf2LdAcZFgfpgFzNaJpWus7 eK0iBXMkdpvC12zs7Xa22tu698SH4uekfn4436QmH47JfP0JfiHs9wXMrNr2ukXlXwT7eKtvhT2+E 0OJVOGD711WjBfPDvyLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8U0T-009VZd-1l; Wed, 29 Nov 2023 23:30:13 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8U0M-009VYS-0f for linux-riscv@lists.infradead.org; Wed, 29 Nov 2023 23:30:08 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B725B61D5C; Wed, 29 Nov 2023 23:30:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2FF9C433CC; Wed, 29 Nov 2023 23:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701300605; bh=A8sPnu2KKz5CALRbBlnZLQ9BA9ZLoGfN4oxpbkVxKs8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=sOrZxI4i2MaUtp68oIZ9YXBhsRtPYuENl8cd8ASOnSMgmuOvvfgmhOkdjL15yzPRm R1mFwLl9Dp0klcSgLGhHmhC1fkDRw8icGapy4fbK+W9gcg8DrmGQyJCdtVGwC04IMB aKPa0FlMnrqtnWzZsTYDqK2m4vGPHjC90zuD508f3ZGkTrRmapE0I5nGMwaOQsfMcQ AvLczgF1SgSmtsgmkIB+UIOnH1f2caTLiRRr6HmyTstvlWDz+0gsWyjUM22FW/TirZ 5Ps0CivWpSDLK2cEOZl7P/mbZx4Qz1IekgyD3vgdd8OqyN0yXJ142m6phTWhXsUeFq q80MmGPKlaicw== From: Nathan Chancellor Date: Wed, 29 Nov 2023 16:29:48 -0700 Subject: [PATCH 2/2] riscv: Restrict DWARF5 when building with LLVM to known working versions MIME-Version: 1.0 Message-Id: <20231129-riscv-restrict-dwarf5-llvm-v1-2-ec0d368fb538@kernel.org> References: <20231129-riscv-restrict-dwarf5-llvm-v1-0-ec0d368fb538@kernel.org> In-Reply-To: <20231129-riscv-restrict-dwarf5-llvm-v1-0-ec0d368fb538@kernel.org> To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, conor@kernel.org Cc: maskray@google.com, ndesaulniers@google.com, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2408; i=nathan@kernel.org; h=from:subject:message-id; bh=A8sPnu2KKz5CALRbBlnZLQ9BA9ZLoGfN4oxpbkVxKs8=; b=owGbwMvMwCUmm602sfCA1DTG02pJDKnpJ6sn+67d9mzvBvNy7bmKz/wSdxrVrHNi3/4rx9P+n H7gr4mzOkpZGMS4GGTFFFmqH6seNzScc5bxxqlJMHNYmUCGMHBxCsBESiYxMsxc23QiQlXUI+RL SMQWizPzZm46NG/1VO/Tr9f6vJq76e1+RobXN5c9Zr365cEirbTq0h0lz1eabZDp3/oqwF94UkR 44zYWAA== X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_153006_330327_4E3A1BA8 X-CRM114-Status: UNSURE ( 9.36 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org LLVM prior to 18.0.0 would generate incorrect debug info for DWARF5 due to linker relaxation, which was worked around in clang by defaulting RISC-V to DWARF4 [1]. Unfortunately, this workaround does not work for the kernel because the DWARF version can be independently changed from the default in Kconfig. Do not allow DWARF5 to be selected for RISC-V when using linker relaxation (ld.lld >= 15.0.0) and a version of LLVM that does not have the fixes (the integrated assembler [2] and ld.lld [3] < 18.0.0) necessary to generate the correct debug info. Link: https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 [1] Link: https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a [2] Link: https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 [3] Signed-off-by: Nathan Chancellor --- arch/riscv/Kconfig | 9 +++++++++ lib/Kconfig.debug | 1 + 2 files changed, 10 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 72be1d8122a3..81b473cb47b0 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -186,6 +186,15 @@ config RISCV_USE_LINKER_RELAXATION # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985 depends on !LD_IS_LLD || LLD_VERSION >= 150000 +# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 +config ARCH_HAS_BROKEN_DWARF5 + def_bool y + depends on RISCV_USE_LINKER_RELAXATION + # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a + depends on AS_IS_LLVM && AS_VERSION < 180000 + # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 + depends on LD_IS_LLD && LLD_VERSION < 180000 + config ARCH_MMAP_RND_BITS_MIN default 18 if 64BIT default 8 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index cc7d53d9dc01..a0ebce05a368 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -282,6 +282,7 @@ config DEBUG_INFO_DWARF4 config DEBUG_INFO_DWARF5 bool "Generate DWARF Version 5 debuginfo" select DEBUG_INFO + depends on !ARCH_HAS_BROKEN_DWARF5 depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) help Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc