From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 92FE61F47C for ; Tue, 24 Jan 2023 13:02:58 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=clisp.org header.i=@clisp.org header.a=rsa-sha256 header.s=strato-dkim-0002 header.b=XeLA2y3b; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKIwu-0007M1-7m; Tue, 24 Jan 2023 08:02:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKIwj-0007Kb-BX for bug-gnulib@gnu.org; Tue, 24 Jan 2023 08:02:43 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.160]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKIwg-0000UY-SF; Tue, 24 Jan 2023 08:02:41 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1674565354; cv=none; d=strato.com; s=strato-dkim-0002; b=Xgq457otsxYODzv949CicdLYlNzN5s8Q3x+Nnfe0ffnj2BOps/gXQ/OOWGvqSUENAk lwq3NME51g0rJDczH0BjmCoEEUAK4+Ay29mTwajDYVs/5+6yzaGwC729cWMmlCc1DIiX cw3cRF9M4Jo8buaYdCjtUXGWAbsmeS/XvGMYgAhHELdu4SQcmD5qmVMXr/EQb0XQ1JOy EXxeaN+ws/abOpZ4iMZ/l72IzvPFTigsxTSqZd05LwPK+PLhGzlhBGutpYxLBcX8rafj oiQh2XwtuFWAXHQTlCnY4bLnRDOKhOa8eXb88kD8KZSTKK935cuqaovSL4boAwkA+eOP 1IuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1674565354; s=strato-dkim-0002; d=strato.com; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=X3MbCfdrg5n7Zq1EJ8FA36zjrFmORGOgHf1nlIlUNck=; b=qMNWPPkA5NUOz6qqKg39Q4aQGUPLqemZ8n7jhz/NlmHgLjTaSHm8F+Q4Y/PytbhtiW 9tYpvm8FC7ORRRx6f5UZbsFBzrfCFgQUNWzlG7w9X7qHhgTfL6Ydr6nzshRtK0flfx22 uxEf2X83PHOyNreyxMe4+C9P8OZAu1Uc+v+hVcmhDytvbvd2sdlrRYtGSvHHBtIMCZ5Q NQ8V40+zyrEi6AiHZTL+pAUsMZwYua/tNTuGqeDfKC0H5OmGRepaVMwNgtHJKxhBqGe4 x++7ydGUROg7Tqrfcn/g+1c6u6Y6SsjryzVG6XKS7cf2lYQ3otLLDhjXitjexXLpxmJb lnlw== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1674565354; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=X3MbCfdrg5n7Zq1EJ8FA36zjrFmORGOgHf1nlIlUNck=; b=XeLA2y3bIuSewFs0Cwuk/wIeZyY+yliIlVVzlnFYiwG3WjFhxGjBiIwnNj1hxCZFcu hbRhVzb58/JU6zk59uDMuKkrpr5S2nrCdyIoSeUmYAS3wkcykZUm/09shFmYcbZUtmrt RbQ7nZ921EOaoNmQZeVRCCTujOTZ+HxCtPi0ajQgOHHvqUH2TlaWo2gViztqRvHHADXo Y7t2gNa0OEKI2VKbqMksUkZPB5KD8/BBGSSaZDl9hQYYTAmofDLDwNTsZZV/gSE+QQtJ GHjcSkjsPYN1WHku1JnrWqQouv3ko9xuwaDEYGSPNPe2q7mnffRwm4PL0VH/Y7ZhQKak hqGg== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpOQ2vMqqbensZiljpU4KIPWf4Je" Received: from nimes.localnet by smtp.strato.de (RZmta 49.2.2 AUTH) with ESMTPSA id 098542z0OD2Y2X5 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 24 Jan 2023 14:02:34 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: alignasof, stdalign: Fix a compilation error on FreeBSD 12.0 Date: Tue, 24 Jan 2023 14:02:34 +0100 Message-ID: <2593218.SeglcFtGQu@nimes> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2913594.9ZrGZTpANS" Content-Transfer-Encoding: 7Bit Received-SPF: none client-ip=81.169.146.160; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org This is a multi-part message in MIME format. --nextPart2913594.9ZrGZTpANS Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On FreeBSD 12.0/i386 I get a compilation error when building a testdir for module 'rawmemchr'. On the master branch, the first error is: In file included from ../../gllib/rawmemchr.c:17: In file included from ../config.h:1018: In file included from /usr/include/stddef.h:41: /usr/include/sys/_types.h:106:35: error: expected expression long long __max_align1 __aligned(_Alignof(long long)); ^ ../config.h:964:39: note: expanded from macro '_Alignof' # define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) ^ On the stable-202301 branch, the first error is: In file included from ../../gllib/rawmemchr.c:17: In file included from ../config.h:925: In file included from ./stdalign.h:131: In file included from /usr/include/stddef.h:41: /usr/include/sys/_types.h:106:35: error: expected expression long long __max_align1 __aligned(_Alignof(long long)); ^ ./stdalign.h:70:36: note: expanded from macro '_Alignof' # define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) ^ What happens is that - config.h includes , per the patch that I submitted in . - This is the gnulib-generated one. (In the purpose of my patch was to avoid including the gnulib-generated stdalign.h, but it did not achieve that goal since on this platform HAVE_STDALIGN_H is 1, following these configure findings: checking for stdalign.h... yes checking for alignas and alignof... no . Anyway.) - At the end of , gets included. - includes , which attempts to define max_align_t. For this it uses _Alignof(long long), which expands to offsetof (struct { char __a; long long __b; }, __b) - But at this point offsetof is not yet defined (since is still being included). The following patch fixes it. One in master, a different one for the stable-202301 branch. (On the stable-202207 branch there is no problem.) --nextPart2913594.9ZrGZTpANS Content-Disposition: attachment; filename="0001-master-alignasof-stdalign-Fix-a-compilation-error-on-FreeBS.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-master-alignasof-stdalign-Fix-a-compilation-error-on-FreeBS.patch" >From b323b5297757c5c904e6aff63454c777703361ce Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 24 Jan 2023 13:44:07 +0100 Subject: [PATCH] alignasof, stdalign: Fix a compilation error on FreeBSD 12.0. * m4/stdalign.m4 (gl_ALIGNASOF): In C mode, prefer __builtin_offsetof over offsetof when possible, since __builtin_offsetof works also when has not been fully included yet. --- ChangeLog | 7 +++++++ m4/stdalign.m4 | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 759310346b..f999f105a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-01-24 Bruno Haible + + alignasof, stdalign: Fix a compilation error on FreeBSD 12.0. + * m4/stdalign.m4 (gl_ALIGNASOF): In C mode, prefer __builtin_offsetof + over offsetof when possible, since __builtin_offsetof works also when + has not been fully included yet. + 2023-01-22 Bruno Haible doc: Update list of target platforms. diff --git a/m4/stdalign.m4 b/m4/stdalign.m4 index 0bb9281f5e..6a0ab2c102 100644 --- a/m4/stdalign.m4 +++ b/m4/stdalign.m4 @@ -112,8 +112,12 @@ AC_DEFUN([gl_ALIGNASOF], # define _GL_STDALIGN_NEEDS_STDDEF 1 # endif # else -# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) -# define _GL_STDALIGN_NEEDS_STDDEF 1 +# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__ +# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) +# else +# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) +# define _GL_STDALIGN_NEEDS_STDDEF 1 +# endif # endif # endif # if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)) -- 2.34.1 --nextPart2913594.9ZrGZTpANS Content-Disposition: attachment; filename="0001-stable-stdalign-Fix-a-compilation-error-on-FreeBSD-12.0.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-stable-stdalign-Fix-a-compilation-error-on-FreeBSD-12.0.patch" >From 1f4fe409ea4379c3e537507822151e135be758d8 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 24 Jan 2023 13:36:11 +0100 Subject: [PATCH] stdalign: Fix a compilation error on FreeBSD 12.0. * lib/stdalign.in.h (_Alignof): In C mode, prefer __builtin_offsetof over offsetof when possible, since __builtin_offsetof works also when has not been fully included yet. * m4/stdalign.m4 (gl_STDALIGN_H): Likewise. --- ChangeLog | 8 ++++++++ lib/stdalign.in.h | 8 ++++++-- m4/stdalign.m4 | 8 ++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ca8306d1e4..bd7fd9ab5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2023-01-24 Bruno Haible + + stdalign: Fix a compilation error on FreeBSD 12.0. + * lib/stdalign.in.h (_Alignof): In C mode, prefer __builtin_offsetof + over offsetof when possible, since __builtin_offsetof works also when + has not been fully included yet. + * m4/stdalign.m4 (gl_STDALIGN_H): Likewise. + 2023-01-22 Paul Eggert sigsegv, vma-iter: port to Solaris 10 diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h index 17357810c7..7f9dbb466e 100644 --- a/lib/stdalign.in.h +++ b/lib/stdalign.in.h @@ -66,8 +66,12 @@ # define _GL_STDALIGN_NEEDS_STDDEF 1 # endif # else -# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) -# define _GL_STDALIGN_NEEDS_STDDEF 1 +# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__ +# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) +# else +# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) +# define _GL_STDALIGN_NEEDS_STDDEF 1 +# endif # endif #endif #if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)) diff --git a/m4/stdalign.m4 b/m4/stdalign.m4 index b1438eeace..dc2971753d 100644 --- a/m4/stdalign.m4 +++ b/m4/stdalign.m4 @@ -93,8 +93,12 @@ AC_DEFUN([gl_STDALIGN_H], # define _GL_STDALIGN_NEEDS_STDDEF 1 # endif # else -# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) -# define _GL_STDALIGN_NEEDS_STDDEF 1 +# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__ +# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) +# else +# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) +# define _GL_STDALIGN_NEEDS_STDDEF 1 +# endif # endif # endif # if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)) -- 2.34.1 --nextPart2913594.9ZrGZTpANS--