Subject: Use -Wl,-rpath instead of -R on GNU/Linux with GCC 4.6

From: [email-masked] (Ludovic Courtès)
Date: Mon, 16 Apr 2012 12:01:06 +0200

Hello,

The patch below fixes linking of ‘temacs’ on GNU/Linux with GCC 4.6.

=== modified file 'configure.in'
--- configure.in	2011-09-26 18:38:31 +0000
+++ configure.in	2012-04-16 09:52:23 +0000
@@ -3406,7 +3406,7 @@ case "$opsys" in
   ## had not yet been defined and was expanded to null.  Hence LD_SWITCH_SYSTEM
   ## had different values in configure (in ac_link) and src/Makefile.in.
   ## It seems clearer therefore to put this piece in LD_SWITCH_SYSTEM_TEMACS.
-  gnu-linux) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_AUX)" ;;
+  gnu-linux) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_AUX_RPATH)" ;;
 
   *) LD_SWITCH_SYSTEM_TEMACS= ;;
 esac

GCC 4.5 used to ignore ‘-R’, but GCC 4.6 rejects it:

--8<---------------cut here---------------start------------->8---
$ echo "int main () { return 0; }" > t.c

$ ./result/bin/gcc t.c -R/foo
gcc: unrecognized option '-R/foo'
$ echo $?
0
$ ./result/bin/gcc --version | head -1
gcc (GCC) 4.5.3

$ gcc t.c -R/foo
gcc: error: unrecognized option ‘-R’
$ echo $?
1
$ gcc --version | head -1
gcc (GCC) 4.6.2
--8<---------------cut here---------------end--------------->8---

(This is why the ‘build’ job at <http://hydra.nixos.org/eval/605870> has
been failing since the standard build environment switched from GCC 4.5
to 4.6 last month.)

In fact, the above should be applied to all GNU variants, so *gnu* may
be more appropriate than gnu-linux.

Thanks,
Ludo’.