From nobody Thu Sep 11 16:34:54 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70369C00528 for ; Fri, 4 Aug 2023 12:56:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229758AbjHDM4W (ORCPT ); Fri, 4 Aug 2023 08:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229617AbjHDM4S (ORCPT ); Fri, 4 Aug 2023 08:56:18 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74F9946A8 for ; Fri, 4 Aug 2023 05:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1691153771; bh=ZMXn8jVebSrtDL/LBnjGzGXwPqNhsZz6dbtGGMrDzdM=; h=From:To:Cc:Subject:Date:From; b=j52ZqcX3hlCsROiovI7K3ufrvQbD4+1eZJDWNURt85bBy5bhkdRCnJseSXRxqlI/C w5poC7S7IF8ag+vZ2ZxtjeF+uk87kX1lA/UCuvsFa0UeRC2ZHaOfdjmJedckrLjde3 2NTodXEeSykH3g9dARM29xIURFvU61z/MSAS0pDk= Received: from ld50.lan (unknown [101.88.28.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 79398600CE; Fri, 4 Aug 2023 20:56:11 +0800 (CST) From: WANG Xuerui To: Huacai Chen Cc: Nathan Chancellor , loongarch@lists.linux.dev, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui , Nick Desaulniers Subject: [PATCH] LoongArch: Drop -ffreestanding from CFLAGS Date: Fri, 4 Aug 2023 20:56:09 +0800 Message-Id: <20230804125609.2054719-1-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: WANG Xuerui As explained by Nick in the original issue: the kernel usually does a good job of providing library helpers that have similar semantics as their ordinary userspace libc equivalents, but -ffreestanding disables such libcall optimization and other related features in the compiler, which can lead to unexpected things such as CONFIG_FORTIFY_SOURCE not working (!). As it turns out to be the case, removing the flag does not impact the LoongArch kernel's normal operation at all; so just remove it to restore expected libcall semantics globally on this architecture. Closes: https://github.com/ClangBuiltLinux/linux/issues/1897 Reported-by: Nathan Chancellor Suggested-by: Nick Desaulniers Signed-off-by: WANG Xuerui --- arch/loongarch/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index b1e5db51b61c..db0d7210272d 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -83,7 +83,6 @@ KBUILD_CFLAGS_KERNEL +=3D -fPIE LDFLAGS_vmlinux +=3D -static -pie --no-dynamic-linker -z notext endif =20 -cflags-y +=3D -ffreestanding cflags-y +=3D $(call cc-option, -mno-check-zero-division) =20 load-y =3D 0x9000000000200000 --=20 2.40.0