From patchwork Thu May 12 22:29:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 1630439 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.a=rsa-sha256 header.s=google header.b=WOLCoUcB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kzmgd23Xwz9sG3 for ; Fri, 13 May 2022 08:30:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7FF76384F02A for ; Thu, 12 May 2022 22:30:18 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 3FDAB3846409 for ; Thu, 12 May 2022 22:29:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3FDAB3846409 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x429.google.com with SMTP id w4so9062364wrg.12 for ; Thu, 12 May 2022 15:29:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=VFIYXFg2Xt8QSBItVEocElyNjT2bHRKRtfY8U8eaG+E=; b=WOLCoUcBo1CRjD+PW3WbJVyxvijlqJtQdhJ+6qdf+ey+V+K9x+gQh7Z4nQF9nJq8Bm 1mdYG8e0Ee0C9B0zgNg2+1YtHaDxe9LAdvyC7yJYj46uQtj4kBEqnW4Ss2/GIwojnuI7 az2S1jt4rMkKYmOagYFh4Rb54shHU+B0fA46yESEIUm7GJXiLCUiRw3iE8jWwvjnRvSQ 2TU8Ks9HJpH4KgqBI2rZ/CiHus+1nnI1t4WAJo9a8elrLQLKXm5dJTD6NQm84j5j6S8M n0dawWoOltvVjRl1jscFGdOVRVpcFJVO+QRhVk6oHpEPMTqa687M0bth6JQy+uVzbO1T VoXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=VFIYXFg2Xt8QSBItVEocElyNjT2bHRKRtfY8U8eaG+E=; b=uoOGFKqjzx/VMrD08QjK+/uolO4sMBpTilIOwLKret3QAdXLErhycNP4ZJqHr/md8M Oisc5d9F+4/OqH44blgdXjz9c5qkxc03wHkKYlhPu+emc1lqIIS11e9+8VqByea60qyC tQVh4unnkRZAd2M204qrlMSNuBI1n8J7AO1ziS/YYPaAS9CKr1W73N1LI0nRfx1St4/I vxWpbv+dUqAR2O2pIwbjKYt8+wecf4z7mr3PFnm4UT/z9aUukBy5A79GAuHfCQtwNRh7 M6sYIvsCyGQj2NWqMio/s3z5EYeV7Vma0P+NMoy0W3Ry7va/Fsev+ze/DELvHrcsXgux KeNg== X-Gm-Message-State: AOAM530yqyXXLadh9EK/PyigBSWkS2zY02ikiRHOvK4Ld1DibhSqtT4j ERxxvLVnNZRbJsD2gumtuBGJJARGOMTrdVjA X-Google-Smtp-Source: ABdhPJx5ujS0dAvrAQ905P0hv02Mdd7ZO0aUdUF5lyY/XtZC5AZaqGYmZEijGi7xZDVkarpKzUbrgA== X-Received: by 2002:a5d:510b:0:b0:20a:cb62:d9fe with SMTP id s11-20020a5d510b000000b0020acb62d9femr1519937wrt.108.1652394553066; Thu, 12 May 2022 15:29:13 -0700 (PDT) Received: from tpp.orcam.me.uk (tpp.orcam.me.uk. [2001:8b0:154:0:ea6a:64ff:fe24:f2fc]) by smtp.gmail.com with ESMTPSA id h18-20020a1ccc12000000b003943558a976sm663152wmb.29.2022.05.12.15.29.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 May 2022 15:29:12 -0700 (PDT) Date: Thu, 12 May 2022 23:29:11 +0100 (BST) From: "Maciej W. Rozycki" To: libc-alpha@sourceware.org Subject: [PATCH v2 4/4] RISC-V: Use an autoconf template to produce `preconfigure' In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Waterman , Mao Han , Andreas Schwab , Joseph Myers Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Avoid fiddling with autoconf internals and use AC_DEFINE_UNQUOTED to define macros in the configuration headers rather than handcoding an equivalent shell sequence with the use of the `as_echo' undocumented variable. Switch to using AC_MSG_ERROR rather than `echo' and `exit' directly for error handling. Owing to the lack of any kind of error annotation it makes it difficult to spot the message in the flood in a parallel build and neither it is logged in `config.log'. Reviewed-by: Palmer Dabbelt Acked-by: Palmer Dabbelt --- Changes from v1: - Convert the script to an autoconf template and use AC_MSG_ERROR. - Also handle configuration macro definitions, using AC_DEFINE_UNQUOTED. --- sysdeps/riscv/preconfigure | 33 +++++++++++---------- sysdeps/riscv/preconfigure.ac | 64 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 15 deletions(-) glibc-riscv-preconfigure-as-fn-error.diff Index: glibc/sysdeps/riscv/preconfigure =================================================================== --- glibc.orig/sysdeps/riscv/preconfigure +++ glibc/sysdeps/riscv/preconfigure @@ -1,3 +1,6 @@ +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! +# Local preconfigure fragment for sysdeps/riscv + case "$machine" in riscv*) xlen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_xlen \(.*\)/\1/p'` @@ -9,8 +12,7 @@ riscv*) 64 | 32) ;; *) - echo "Unable to determine XLEN" >&2 - exit 1 + as_fn_error 1 "Unable to determine XLEN" "$LINENO" 5 ;; esac @@ -20,15 +22,13 @@ riscv*) with_fp_cond=1 ;; 32) - echo "glibc does not yet support systems with the F but not D extensions" >&2 - exit 1 + as_fn_error 1 "glibc does not yet support systems with the F but not D extensions" "$LINENO" 5 ;; "") with_fp_cond=0 ;; *) - echo "Unable to determine FLEN" >&2 - exit 1 + as_fn_error 1 "Unable to determine FLEN" "$LINENO" 5 ;; esac @@ -37,31 +37,34 @@ riscv*) abi_flen=0 ;; single) - echo "glibc does not yet support the single floating-point ABI" >&2 - exit 1 + as_fn_error 1 "glibc does not yet support the single floating-point ABI" "$LINENO" 5 ;; double) abi_flen=64 ;; *) - echo "Unable to determine floating-point ABI" >&2 - exit 1 + as_fn_error 1 "Unable to determine floating-point ABI" "$LINENO" 5 ;; esac case "$atomic" in __riscv_atomic) - ;; + ;; *) - echo "glibc requires the A extension" >&2 - exit 1 + as_fn_error 1 "glibc requires the A extension" "$LINENO" 5 ;; esac base_machine=riscv machine=riscv/rv$xlen/$float_machine - $as_echo "#define RISCV_ABI_XLEN $xlen" >>confdefs.h - $as_echo "#define RISCV_ABI_FLEN $abi_flen" >>confdefs.h + cat >>confdefs.h <<_ACEOF +#define RISCV_ABI_XLEN $xlen +_ACEOF + + cat >>confdefs.h <<_ACEOF +#define RISCV_ABI_FLEN $abi_flen +_ACEOF + ;; esac Index: glibc/sysdeps/riscv/preconfigure.ac =================================================================== --- /dev/null +++ glibc/sysdeps/riscv/preconfigure.ac @@ -0,0 +1,64 @@ +GLIBC_PROVIDES[]dnl See aclocal.m4 in the top level source directory. +# Local preconfigure fragment for sysdeps/riscv + +case "$machine" in +riscv*) + xlen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_xlen \(.*\)/\1/p'` + flen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_flen \(.*\)/\1/p'` + float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_float_abi_\([^ ]*\) .*/\1/p'` + atomic=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | grep '#define __riscv_atomic' | cut -d' ' -f2` + + case "$xlen" in + 64 | 32) + ;; + *) + AC_MSG_ERROR([Unable to determine XLEN], [1]) + ;; + esac + + case "$flen" in + 64) + float_machine=rvd + with_fp_cond=1 + ;; + 32) + AC_MSG_ERROR([glibc does not yet support systems with the F but not D extensions], 1) + ;; + "") + with_fp_cond=0 + ;; + *) + AC_MSG_ERROR([Unable to determine FLEN], [1]) + ;; + esac + + case "$float_abi" in + soft) + abi_flen=0 + ;; + single) + AC_MSG_ERROR([glibc does not yet support the single floating-point ABI], [1]) + ;; + double) + abi_flen=64 + ;; + *) + AC_MSG_ERROR([Unable to determine floating-point ABI], [1]) + ;; + esac + + case "$atomic" in + __riscv_atomic) + ;; + *) + AC_MSG_ERROR([glibc requires the A extension], [1]) + ;; + esac + + base_machine=riscv + machine=riscv/rv$xlen/$float_machine + + AC_DEFINE_UNQUOTED([RISCV_ABI_XLEN], [$xlen]) + AC_DEFINE_UNQUOTED([RISCV_ABI_FLEN], [$abi_flen]) + ;; +esac