From patchwork Mon May 27 11:18:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 90949 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22EA03858433 for ; Mon, 27 May 2024 11:21:06 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id A8A4A3858C35 for ; Mon, 27 May 2024 11:19:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A8A4A3858C35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A8A4A3858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716808773; cv=none; b=oqf9YtUafasegcNkSfgjKes6qy+tzPQ4ZFkCsmtVojJcJpDdALS6jn4Ea5i7pzIezwV/BvG/iTVajrEi4yE2laVlo7lA+MImBS4wLWjA07k43fz9dCMsBM5vFHCeSnrXf3bDM1eT3ZQ2i4Gy1s1YZ5I2NxHvy/fjRLAWV1/C2NE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716808773; c=relaxed/simple; bh=sp8BAn6PW1iPdgULjL8a8KZFO65B1LUGdDTOwx0L8jw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pdhCUPLg6cQjZGiGGAoDnRjfJhIt8InBtBXBlhX+c8gsFQtlW7Flo1MxIAG3MvNbxzTjRb9ST+gu22h886g+S8ihYizIU+N8We7AtWNNCp7rxPpIvsM1iTnL7CGAFh6EG2Zalj+Lvw/SubZnWaLy4aATzqhcKdD1b+g1iJFxaG4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5295f201979so3314203e87.2 for ; Mon, 27 May 2024 04:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1716808766; x=1717413566; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+apeuom6RsFcela7h9RztLgGg80Twa+f2x4XT0EMiN8=; b=Y1vreqgKYtMTtY82NWeYkPrB8WCCO3rKS8FYV9lyj25qeqPUGHPnzVxU4dSHogbUFT SgCHdZP4HRgosJM4FMnzZvBgnpIz9g3rfI6g+PYyFzh6HS1wFIt+15w2pOMxUDgxRixE dWg1H8L5XUUdgW06mWPsGlcL9FnOUluuEPqf5yUUz6bL6wTcP1QkZuQyXhTT268pfCUM 4LvcKqE+nMRMWsWZ/H4lBdG96rG8tnxRYM+5P/DyG71DWW8DV0spSDuQ1MZjShh6rtcF JcBQu31wsmjXabjT2XL4p8+8M1I4OWg2KvceRfBT/MyIx/p/yRLBLlPImAr3j4NH+UZC 9g4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716808766; x=1717413566; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+apeuom6RsFcela7h9RztLgGg80Twa+f2x4XT0EMiN8=; b=P52t+sMnx7YzcafDXjuA05syu86FHa769/pYEh621o+N03z3pEhsWI2JAm6I6wsVIb 6TDIMDU6ggfUiTwkaP7dru/c2a72M8R9anQvKX+BxeDqjGRiQ0O5eHeSQHe8TAiXWQft 2C02nR/XQsgfU0DY4zbKaEePCom4PWq2GgWtE5bgRhUwoSWDqC2H2MDbAKFolS1JLHhD fpYw+8awCrfgfJCSJgouFl2f0fPQ1l1KjnQTbUgHb0Hd6G8ra465xvkIi4dEz09qtrUW jVaBwtyHofHn5KOCB+zCL+e6DN7/4K2yEdzEQrhNxFYKBMnVzgcdL//+lsuFNOO4MENL dl0w== X-Gm-Message-State: AOJu0YzfGk/5nxBKXkNhcodzx0YQ9IBH97WUX/NHP4gNLzPYfJ4BtNZh 585irrrQzLEsAXJlvjjpDzTDSiwqFW/GV+Hx5tEHM061OKv5uD/PkyyMg/tHrIJlsgUpUwxIqqz mPdr3mA== X-Google-Smtp-Source: AGHT+IGnmyu9mUcJxjpfMEGJ0Dyukb6olGvqYtW+hrFPN8qWGUiLDHI1iiLFjDGU9FCukOstD2Xyew== X-Received: by 2002:a05:6512:5c9:b0:523:3be3:cbfe with SMTP id 2adb3069b0e04-52966ca8800mr5033466e87.65.1716808765846; Mon, 27 May 2024 04:19:25 -0700 (PDT) Received: from beast.fritz.box (static.239.130.217.95.clients.your-server.de. [95.217.130.239]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5296e887b1asm519861e87.32.2024.05.27.04.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 04:19:25 -0700 (PDT) From: =?utf-8?q?Christoph_M=C3=BCllner?= To: libc-alpha@sourceware.org, Adhemerval Zanella , Palmer Dabbelt , Darius Rad , Andrew Waterman , Philipp Tomsich , Evan Green , DJ Delorie , Vineet Gupta , Kito Cheng , Jeff Law Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [PATCH v2 09/15] RISC-V: Add compiler test for Zbb function attribute support Date: Mon, 27 May 2024 13:18:54 +0200 Message-ID: <20240527111900.1060546-10-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240527111900.1060546-1-christoph.muellner@vrull.eu> References: <20240527111900.1060546-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_MANYTO, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Target function attributes that allow enabling RISC-V extensions have been added to GCC and LLVM a few months ago. This patch adds a configure test to see if the compiler supports enabling Zbb via this mechanism. Note, that unknown target attributes just issue a warning, so this test needs to build with -Werror. Tested with GCC 13 (fails) and GCC 14 (succeeds). Signed-off-by: Christoph Müllner --- config.h.in | 3 +++ sysdeps/riscv/configure | 27 +++++++++++++++++++++++++++ sysdeps/riscv/configure.ac | 18 ++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/config.h.in b/config.h.in index 9a83b774fa..10a670441c 100644 --- a/config.h.in +++ b/config.h.in @@ -273,6 +273,9 @@ /* PowerPC32 uses fctidz for floating point to long long conversions. */ #define HAVE_PPC_FCTIDZ 0 +/* RISC-V function attributes for Zbb. */ +#define HAVE_RISCV_FATTRIBUTE_ZBB 0 + /* Define if PIE is unsupported. */ #undef PIE_UNSUPPORTED diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure index c8f01709f8..e0f57fcf9b 100644 --- a/sysdeps/riscv/configure +++ b/sysdeps/riscv/configure @@ -80,3 +80,30 @@ if test "$libc_cv_static_pie_on_riscv" = yes; then printf "%s\n" "#define SUPPORT_STATIC_PIE 1" >>confdefs.h fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for RISC-V Zbb target attribute support" >&5 +printf %s "checking for RISC-V Zbb target attribute support... " >&6; } +if test ${libc_cv_compiler_fattribute_zbb+y} +then : + printf %s "(cached) " >&6 +else $as_nop + cat > conftest.c <&5 \ + 2>&5 ; then + libc_cv_compiler_fattribute_zbb=yes +fi +rm -f conftest* +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_compiler_fattribute_zbb" >&5 +printf "%s\n" "$libc_cv_compiler_fattribute_zbb" >&6; } +if test "$libc_cv_compiler_fattribute_zbb" = yes; then + printf "%s\n" "#define HAVE_RISCV_FATTRIBUTE_ZBB 1" >>confdefs.h + +fi +config_vars="$config_vars +have-fattribute-zbb-support = $libc_cv_compiler_fattribute_zbb" + diff --git a/sysdeps/riscv/configure.ac b/sysdeps/riscv/configure.ac index ee3d1ed014..a7e16dcf83 100644 --- a/sysdeps/riscv/configure.ac +++ b/sysdeps/riscv/configure.ac @@ -43,3 +43,21 @@ EOF if test "$libc_cv_static_pie_on_riscv" = yes; then AC_DEFINE(SUPPORT_STATIC_PIE) fi + +dnl Test if we have Zbb via function attributes +AC_CACHE_CHECK([for RISC-V Zbb target attribute support], + libc_cv_compiler_fattribute_zbb, [dnl +cat > conftest.c <&AS_MESSAGE_LOG_FD \ + 2>&AS_MESSAGE_LOG_FD ; then + libc_cv_compiler_fattribute_zbb=yes +fi +rm -f conftest*]) +if test "$libc_cv_compiler_fattribute_zbb" = yes; then + AC_DEFINE(HAVE_RISCV_FATTRIBUTE_ZBB) +fi +LIBC_CONFIG_VAR([have-fattribute-zbb-support], [$libc_cv_compiler_fattribute_zbb])