This patch replaces the use of the "-R" linker option by "-rpath", which 
appears to be
more portable (accepted by tcc, for example). According to the GNU ld manual, 
-R is
actually a compatibility alias for -rpath, so the latter seems to be more 
canonical.
The manual page for Solaris' ld lists only -R, so on that platform we still use 
it.


felix
From 0e9dba82304d5631a52fe84be80f2b308b03e7cc Mon Sep 17 00:00:00 2001
From: felix <fe...@call-with-current-continuation.org>
Date: Wed, 11 Mar 2020 18:41:50 +0100
Subject: [PATCH] use -rpath instead of -R on all platforms but Solaris

---
 Makefile.aix             | 2 +-
 Makefile.android         | 4 ++--
 Makefile.bsd             | 4 ++--
 Makefile.haiku           | 4 ++--
 Makefile.hurd            | 4 ++--
 Makefile.linux           | 4 ++--
 README                   | 2 +-
 csc.scm                  | 9 ++++++---
 manual/Cross development | 2 +-
 9 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/Makefile.aix b/Makefile.aix
index ce4cf4fb..93322b06 100644
--- a/Makefile.aix
+++ b/Makefile.aix
@@ -49,7 +49,7 @@ CXX_COMPILER = g++
 
 LINKER_OPTIONS = -maix64 -Wl,-bsvr4 -Wl,-bbigtoc
 LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -L. -shared
-LINKER_EXECUTABLE_OPTIONS = -L. -Wl,-R"$(RUNTIME_LINKER_PATH)"
+LINKER_EXECUTABLE_OPTIONS = -L. -Wl,-rpath="$(RUNTIME_LINKER_PATH)"
 LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared
 
 LIBRARIAN_OPTIONS = -rv -X 64
diff --git a/Makefile.android b/Makefile.android
index 1812dcc1..7d30e01f 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -42,8 +42,8 @@ C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os -fomit-frame-pointer
 endif
 endif
 LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared
-LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -L. -shared 
-Wl,-R"$(RUNTIME_LINKER_PATH)"
-LINKER_LINK_SHARED_PROGRAM_OPTIONS = -Wl,-R"$(RUNTIME_LINKER_PATH)"
+LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -L. -shared 
-Wl,-rpath="$(RUNTIME_LINKER_PATH)"
+LINKER_LINK_SHARED_PROGRAM_OPTIONS = -Wl,-rpath="$(RUNTIME_LINKER_PATH)"
 # Android NDK build system currently does not understand
 # versioned sonames, so don't try to embed a soname.
 #LIBCHICKEN_SO_LINKER_OPTIONS = 
-Wl,-soname,lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX).so.$(BINARYVERSION)
diff --git a/Makefile.bsd b/Makefile.bsd
index b982a06f..b1996e0b 100644
--- a/Makefile.bsd
+++ b/Makefile.bsd
@@ -43,8 +43,8 @@ C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os -fomit-frame-pointer
 endif
 endif
 LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared
-LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -shared -Wl,-R"$(RUNTIME_LINKER_PATH)" 
-Wl,-L.
-LINKER_LINK_SHARED_PROGRAM_OPTIONS = -Wl,-R"$(RUNTIME_LINKER_PATH)"
+LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -shared 
-Wl,-rpath="$(RUNTIME_LINKER_PATH)" -Wl,-L.
+LINKER_LINK_SHARED_PROGRAM_OPTIONS = -Wl,-rpath="$(RUNTIME_LINKER_PATH)"
 LIBCHICKEN_SO_LINKER_OPTIONS = 
-Wl,-soname,lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX).so.$(BINARYVERSION)
 LIBRARIES = -lm -lpthread
 NEEDS_RELINKING = yes
diff --git a/Makefile.haiku b/Makefile.haiku
index a20da9b2..27763fa0 100644
--- a/Makefile.haiku
+++ b/Makefile.haiku
@@ -42,8 +42,8 @@ C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os -fomit-frame-pointer
 endif
 endif
 LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared
-LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -L. -shared 
-Wl,-R"$(RUNTIME_LINKER_PATH)"
-LINKER_LINK_SHARED_PROGRAM_OPTIONS = -Wl,-R"$(RUNTIME_LINKER_PATH)"
+LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -L. -shared 
-Wl,-rpath="$(RUNTIME_LINKER_PATH)"
+LINKER_LINK_SHARED_PROGRAM_OPTIONS = -Wl,-rpath="$(RUNTIME_LINKER_PATH)"
 LIBCHICKEN_SO_LINKER_OPTIONS = 
-Wl,-soname,lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX).so.$(BINARYVERSION)
 LIBRARIES = -lnetwork
 NEEDS_RELINKING = yes
diff --git a/Makefile.hurd b/Makefile.hurd
index f09d6ded..abac66a2 100644
--- a/Makefile.hurd
+++ b/Makefile.hurd
@@ -43,8 +43,8 @@ C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os -fomit-frame-pointer
 endif
 endif
 LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared
-LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -L. -shared 
-Wl,-R"$(RUNTIME_LINKER_PATH)"
-LINKER_LINK_SHARED_PROGRAM_OPTIONS = -Wl,-R"$(RUNTIME_LINKER_PATH)"
+LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -L. -shared 
-Wl,-rpath="$(RUNTIME_LINKER_PATH)"
+LINKER_LINK_SHARED_PROGRAM_OPTIONS = -Wl,-rpath="$(RUNTIME_LINKER_PATH)"
 LIBCHICKEN_SO_LINKER_OPTIONS = 
-Wl,-soname,lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX).so.$(BINARYVERSION)
 LIBRARIES = -lm -ldl
 NEEDS_RELINKING = yes
diff --git a/Makefile.linux b/Makefile.linux
index cfa8c2c5..7f0fa06c 100644
--- a/Makefile.linux
+++ b/Makefile.linux
@@ -43,8 +43,8 @@ C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os -fomit-frame-pointer
 endif
 endif
 LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared
-LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -L. -shared 
-Wl,-R"$(RUNTIME_LINKER_PATH)"
-LINKER_LINK_SHARED_PROGRAM_OPTIONS = -Wl,-R"$(RUNTIME_LINKER_PATH)"
+LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -L. -shared 
-Wl,-rpath="$(RUNTIME_LINKER_PATH)"
+LINKER_LINK_SHARED_PROGRAM_OPTIONS = -Wl,-rpath="$(RUNTIME_LINKER_PATH)"
 LIBCHICKEN_SO_LINKER_OPTIONS = 
-Wl,-soname,lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX).so.$(BINARYVERSION)
 LIBRARIES = -lm -ldl
 NEEDS_RELINKING = yes
diff --git a/README b/README
index fd295c9d..92d20a29 100644
--- a/README
+++ b/README
@@ -423,7 +423,7 @@ _/        _/    _/    _/    _/        _/  _/    _/        
_/    _/_/
            you add the following definitions to `Makefile.bsd':
 
              C_COMPILER_OPTIONS += -I/usr/pkg/lib
-             LINKER_OPTIONS += -L/usr/pkg/lib -Wl,-R/usr/pkg/lib
+             LINKER_OPTIONS += -L/usr/pkg/lib -Wl,-rpath=/usr/pkg/lib
 
            Note that this may cause build-problems, if you already have
            an existing CHICKEN installation in the /usr/pkg prefix.
diff --git a/csc.scm b/csc.scm
index a3a89aa3..01cfd04f 100644
--- a/csc.scm
+++ b/csc.scm
@@ -68,6 +68,7 @@
 (define osx (eq? (software-version) 'macosx))
 (define cygwin (eq? (software-version) 'cygwin))
 (define aix (eq? (build-platform) 'aix))
+(define solaris (memq (software-version) '(solaris sunos)))
 
 (define elf
   (memq (software-version) '(linux netbsd freebsd solaris openbsd hurd haiku)))
@@ -256,20 +257,21 @@
 (define linking-optimization-options default-linking-optimization-options)
 
 (define link-options '())
+(define rpath-option (if solaris "-R" "-rpath="))
 
 (define (builtin-link-options)
   (append
    (cond (elf
          (list
           (conc "-L" library-dir)
-          (conc "-Wl,-R"
+          (conc "-Wl," rpath-option
                 (if deployed
                     "$ORIGIN"
                     (if host-mode
                         host-libdir
                         TARGET_RUN_LIB_HOME)))))
         (aix
-         (list (conc "-Wl,-R\"" library-dir "\"")))
+         (list (conc "-Wl," rpath-option "\"" library-dir "\"")))
         (else
          (list (conc "-L" library-dir))))
    (if (and deployed (memq (software-version) '(freebsd openbsd netbsd)))
@@ -776,7 +778,8 @@ EOF
                (set! rpath (car rest))
                (when (and (memq (build-platform) '(gnu clang))
                           (not mingw) (not osx))
-                 (set! link-options (append link-options (list (string-append 
"-Wl,-R" rpath)))) )
+                 (set! link-options
+                    (append link-options (list (string-append "-Wl," 
rpath-option rpath)))) )
                (set! rest (cdr rest)) ]
               [(-host) #f]
               ((-oi) 
diff --git a/manual/Cross development b/manual/Cross development
index d1a07742..fe6757fb 100644
--- a/manual/Cross development  
+++ b/manual/Cross development  
@@ -198,7 +198,7 @@ Looks good.
   arm-none-linux-gnueabi-gcc hello.c -o hello.o -c -fno-strict-aliasing 
-DHAVE_CHICKEN_CONFIG_H -g -Wall \
     -Wno-unused -I /home/felix/cross-chicken/arm-chicken/include
   rm hello.c
-  arm-none-linux-gnueabi-gcc hello.o -o hello 
-L/home/felix/cross-chicken/arm-chicken/lib  -Wl,-R/usr/lib -lm \
+  arm-none-linux-gnueabi-gcc hello.o -o hello 
-L/home/felix/cross-chicken/arm-chicken/lib  -Wl,-rpath=/usr/lib -lm \
     -ldl -lchicken
   rm hello.o
 
-- 
2.21.0

Reply via email to