FYI... ---------- Forwarded message --------- From: Jeffrey Walton <noloa...@gmail.com> Date: Mon, Feb 3, 2020 at 3:12 AM Subject: GnuTLS 3.6.12 patch for OS X 10.9 To: <gnutls-de...@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
--- 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]]