bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* Fwd: GnuTLS 3.6.12 patch for OS X 10.9
       [not found] <CAH8yC8nYWRR5G_meNqQHH3CA24_oAxFhRvO5w9E2sezv9_B8EQ@mail.gmail.com>
@ 2020-02-03  8:15 ` Jeffrey Walton
  2020-02-03 17:24   ` Paul Eggert
  0 siblings, 1 reply; 10+ messages in thread
From: Jeffrey Walton @ 2020-02-03  8:15 UTC (permalink / raw)
  To: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 3162 bytes --]

FYI...

---------- Forwarded message ---------
From: Jeffrey Walton <noloader@gmail.com>
Date: Mon, Feb 3, 2020 at 3:12 AM
Subject: GnuTLS 3.6.12 patch for OS X 10.9
To: <gnutls-devel@lists.gnutls.org>

Hi Everyone,

I'm working from the GnuTLS 3.6.12 release tarball on OS X 10.9.

The build is failing due to the handling of _Noreturn in config.h and
gl/_Noreturn.h. An example of the error is shown below.

The attached patch fixes the build. In the case of OS X 10.9 with
Clang, the compiler already knows what to do with
__attribute__((__noreturn__)). The machinery should not modify
anything.

gcc -DHAVE_CONFIG_H -I. -I..  -I./gl -I./gl -I./../lib/includes
-I./../lib/includes -I./../libdane/includes -I./../extra/includes
-I../src/libopts -I./libopts  -I/usr/local/include -DNDEBUG
-fno-common -Wall   -g2 -O2 -march=native -fPIC -pthread -MT tests.o
-MD -MP -MF $depbase.Tpo -c -o tests.o tests.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from psk.c:50:
In file included from ./gl/unistd.h:40:
/usr/include/unistd.h:424:18: error: use of undeclared identifier '__noreturn__'
void     _exit(int) __dead2;
                    ^
/usr/include/sys/cdefs.h:135:33: note: expanded from macro '__dead2'
#define __dead2         __attribute__((noreturn))
                                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stdnoreturn.h:27:18:
note:
      expanded from macro 'noreturn'
#define noreturn _Noreturn
                 ^
../config.h:1828:37: note: expanded from macro '_Noreturn'
#  define _Noreturn __attribute__ ((__noreturn__))
                                    ^
In file included from psk.c:50:
In file included from ./gl/unistd.h:40:
/usr/include/unistd.h:640:18: error: use of undeclared identifier '__noreturn__'
void     _Exit(int) __dead2;
                    ^
/usr/include/sys/cdefs.h:135:33: note: expanded from macro '__dead2'
#define __dead2         __attribute__((noreturn))
                                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stdnoreturn.h:27:18:
note:
      expanded from macro 'noreturn'
#define noreturn _Noreturn
                 ^
../config.h:1828:37: note: expanded from macro '_Noreturn'
#  define _Noreturn __attribute__ ((__noreturn__))
                                    ^
2 errors generated.
gmake[4]: *** [Makefile:2121: psk.o] Error 1
gmake[4]: *** Waiting for unfinished jobs....

If you don't like the use of __has_attribute, then the following
defines may be helpful to untangle things (or make the fur ball
bigger):

$ gcc -dM -E - < /dev/null | grep -i -E 'clang|llvm|apple|gnu'
#define __APPLE_CC__ 6000
#define __APPLE__ 1
#define __GNUC_MINOR__ 2
#define __GNUC_PATCHLEVEL__ 1
#define __GNUC_STDC_INLINE__ 1
#define __GNUC__ 4
#define __VERSION__ "4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)"
#define __apple_build_version__ 6000057
#define __clang__ 1
#define __clang_major__ 6
#define __clang_minor__ 0
#define __clang_patchlevel__ 0
#define __clang_version__ "6.0 (clang-600.0.57)"
#define __llvm__ 1

Jeff

