~ chicken-core (chicken-5) 934eecc82bc6d6b8381773516c9dbbeddd617613


commit 934eecc82bc6d6b8381773516c9dbbeddd617613
Author:     Peter Bex <peter@more-magic.net>
AuthorDate: Sun Mar 5 16:38:33 2017 +0100
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Tue Mar 7 19:15:17 2017 +1300

    Fix running of tests when not installed (#1347)
    
    When the tests were being run, and an extension was required for
    syntax, the compiler would not be able to load the extension or even
    its import library, because it would search the target installation
    directory, which either contained an old, outdated, version of the
    library (whoops!), or it wouldn't exist at all.
    
    To fix this we simply export CHICKEN_REPOSITORY, always.
    
    Static linking was also busted for much the same reason: it would link
    directly against /path/to/chicken/lib/libchicken.a.  This is not
    necessary, because the path would be put after -static.  Instead, we
    rely on ld(1)'s behaviour that any -l flags after the -static flag is
    interpreted as referring to a static archive, so we just use -lchicken
    in all cases, regardless of requiring static or dynamic linking.
    
    This should also fix static cross-compilation when the target library
    name of libchicken has been customised.
    
    Signed-off-by: Evan Hanson <evhan@foldling.org>

diff --git a/csc.scm b/csc.scm
index 9a3a8b65..e8cc7418 100644
--- a/csc.scm
+++ b/csc.scm
@@ -138,9 +138,6 @@
       (string-append "cyg" INSTALL_LIB_NAME "-0")
       libchicken))
 
-(define default-library
-  (string-append libchicken "." library-extension))
-
 (define default-compilation-optimization-options (string-split (if host-mode INSTALL_CFLAGS TARGET_CFLAGS)))
 (define best-compilation-optimization-options default-compilation-optimization-options)
 (define default-linking-optimization-options (string-split (if host-mode INSTALL_LDFLAGS TARGET_LDFLAGS)))
@@ -228,12 +225,8 @@
       INSTALL_MORE_LIBS
       TARGET_MORE_LIBS))
 
-(define default-library-files 
-  (list
-   (prefix default-library "lib"
-	   (string-append
-	    (if host-mode INSTALL_LIB_HOME TARGET_LIB_HOME)
-	    (string-append "/" default-library)))) )
+(define default-library-files
+  (list (string-append "-l" (if host-mode INSTALL_LIB_NAME TARGET_LIB_NAME))))
 
 (define default-shared-library-files 
   (list (string-append "-l" (if host-mode INSTALL_LIB_NAME TARGET_LIB_NAME))))
diff --git a/tests/runtests.sh b/tests/runtests.sh
index c66cf3c7..74e7ecfa 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -70,6 +70,11 @@ do
 done
 
 CHICKEN_REPOSITORY=${TEST_DIR}/test-repository
+CHICKEN_PREFIX=${TEST_DIR}/..
+
+export CHICKEN_REPOSITORY
+export CHICKEN_PREFIX
+
 CHICKEN=${TEST_DIR}/../chicken
 CHICKEN_PROFILE=${TEST_DIR}/../chicken-profile
 CHICKEN_INSTALL=${TEST_DIR}/../chicken-install
@@ -492,9 +497,9 @@ $compile2 -link reverser linking-tests.scm
 $compile2 -link reverser linking-tests.scm -static
 ./linking-tests
 mv reverser.o reverser.import.scm "$CHICKEN_REPOSITORY"
-CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $compile2 -link reverser linking-tests.scm
+$compile2 -link reverser linking-tests.scm
 ./linking-tests
-CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $compile2 -link reverser linking-tests.scm -static
+$compile2 -link reverser linking-tests.scm -static
 ./linking-tests
 
 echo "======================================== private repository test ..."
@@ -508,26 +513,24 @@ PATH=`pwd`/tmp:$PATH xxx ${TEST_DIR}/tmp
 rm -fr rev-app rev-app-2 reverser/*.import.* reverser/*.so
 
 echo "======================================== reinstall tests"
-CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $CHICKEN_UNINSTALL -force reverser
-CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY CSC_OPTIONS=$COMPILE_OPTIONS \
-    CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL -t local -l $TEST_DIR \
-    -csi ${TEST_DIR}/../csi reverser:1.0
-CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $interpret -bnq rev-app.scm 1.0
-CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY CSC_OPTIONS=$COMPILE_OPTIONS \
-    CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL -t local -l $TEST_DIR \
-    -reinstall -force -csi ${TEST_DIR}/../csi
-CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY $interpret -bnq rev-app.scm 1.0
+$CHICKEN_UNINSTALL -force reverser
+CSC_OPTIONS=$COMPILE_OPTIONS CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL \
+	-t local -l $TEST_DIR -csi ${TEST_DIR}/../csi reverser:1.0
+$interpret -bnq rev-app.scm 1.0
+CSC_OPTIONS=$COMPILE_OPTIONS CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL \
+	-t local -l $TEST_DIR -reinstall -force -csi ${TEST_DIR}/../csi
+$interpret -bnq rev-app.scm 1.0
 
 if test $OS_NAME != AIX -a $OS_NAME != SunOS -a $OS_NAME != GNU; then
 	echo "======================================== deployment tests"
 	mkdir rev-app
-        TARGET_LIB_PATH=${TEST_DIR}/.. CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY CSC_OPTIONS=$COMPILE_OPTIONS \
-                          CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL -csi ${TEST_DIR}/../csi -t local -l $TEST_DIR reverser
-        TARGET_LIB_PATH=${TEST_DIR}/.. CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY CSC_OPTIONS=$COMPILE_OPTIONS \
-                          CSI_OPTIONS=$SETUP_PREFIX $compile2 -deploy rev-app.scm
-        TARGET_LIB_PATH=${TEST_DIR}/.. CHICKEN_REPOSITORY=$CHICKEN_REPOSITORY CSC_OPTIONS=$COMPILE_OPTIONS \
-                          CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL -csi ${TEST_DIR}/../csi -deploy -prefix rev-app -t local -l $TEST_DIR reverser
-	unset LD_LIBRARY_PATH DYLD_LIBRARY_PATH CHICKEN_REPOSITORY
+	TARGET_LIB_PATH=${TEST_DIR}/.. CSC_OPTIONS=$COMPILE_OPTIONS \
+			  CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL -csi ${TEST_DIR}/../csi -t local -l $TEST_DIR reverser
+	TARGET_LIB_PATH=${TEST_DIR}/.. CSC_OPTIONS=$COMPILE_OPTIONS \
+			  CSI_OPTIONS=$SETUP_PREFIX $compile2 -deploy rev-app.scm
+	TARGET_LIB_PATH=${TEST_DIR}/.. CSC_OPTIONS=$COMPILE_OPTIONS \
+			  CSI_OPTIONS=$SETUP_PREFIX $CHICKEN_INSTALL -csi ${TEST_DIR}/../csi -deploy -prefix rev-app -t local -l $TEST_DIR reverser
+	unset LD_LIBRARY_PATH DYLD_LIBRARY_PATH
 	# An absolute path is required on NetBSD with $ORIGIN, hence `pwd`
 	`pwd`/rev-app/rev-app 1.1
 	mv rev-app rev-app-2
Trap