Path: news.ibcinc.com!not-for-mail
From: Roderick Schertler <roderick@argon.org>
Newsgroups: rec.games.roguelike.nethack
Subject: [PATCH] unixres.c RTLD_NEXT problem compiling 3.4.1 under Linux
Date: 05 Mar 2003 17:12:15 -0500
Organization: International Bonded Couriers
Lines: 42
Message-ID: <87y93tmpj4.fsf@eeyore.ibcinc.com>
References: <slrnb64otn.1a1.dsb@rover.dsb-i>
NNTP-Posting-Host: eeyore.ibcinc.com
X-Trace: piglet.ibcinc.com 1046902336 10714 198.22.130.65 (5 Mar 2003 22:12:16 GMT)
Cc: nethack-bugs@nethack.org
X-Newsreader: Gnus v5.7/Emacs 20.7
Xref: news.ibcinc.com rec.games.roguelike.nethack:87284

On Sun, 02 Mar 2003 20:02:28 GMT, Scott Bigham <dsb@killerbunnies.org> said:
>
> Now, be warned, I haven't been able to actually test the changed patches
> (compile chokes on RTLD_NEXT in sys/unix/unixres.c), [...]

RTLD_NEXT is defined by dlfcn.h if __USE_GNU is set, which happens if
the user set _GNU_SOURCE.  unixres.c is setting _GNU_SOURCE so that this
will happen, but features.h, which is responsible for turning on the
former in the presence of the latter, has already been included by that
point.  Since it arranges only to be included once, __USE_GNU doesn't
get set and so RTLD_NEXT doesn't get defined.

diff -ur base.1/sys/unix/unixres.c work/sys/unix/unixres.c
--- base.1/sys/unix/unixres.c	2003-02-23 09:43:39.000000000 -0500
+++ work/sys/unix/unixres.c	2003-03-05 16:56:12.000000000 -0500
@@ -14,14 +14,19 @@
  * hide them.
  */
 
+/* _GNU_SOURCE has to be set before including config.h, as otherwise
+ * features.h will be included and it will be too late.
+ */
+
+#if defined(linux) && defined(__GNUC__)
+# define _GNU_SOURCE
+#endif
+
 #include "config.h"
 
 #ifdef GETRES_SUPPORT
 
 # if defined(LINUX)
-#ifdef __GNUC__
-#define _GNU_SOURCE
-#endif
 
 /* requires dynamic linking with libc */
 #include <dlfcn.h>

-- 
Roderick Schertler
roderick@argon.org
