From patchwork Thu Jan 18 18:02:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Wachsmuth X-Patchwork-Id: 1888192 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=GGwLegFK; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=GoITl9vF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TG9Zm0Svpz1yPV for ; Fri, 19 Jan 2024 05:02:56 +1100 (AEDT) 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:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=GN8SMj5ifWts7RbMA6KKErOGOJPtv4Y90ptpuLkkvLg=; b=GGwLegFKuk9dml /st+Gfk5FzFTVk9bk5zakBCzRWG4coyE447MZZ/PrOjlMzkVRtRN10BeIxmEH62Jr1sHq5U9oEtjc Qoz6iYowpWgQ/XNYtWAknEOAA9Qx++JNheaZe8bCE5H4vBD1MNvfpiX6ILN+0cBjkv1+Je9Bh15vZ uWW/fwc7TufBIc9auJGr0HEH07YKFH3Up5iuKdeE2kjdDq41Sl3LdA5vHXbj3XQGGG0DpX/IAJ+BB jw4m6ivXxDz2nrdgO+aeieCTaH+XbwQlDBzW1+7pEM5YhwlvYhZGlyp0Oa89bbhGyxt6jBSwZzd/r VQPCd7adhbDiExCg9X5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQWiu-003SSO-2I; Thu, 18 Jan 2024 18:02:40 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQWir-003SRO-1z for opensbi@lists.infradead.org; Thu, 18 Jan 2024 18:02:39 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-337b38d6568so3257052f8f.1 for ; Thu, 18 Jan 2024 10:02:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705600953; x=1706205753; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=HVPKlURynHC/2gInYTQbQcDxgYDiko1Atlfn5vYnx1w=; b=GoITl9vFdo0PIGwbuMd50Jz/kf2X2zQbYf+3mRyV+PidDsUCkk1VUpl7tlthV434o0 zxHHo3FxJ/auCUmr2PpJOs64izHlzpz1wMluiV/ng7b6QEuxMB1rj4OLfVsrXZt3pk+i chOewoGABT4Mkvl3ZnhSh0wmMcW/kqz+Y+OdR9Yma5Lk4B550zbtIv/MCYTOHeCBuHaj x1cjrYG2Zl08bLxdsv7r3Of0f3e9YdHLIjgHPYwk7UMnQt7Q9dGLHhkf2Ljr0ALd9F0O h0s948+/VRbAQdU7XEu4pOEOGnIoA4M7IGCXjDFX0sxtFlT+3xMW+f15tN4H5nrOFqGf ALpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705600953; x=1706205753; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HVPKlURynHC/2gInYTQbQcDxgYDiko1Atlfn5vYnx1w=; b=YsqlJlLJUOd8VjRCoykQCpc86zser/cyLulYF0M70f2kp6iEnbGOMSzVWpWAbzzhTK Yriq+YZH/kKJm2PqiZh0cHG8Sgv4foeBNLbvxA4YrFRod3DaPC6wz/YaPC0zoUacG5vL QPxcLqygFrU5pw3QKazQCrwZvFwuPj0lfXp6bRVaNw3iaxt9fstActfxW4Zc+aG+dN19 9VDMkBlEp7lexHfrS2WbMoeR2m/HnUZrMx6EXF65i7+iqy7egylwW+FaLTK9U54fOmX1 MsCYowVx5hIa21sA5dqkQ8Zqecmt+8befrqaa56Y5poUFPqC8TMOgk6LqPytdXmyuNDf JsRg== X-Gm-Message-State: AOJu0Yxr+vC+aYJIWepn4+GfqwHM/Wy4YpoD+86JmQa7I6apphi/FMvz NP5HY9CA9ey5VX1K5oyCP93Es+yDReYoADmMRVkgKoetxD5qvoyK1dsfbCUK X-Google-Smtp-Source: AGHT+IGAE7rDO/whuki0TG0dkG5WoOt/Bt+jCjoO1JD6zV6caOPFF/JcniNwFwKzppp3FOU+aLC14Q== X-Received: by 2002:a1c:7519:0:b0:40e:3529:b874 with SMTP id o25-20020a1c7519000000b0040e3529b874mr777382wmc.172.1705600952901; Thu, 18 Jan 2024 10:02:32 -0800 (PST) Received: from kalles-mbp.fritz.box (p200300e3e71bca0039c7fb9688d48adf.dip0.t-ipconnect.de. [2003:e3:e71b:ca00:39c7:fb96:88d4:8adf]) by smtp.gmail.com with ESMTPSA id fk4-20020a056402398400b005576a384b46sm9766512edb.10.2024.01.18.10.02.32 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 18 Jan 2024 10:02:32 -0800 (PST) From: Kalle Wachsmuth To: opensbi@lists.infradead.org Subject: [PATCH v2] Makefile: don't pass -mstrict-align if not supported Date: Thu, 18 Jan 2024 19:02:31 +0100 Message-Id: <20240118180231.30300-1-kalle.wachsmuth@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240118_100237_672683_06AE3330 X-CRM114-Status: UNSURE ( 9.18 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Support for that option will be added in LLVM 18: https://github.com/llvm/llvm-project/commit/23ce5368409c760f3dd49d0f17f34772b0b869d8 Clang 17.0.6, however, will error when passed the `-mstrict-align` flag. We should only use the flag if it is supported. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:432 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [kalle.wachsmuth[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Support for that option will be added in LLVM 18: https://github.com/llvm/llvm-project/commit/23ce5368409c760f3dd49d0f17f34772b0b869d8 Clang 17.0.6, however, will error when passed the `-mstrict-align` flag. We should only use the flag if it is supported. Signed-off-by: Kalle Wachsmuth Reviewed-by: Xiang W Reviewed-by: Anup Patel --- (I'm using Homebrew Clang on macOS.) Makefile | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) -- 2.39.3 (Apple Git-145) diff --git a/Makefile b/Makefile index de4e73a..66048c3 100644 --- a/Makefile +++ b/Makefile @@ -170,6 +170,9 @@ OPENSBI_LD_PIE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) $(USE_LD_FLAG) -fP # Check whether the compiler supports -m(no-)save-restore CC_SUPPORT_SAVE_RESTORE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mno-save-restore -x c /dev/null -o /dev/null 2>&1 | grep -e "-save-restore" >/dev/null && echo n || echo y) +# Check whether the compiler supports -m(no-)strict-align +CC_SUPPORT_STRICT_ALIGN := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mstrict-align -x c /dev/null -o /dev/null 2>&1 | grep -e "-mstrict-align\|-mno-unaligned-access" >/dev/null && echo n || echo y) + # Check whether the assembler and the compiler support the Zicsr and Zifencei extensions CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null 2>&1 | grep "zicsr\|zifencei" > /dev/null && echo n || echo y) @@ -337,11 +340,14 @@ CFLAGS += -O0 else CFLAGS += -O2 endif -CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align -# enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE +CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls +# Optionally supported flags ifeq ($(CC_SUPPORT_SAVE_RESTORE),y) CFLAGS += -mno-save-restore endif +ifeq ($(CC_SUPPORT_STRICT_ALIGN),y) +CFLAGS += -mstrict-align +endif CFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA) CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) CFLAGS += $(RELAX_FLAG) @@ -355,11 +361,14 @@ CPPFLAGS += $(platform-cppflags-y) CPPFLAGS += $(firmware-cppflags-y) ASFLAGS = -g -Wall -nostdlib -ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align -# enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE +ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls +# Optionally supported flags ifeq ($(CC_SUPPORT_SAVE_RESTORE),y) ASFLAGS += -mno-save-restore endif +ifeq ($(CC_SUPPORT_STRICT_ALIGN),y) +ASFLAGS += -mstrict-align +endif ASFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA) ASFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) ASFLAGS += $(RELAX_FLAG)