[-- Attachment #2: gnutls.patch --]
[-- Type: application/x-patch, Size: 1588 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Fwd: GnuTLS 3.6.12 patch for OS X 10.9
  2020-02-03  8:15 ` Fwd: GnuTLS 3.6.12 patch for OS X 10.9 Jeffrey Walton
@ 2020-02-03 17:24   ` Paul Eggert
  2020-02-03 20:39     ` Paul Eggert
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Eggert @ 2020-02-03 17:24 UTC (permalink / raw)
  To: noloader; +Cc: gnutls-devel, bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 4420 bytes --]

Re the message forwarded below. First I don't see a copy of this message at 
<https://lists.gnu.org/r/gnutls-devel/2015-02/index.html> so I'm taking the 
liberty of copying the entire thing to gnutls-devel@gnu.org.

Second, your patch (attached) doesn't look right. config.h should not #define 
__has_attribute because too much code (perhaps unwisely) defaults 
__has_attribute to something other than just 0, and relies on doing this, and if 
config.h defaults it to 0 then the code won't work. (The advice about defaulting 
__has_attribute to 0 in https://clang.llvm.org/docs/LanguageExtensions.html is 
wrong for GCC.)

Third, the proposed patch uses __has_attribute(__noreturn__) to decide whether 
_Noreturn is supported, which doesn't sound right. I expect that Clang 
historically has had modes in which __attribute__((__noreturn__)) worked and 
_Noreturn didn't, or vice versa.

If you could let us know exactly when Clang supports _Noreturn and when it 
doesn't (C++ vs C, which version of Clang, which other C preprocessor macros 
matter?) we could come up with a better patch.


> ---------- Forwarded message ---------
> From: Jeffrey Walton <noloader@gmail.com>
> Date: Mon, Feb 3, 2020 at 3:12 AM
> Subject: GnuTLS 3.6.12 patch for OS X 10.9
> To: <gnutls-devel@lists.gnutls.org>
> 
> Hi Everyone,
> 
> I'm working from the GnuTLS 3.6.12 release tarball on OS X 10.9.
> 
> The build is failing due to the handling of _Noreturn in config.h and
> gl/_Noreturn.h. An example of the error is shown below.
> 
> The attached patch fixes the build. In the case of OS X 10.9 with
> Clang, the compiler already knows what to do with
> __attribute__((__noreturn__)). The machinery should not modify
> anything.
> 
> gcc -DHAVE_CONFIG_H -I. -I..  -I./gl -I./gl -I./../lib/includes
> -I./../lib/includes -I./../libdane/includes -I./../extra/includes
> -I../src/libopts -I./libopts  -I/usr/local/include -DNDEBUG
> -fno-common -Wall   -g2 -O2 -march=native -fPIC -pthread -MT tests.o
> -MD -MP -MF $depbase.Tpo -c -o tests.o tests.c &&\
> mv -f $depbase.Tpo $depbase.Po
> In file included from psk.c:50:
> In file included from ./gl/unistd.h:40:
> /usr/include/unistd.h:424:18: error: use of undeclared identifier '__noreturn__'
> void     _exit(int) __dead2;
>                      ^
> /usr/include/sys/cdefs.h:135:33: note: expanded from macro '__dead2'
> #define __dead2         __attribute__((noreturn))
>                                         ^
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stdnoreturn.h:27:18:
> note:
>        expanded from macro 'noreturn'
> #define noreturn _Noreturn
>                   ^
> ../config.h:1828:37: note: expanded from macro '_Noreturn'
> #  define _Noreturn __attribute__ ((__noreturn__))
>                                      ^
> In file included from psk.c:50:
> In file included from ./gl/unistd.h:40:
> /usr/include/unistd.h:640:18: error: use of undeclared identifier '__noreturn__'
> void     _Exit(int) __dead2;
>                      ^
> /usr/include/sys/cdefs.h:135:33: note: expanded from macro '__dead2'
> #define __dead2         __attribute__((noreturn))
>                                         ^
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stdnoreturn.h:27:18:
> note:
>        expanded from macro 'noreturn'
> #define noreturn _Noreturn
>                   ^
> ../config.h:1828:37: note: expanded from macro '_Noreturn'
> #  define _Noreturn __attribute__ ((__noreturn__))
>                                      ^
> 2 errors generated.
> gmake[4]: *** [Makefile:2121: psk.o] Error 1
> gmake[4]: *** Waiting for unfinished jobs....
> 
> If you don't like the use of __has_attribute, then the following
> defines may be helpful to untangle things (or make the fur ball
> bigger):
> 
> $ gcc -dM -E - < /dev/null | grep -i -E 'clang|llvm|apple|gnu'
> #define __APPLE_CC__ 6000
> #define __APPLE__ 1
> #define __GNUC_MINOR__ 2
> #define __GNUC_PATCHLEVEL__ 1
> #define __GNUC_STDC_INLINE__ 1
> #define __GNUC__ 4
> #define __VERSION__ "4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)"
> #define __apple_build_version__ 6000057
> #define __clang__ 1
> #define __clang_major__ 6
> #define __clang_minor__ 0
> #define __clang_patchlevel__ 0
> #define __clang_version__ "6.0 (clang-600.0.57)"
> #define __llvm__ 1
> 
> Jeff
> 


[-- Attachment #2: gnutls.patch --]
[-- Type: text/x-patch, Size: 1588 bytes --]

--- config.h.in
+++ config.h.in
@@ -1806,9 +1806,16 @@
 /* Define to 1 to make NetBSD features available. MINIX 3 needs this. */
 #undef _NETBSD_SOURCE
 
+/* https://clang.llvm.org/docs/LanguageExtensions.html */
+#ifndef __has_attribute         // Optional of course.
+# define __has_attribute(x) 0   // Compatibility non-clang compilers.
+#endif
+
 /* The _Noreturn keyword of C11.  */
 #ifndef _Noreturn
-# if (defined __cplusplus \
+# if defined(__APPLE__) && defined(__clang__) && (__has_attribute(__noreturn__) == 1)
+   /* Don't do anything. Stay out of code paths below. */
+# elif (defined __cplusplus \
       && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
           || (defined _MSC_VER && 1900 <= _MSC_VER)))
 #  define _Noreturn [[noreturn]]
--- src/gl/_Noreturn.h
+++ src/gl/_Noreturn.h
@@ -14,8 +14,15 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
+/* https://clang.llvm.org/docs/LanguageExtensions.html */
+#ifndef __has_attribute         // Optional of course.
+# define __has_attribute(x) 0   // Compatibility non-clang compilers.
+#endif
+
 #ifndef _Noreturn
-# if (defined __cplusplus \
+# if defined(__APPLE__) && defined(__clang__) && (__has_attribute(__noreturn__) == 1)
+   /* Don't do anything. Stay out of code paths below. */
+# elif (defined __cplusplus \
       && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
           || (defined _MSC_VER && 1900 <= _MSC_VER)))
 #  define _Noreturn [[noreturn]]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Fwd: GnuTLS 3.6.12 patch for OS X 10.9
  2020-02-03 17:24   ` Paul Eggert
@ 2020-02-03 20:39     ` Paul Eggert
  2020-02-03 21:28       ` Paul Eggert
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Eggert @ 2020-02-03 20:39 UTC (permalink / raw)
  To: noloader; +Cc: bug-gnulib

On 2/3/20 9:24 AM, Paul Eggert wrote:
> Re the message forwarded below. First I don't see a copy of this message 
> at <https://lists.gnu.org/r/gnutls-devel/2015-02/index.html> so I'm 
> taking the liberty of copying the entire thing to gnutls-devel@gnu.org.

Oops, that bounced, and now I see that the mailing list moved. However, 
I don't see a copy of the message at 
<https://lists.gnutls.org/pipermail/gnutls-devel/2020-February/thread.html> 
either. Anyway, I have attempted to get the GnuTLS developers' attention 
by filing a bug report here:

https://gitlab.com/gnutls/gnutls/issues/926


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Fwd: GnuTLS 3.6.12 patch for OS X 10.9
  2020-02-03 20:39     ` Paul Eggert
@ 2020-02-03 21:28       ` Paul Eggert
  2020-02-03 23:00         ` Jeffrey Walton
  2020-02-04  0:50         ` Jeffrey Walton
  0 siblings, 2 replies; 10+ messages in thread
From: Paul Eggert @ 2020-02-03 21:28 UTC (permalink / raw)
  To: noloader; +Cc: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 186 bytes --]

Looking at the online Clang manuals, it appears that Clang started 
supporting _Noreturn starting with 3.5.0. So does the attached 
(untested) patch work for you? If not, please advise.

[-- Attachment #2: 0001-Port-_Noreturn-to-older-Clang.patch --]
[-- Type: text/x-patch, Size: 3167 bytes --]

From 14f1146b2261ffeaacd5bc74cf034db52232bc52 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 3 Feb 2020 13:20:09 -0800
Subject: [PATCH] Port _Noreturn to older Clang

Problem reported by Jeffery Walton in:
https://lists.gnu.org/r/bug-gnulib/2020-02/msg00013.html
* lib/_Noreturn.h (_Noreturn):
* m4/gnulib-common.m4 (gl_COMMON_BODY):
Assume _Noreturn works in Clang 3.5 and later.
It is documented to work in Clang 3.5:
http://releases.llvm.org/3.5.0/tools/clang/docs/AttributeReference.html
and is not documented in Clang 3.4:
https://releases.llvm.org/3.4/tools/clang/docs/LanguageExtensions.html
---
 ChangeLog           | 13 +++++++++++++
 lib/_Noreturn.h     |  3 ++-
 m4/gnulib-common.m4 |  5 +++--
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2a86791a8..4cfd9d445 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2020-02-03  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Port _Noreturn to older Clang
+	Problem reported by Jeffery Walton in:
+	https://lists.gnu.org/r/bug-gnulib/2020-02/msg00013.html
+	* lib/_Noreturn.h (_Noreturn):
+	* m4/gnulib-common.m4 (gl_COMMON_BODY):
+	Assume _Noreturn works in Clang 3.5 and later.
+	It is documented to work in Clang 3.5:
+	http://releases.llvm.org/3.5.0/tools/clang/docs/AttributeReference.html
+	and is not documented in Clang 3.4:
+	https://releases.llvm.org/3.4/tools/clang/docs/LanguageExtensions.html
+
 2020-02-02  Bruno Haible  <bruno@clisp.org>
 
 	Document the new modules list-c++, set-c++, oset-c++, map-c++, omap-c++.
diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h
index 74ee9ad41..f87eb77a5 100644
--- a/lib/_Noreturn.h
+++ b/lib/_Noreturn.h
@@ -28,7 +28,8 @@
 #  define _Noreturn [[noreturn]]
 # elif ((!defined __cplusplus || defined __clang__)                     \
         && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)  \
-            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
+            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
+            || 3 < __clang_major__ + (5 <= __clang_minor__)))
    /* _Noreturn works as-is.  */
 # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
 #  define _Noreturn __attribute__ ((__noreturn__))
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 276ed1aff..78dd45fe4 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 47
+# gnulib-common.m4 serial 48
 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -31,7 +31,8 @@ AC_DEFUN([gl_COMMON_BODY], [
 #  define _Noreturn [[noreturn]]
 # elif ((!defined __cplusplus || defined __clang__) \
         && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)  \
-            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
+            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
+            || 3 < __clang_major__ + (5 <= __clang_minor__)))
    /* _Noreturn works as-is.  */
 # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
 #  define _Noreturn __attribute__ ((__noreturn__))
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: Fwd: GnuTLS 3.6.12 patch for OS X 10.9
  2020-02-03 21:28       ` Paul Eggert
@ 2020-02-03 23:00         ` Jeffrey Walton
  2020-02-04  2:32           ` Paul Eggert
  2020-02-04  0:50         ` Jeffrey Walton
  1 sibling, 1 reply; 10+ messages in thread
