From 43e24775bb283238cd0ced9d4fdac4cb357fb005 Mon Sep 17 00:00:00 2001
From: Raymond Toy <toy.raymond@gmail.com>
Date: Sun, 4 Oct 2015 20:26:12 -0700
Subject: [PATCH] Support asdf's static-image-op.

* src/lisp/GNUMakefile
    * Don't add exec-final.o to lisp.a.  (But still remove exec-init.o
      from it.)
* src/tools/linker.sh
    * When linking the executable, need to link exec-final.o too.
* bin/make-main-dist.sh
    * Need to install exec-init.o and exec-final.o.  exec-init.o is
      needed to link a normal lisp; exec-final.o is used for the
      executable image.
    * Fix modes on some installed files.  exec-init.o, exec-final.o,
      and lisp.a don't need to be executable.
---
 bin/make-main-dist.sh | 4 +++-
 src/lisp/GNUmakefile  | 8 +-------
 src/tools/linker.sh   | 2 +-
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/bin/make-main-dist.sh b/bin/make-main-dist.sh
index d938c36e7..ace8e84ec 100755
--- a/bin/make-main-dist.sh
+++ b/bin/make-main-dist.sh
@@ -96,7 +96,9 @@ install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/${MANDIR}
 install ${GROUP} ${OWNER} -m 0755 $TARGET/lisp/lisp $DESTDIR/bin/
 if [ "$EXECUTABLE" = "true" ]
 then
-    install ${GROUP} ${OWNER} -m 0755 $TARGET/lisp/lisp.a $DESTDIR/lib/cmucl/lib/
+    install ${GROUP} ${OWNER} -m 0555 $TARGET/lisp/lisp.a $DESTDIR/lib/cmucl/lib/
+    install ${GROUP} ${OWNER} -m 0555 $TARGET/lisp/exec-init.o $DESTDIR/lib/cmucl/lib/
+    install ${GROUP} ${OWNER} -m 0555 $TARGET/lisp/exec-final.o $DESTDIR/lib/cmucl/lib/
     install ${GROUP} ${OWNER} -m 0755 src/tools/linker.sh $DESTDIR/lib/cmucl/lib/
     if [ -f src/tools/$SCRIPT-cmucl-linker-script ]; then
 	install ${GROUP} ${OWNER} -m 0755 src/tools/$SCRIPT-cmucl-linker-script $DESTDIR/lib/cmucl/lib/
diff --git a/src/lisp/GNUmakefile b/src/lisp/GNUmakefile
index 29bb52ac7..4abc3d26b 100644
--- a/src/lisp/GNUmakefile
+++ b/src/lisp/GNUmakefile
@@ -52,21 +52,15 @@ version.o : version.c version
 	$(CC) ${CFLAGS} $(CPPFLAGS) -DVERSION=`cat version` -c $<
 
 lisp: ${OBJS} version.o
-	$(CC) -g ${OS_LINK_FLAGS} -o ,lisp \
-		${OBJS} version.o \
-		${OS_LIBS} -lm
+	$(CC) -g ${OS_LINK_FLAGS} -o ,lisp $^ ${OS_LIBS} -lm
 	mv -f ,lisp lisp
 
 # Create a library out of all the object files so we can build an
 # executable.  However, we need to remove exec-init.o from the library
-# and replace it with exec-final.o because exec-final.o sets the
-# builtin_image_flag to 1 so that the runtime knows the runtime
-# contains the core sections.
 lisp.a:	version.o ${OBJS} ${EXEC_FINAL_OBJ}
 	$(AR) crs lisp.a ${OBJS} version.o
 ifneq (${EXEC_FINAL_OBJ},)
 	$(AR) d lisp.a exec-init.o
-	$(AR) r lisp.a ${EXEC_FINAL_OBJ}
 endif
 
 version:
diff --git a/src/tools/linker.sh b/src/tools/linker.sh
index a5a99ef66..0b2289086 100755
--- a/src/tools/linker.sh
+++ b/src/tools/linker.sh
@@ -139,5 +139,5 @@ trap 'rm -f $OUTDIR/$OPT_IFADDR $OUTDIR/CORRO.o $OUTDIR/CORSTA.o $OUTDIR/CORDYN.
 
 (cd $OUTDIR
 echo "long initial_function_addr = $IFADDR;" > $OPT_IFADDR
-$CCOMPILER -m32 -o $OUTNAME $OPT_IFADDR $OPT_ARCHIVE $OPT_CORE $RO_ADDR $STATIC_ADDR $DYN_ADDR $OPT_EXTRA $OS_LIBS -lm)
+$CCOMPILER -m32 -o $OUTNAME $OPT_IFADDR $OPT_ARCHIVE $CMUCLLIB/exec-final.o $OPT_CORE $RO_ADDR $STATIC_ADDR $DYN_ADDR $OPT_EXTRA $OS_LIBS -lm)
 
-- 
GitLab