From: Jeffrey Walton @ 2020-02-03 23:00 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib

On Mon, Feb 3, 2020 at 4:28 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
>
> Looking at the online Clang manuals, it appears that Clang started
> supporting _Noreturn starting with 3.5.0. So does the attached
> (untested) patch work for you? If not, please advise.

Thanks Paul.

I think there is a small issue. There are two versions of Clang. First
is Apple Clang distributed with Xcode. Second is LLVM Clang. They use
different version numbers.

In your case, you used LLVM Clang version 3.5. If you look at the
release date (https://releases.llvm.org/), it is September 2014.
Around September 2014 Apple released Xcode 6.0
https://xcodereleases.com/). Apple's versioning of Clang follows
Xcode. So you need to use both:

    * LLVM: version 3.5
    * Apple: version 6.0

To tell the difference between LLVM Clang and Apple Clang, use the
preprocessor macro __apple_build_version__. Apple Clang has
__apple_build_version__, LLVM Clang does not.

So the defines would look something like:

#if defined(__apple_build_version__) && (__clang_major__ >= 6)
    /* _Noreturn works as-is.  */
#elif (__clang_major__ == 3 && __clang_minor__ >= 5) || (__clang_major__ >= 4)
    /* _Noreturn works as-is.  */
# elif ...

Or, you can use __has_attribute(_Noreturn). __has_attribute(_Noreturn)
behaves as expected.

I would not worry about other software using __has_attribute. It is a
reserved symbol due to the leading undersocres. Userland software
should not have been using it in the first place. Software that uses
reserved names wanders off the reservation, and now they have to fix
their mistake.

Jeff


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Fwd: GnuTLS 3.6.12 patch for OS X 10.9
  2020-02-03 21:28       ` Paul Eggert
  2020-02-03 23:00         ` Jeffrey Walton
@ 2020-02-04  0:50         ` Jeffrey Walton
  1 sibling, 0 replies; 10+ messages in thread
From: Jeffrey Walton @ 2020-02-04  0:50 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib

On Mon, Feb 3, 2020 at 4:28 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
>
> Looking at the online Clang manuals, it appears that Clang started
> supporting _Noreturn starting with 3.5.0. So does the attached
> (untested) patch work for you? If not, please advise.

If interested, I can provide SSH access to a PowerMac running OS X
10.5 with Apple GCC 4.0.1, and a MacBook running OS X 10.9 with Apple
Clang 6.0.

Apple Clang 6.0 is roughly LLVM Clang 3.5:

    $ /usr/bin/clang --version
    Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
    Target: x86_64-apple-darwin13.4.0

The are several other compilers on the MacBook with OS X 10.9. They
are supplied by MacPorts:

    $ find /opt/local/bin -name '*gcc-mp*' -o -name '*clang-mp*'
    /opt/local/bin/clang-mp-3.7
    /opt/local/bin/clang-mp-5.0
    /opt/local/bin/clang-mp-6.0
    /opt/local/bin/clang-mp-7.0
    /opt/local/bin/clang-mp-8.0
    /opt/local/bin/gcc-mp-5
    /opt/local/bin/gcc-mp-6
    /opt/local/bin/gcc-mp-7

I need your authorized_keys, if interested.

Jeff


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Fwd: GnuTLS 3.6.12 patch for OS X 10.9
  2020-02-03 23:00         ` Jeffrey Walton
@ 2020-02-04  2:32           ` Paul Eggert
  2020-02-04  4:17             ` Jeffrey Walton
  2020-02-04 13:04             ` Jeffrey Walton
  0 siblings, 2 replies; 10+ messages in thread
From: Paul Eggert @ 2020-02-04  2:32 UTC (permalink / raw)
  To: noloader; +Cc: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 831 bytes --]

On 2/3/20 3:00 PM, Jeffrey Walton wrote:

> Or, you can use __has_attribute(_Noreturn). __has_attribute(_Noreturn)
> behaves as expected.

It isn't documented to work, and it doesn't work for me with clang 
version 9.0.0 (Fedora 9.0.0-1.fc31).

> I would not worry about other software using __has_attribute. It is a
> reserved symbol due to the leading undersocres. Userland software
> should not have been using it in the first place.

Gnulib is userland software, so we cannot use your argument to justify 
putting "#define __has_attribute(x) 0" into Gnulib.

How about the attached (untested) patch instead? It looks at 
__apple_build_version__.

PS. I must say that Apple's hijacking and renumbering of __clang_major__ 
seems pretty antisocial, and breaks some already-existing code in Gnulib 
- what caused Apple to do that?

[-- Attachment #2: 0001-Port-_Noreturn-to-older-Clang.patch --]
[-- Type: text/x-patch, Size: 3708 bytes --]

From b5a5d22145cb3fa8c92e7b460710cb63e7bafb44 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 3 Feb 2020 13:20:09 -0800
Subject: [PATCH] Port _Noreturn to older Clang

Problem reported by Jeffery Walton in:
https://lists.gnu.org/r/bug-gnulib/2020-02/msg00013.html
* lib/_Noreturn.h (_Noreturn):
* m4/gnulib-common.m4 (gl_COMMON_BODY):
Assume _Noreturn works in Clang 3.5 and later.
It is documented to work in Clang 3.5:
http://releases.llvm.org/3.5.0/tools/clang/docs/AttributeReference.html
and is not documented in Clang 3.4:
https://releases.llvm.org/3.4/tools/clang/docs/LanguageExtensions.html
Apple sets __clang_version__ to a different value, so use
__apple_build_version__ there.  See:
https://lists.gnu.org/r/bug-gnulib/2020-02/msg00017.html
---
 ChangeLog           | 16 ++++++++++++++++
 lib/_Noreturn.h     |  5 ++++-
 m4/gnulib-common.m4 |  7 +++++--
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2a86791a8..a753da8ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2020-02-03  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Port _Noreturn to older Clang
+	Problem reported by Jeffery Walton in:
+	https://lists.gnu.org/r/bug-gnulib/2020-02/msg00013.html
+	* lib/_Noreturn.h (_Noreturn):
+	* m4/gnulib-common.m4 (gl_COMMON_BODY):
+	Assume _Noreturn works in Clang 3.5 and later.
+	It is documented to work in Clang 3.5:
+	http://releases.llvm.org/3.5.0/tools/clang/docs/AttributeReference.html
+	and is not documented in Clang 3.4:
+	https://releases.llvm.org/3.4/tools/clang/docs/LanguageExtensions.html
+	Apple sets __clang_version__ to a different value, so use
+	__apple_build_version__ there.  See:
+	https://lists.gnu.org/r/bug-gnulib/2020-02/msg00017.html
+
 2020-02-02  Bruno Haible  <bruno@clisp.org>
 
 	Document the new modules list-c++, set-c++, oset-c++, map-c++, omap-c++.
diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h
index 74ee9ad41..606e92f52 100644
--- a/lib/_Noreturn.h
+++ b/lib/_Noreturn.h
@@ -28,7 +28,10 @@
 #  define _Noreturn [[noreturn]]
 # elif ((!defined __cplusplus || defined __clang__)                     \
         && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)  \
-            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
+            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
+            || (defined __apple_build_version__ \
+                ? 6000000 <= __apple_build_version__ \
+                : 3 < __clang_major__ + (5 <= __clang_minor__))))
    /* _Noreturn works as-is.  */
 # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
 #  define _Noreturn __attribute__ ((__noreturn__))
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 276ed1aff..b4795c18a 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 47
+# gnulib-common.m4 serial 48
 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -31,7 +31,10 @@ AC_DEFUN([gl_COMMON_BODY], [
 #  define _Noreturn [[noreturn]]
 # elif ((!defined __cplusplus || defined __clang__) \
         && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)  \
-            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
+            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
+            || (defined __apple_build_version__ \
+                ? 6000000 <= __apple_build_version__ \
+                : 3 < __clang_major__ + (5 <= __clang_minor__))))
    /* _Noreturn works as-is.  */
 # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
 #  define _Noreturn __attribute__ ((__noreturn__))
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: Fwd: GnuTLS 3.6.12 patch for OS X 10.9
  2020-02-04  2:32           ` Paul Eggert
@ 2020-02-04  4:17             ` Jeffrey Walton
  2020-02-04 19:41               ` Paul Eggert
  2020-02-04 13:04             ` Jeffrey Walton
  1 sibling, 1 reply; 10+ messages in thread
From: Jeffrey Walton @ 2020-02-04  4:17 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib

On Mon, Feb 3, 2020 at 9:32 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
> ...
> How about the attached (untested) patch instead? It looks at
> __apple_build_version__.

Ack, tested OK on OS X 10.9 and a Linux smoke test.

I was able to test _Noreturn.h through GnuTLS. I was not able to test
gnulib-common.m4. (I'm still learning how to test Gnulib).

I think CentOS 5 and NetBSD or FreeBSD would be good platforms to test
also. I need some time to adjust my scripts. Recent package upgrades
have broken some compiles.

One warning.... I've never found __apple_build_version__ documented
anywhere. I learned of __apple_build_version__ looking at diff's of
'clang -dM -E'. With that said, I've been using
__apple_build_version__ for 5 or 10 years without a problem. Apple
also uses __apple_build_version__ in places like
https://opensource.apple.com/source/xnu/xnu-4570.61.1/san/kasan_internal.h.auto.html
.

> PS. I must say that Apple's hijacking and renumbering of __clang_major__
> seems pretty antisocial, and breaks some already-existing code in Gnulib
> - what caused Apple to do that?

Yeah, I have my feelings on it, too.

Jeff


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Fwd: GnuTLS 3.6.12 patch for OS X 10.9
  2020-02-04  2:32           ` Paul Eggert
  2020-02-04  4:17             ` Jeffrey Walton
@ 2020-02-04 13:04             ` Jeffrey Walton
  1 sibling, 0 replies; 10+ messages in thread
From: Jeffrey Walton @ 2020-02-04 13:04 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib

On Mon, Feb 3, 2020 at 9:32 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
>
> On 2/3/20 3:00 PM, Jeffrey Walton wrote:
>
> > Or, you can use __has_attribute(_Noreturn). __has_attribute(_Noreturn)
> > behaves as expected.
>
> It isn't documented to work, and it doesn't work for me with clang
> version 9.0.0 (Fedora 9.0.0-1.fc31).
>
> > I would not worry about other software using __has_attribute. It is a
> > reserved symbol due to the leading undersocres. Userland software
> > should not have been using it in the first place.
>
> Gnulib is userland software, so we cannot use your argument to justify
> putting "#define __has_attribute(x) 0" into Gnulib.

Yeah, you're right.

This is how GCC recommends using __has_attribute:
https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html

Jeff


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Fwd: GnuTLS 3.6.12 patch for OS X 10.9
  2020-02-04  4:17             ` Jeffrey Walton
@ 2020-02-04 19:41               ` Paul Eggert
  0 siblings, 0 replies; 10+ messages in thread
From: Paul Eggert @ 2020-02-04 19:41 UTC (permalink / raw)
  To: noloader; +Cc: bug-gnulib

On 2/3/20 8:17 PM, Jeffrey Walton wrote:
> Ack, tested OK on OS X 10.9 and a Linux smoke test.

Thanks for checking; I installed it into Gnulib and GnuTLS should pick 
it up in due course.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-02-04 19:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAH8yC8nYWRR5G_meNqQHH3CA24_oAxFhRvO5w9E2sezv9_B8EQ@mail.gmail.com>
2020-02-03  8:15 ` Fwd: GnuTLS 3.6.12 patch for OS X 10.9 Jeffrey Walton
2020-02-03 17:24   ` Paul Eggert
2020-02-03 20:39     ` Paul Eggert
2020-02-03 21:28       ` Paul Eggert
2020-02-03 23:00         ` Jeffrey Walton
2020-02-04  2:32           ` Paul Eggert
2020-02-04  4:17             ` Jeffrey Walton
2020-02-04 19:41               ` Paul Eggert
2020-02-04 13:04             ` Jeffrey Walton
2020-02-04  0:50         ` Jeffrey Walton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).