Skip to content
Snippets Groups Projects
Commit aa09793a authored by rtoy's avatar rtoy
Browse files

Add support for executable stuff using Sun C on sparc. The executable

appears to be created successfully, and you can do things, but it is
not usable.

lisp/elf.h:
o Set C_COMPILER to either "cc" or "gcc".  We use gcc everywhere,
  except if the C compiler is Sun C on sparc.

lisp/elf.c:
o Print out C_COMPILER as the first arg to the linker script.

tools/linker.sh:
o Rearrange code so test for number of args is done first.
o Look at the first arg to determine the C compiler used.  If gcc, use
  the original code.  Add new code to support Sun C.
parent e52781c9
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@
Above changes put into main CVS branch. 05-Jul-2007.
$Id: elf.c,v 1.13 2007/07/25 15:35:32 fgilham Exp $
$Id: elf.c,v 1.14 2007/08/14 15:57:47 rtoy Exp $
*/
#include <stdio.h>
......@@ -346,7 +346,8 @@ elf_run_linker(long init_func_address, char *file)
free(paths);
printf("\t[%s: linking %s... \n", command, file);
fflush(stdout);
sprintf(command_line, "%s 0x%lx %s", command, init_func_address, file);
sprintf(command_line, "%s %s 0x%lx %s", command, C_COMPILER,
init_func_address, file);
ret = system(command_line);
if(ret == -1) {
perror("Can't run link script");
......
/* $Id: elf.h,v 1.7 2007/07/24 19:09:14 rtoy Exp $ */
/* $Id: elf.h,v 1.8 2007/08/14 15:57:47 rtoy Exp $ */
/* This code was written by Fred Gilham and has been placed in the public domain. It is
provided "AS-IS" and without warranty of any kind.
......@@ -16,6 +16,17 @@
#include <elf.h>
#endif
/*
* We need to know which compiler was used to build lisp. I think gcc
* is used everywhere, except on Solaris/sparc, where we can use
* either gcc or Sun C.
*/
#if defined(__SUNPRO_C) && defined(__sparc)
#define C_COMPILER "cc"
#else
#define C_COMPILER "gcc"
#endif
int write_elf_object(const char *, int, os_vm_address_t, os_vm_address_t);
void elf_cleanup(const char *);
int elf_run_linker(long, char *);
......
#!/bin/sh -x
# $Id: linker.sh,v 1.6 2007/07/25 16:33:16 rtoy Exp $
# $Id: linker.sh,v 1.7 2007/08/14 15:57:48 rtoy Exp $
# This file was written by Fred Gilham and is placed in the public domain.
# It comes without warranty of any kind.
PATH=/bin:/usr/bin:/usr/local/bin
GCC=`which gcc`
if [ -z "$GCC" ]
if [ $# -ne 3 ]
then
echo 'Cannot find GCC. How did you build lisp?'
echo "Usage: `basename $0` <c-compiler> <initial function address> <executable file>"
exit 1
fi
# Uniform method for finding GCC C runtime object files suggested by Ray Toy
CRTPATH=`$GCC -print-libgcc-file-name`
LIBROOT=`dirname $CRTPATH`
echo "LIBROOT is $LIBROOT"
CCOMPILER=$1
shift;
if [ $# -ne 2 ]
then
echo "Usage: `basename $0` <initial function address> <executable file>"
exit 1
if [ $CCOMPILER = "cc" ]; then
# Sun C compiler
# Can't set PATH because we don't really know where the compiler
# is. The user has to have it in his path.
CC=`which cc`
if [ -z "$CC" ]; then
echo 'Cannot find Sun C. Is it available and in $PATH?'
exit 1
fi
CRTPATH=`dirname $CC`/../prod
LIBROOT=$CRTPATH/lib
else
# Gcc
PATH=/bin:/usr/bin:/usr/local/bin
GCC=`which gcc`
if [ -z "$GCC" ]; then
echo 'Cannot find GCC. How did you build lisp?'
exit 1
fi
# Uniform method for finding GCC C runtime object files suggested by Ray Toy
CRTPATH=`$GCC -print-libgcc-file-name`
LIBROOT=`dirname $CRTPATH`
fi
echo "LIBROOT is $LIBROOT"
OPSYS=`uname`
VER=''
......@@ -77,9 +97,17 @@ case "$OPSYS" in
LIBS='-lm -lgcc -lc -lgcc'
;;
SunOS )
STARTCRT="$LIBROOT/crt1.o $LIBROOT/crti.o $LIBROOT/crtbegin.o"
ENDCRT="$LIBROOT/crtend.o $LIBROOT/crtn.o"
LIBS="-L$LIBROOT -lm -lgcc -lc -lgcc -lsocket -lnsl -ldl"
if [ $CCOMPILER = "cc" ]; then
# These values were obtained by running cc -# hello.c and
# looking at the linker command.
STARTCRT="$LIBROOT/crti.o $LIBROOT/crt1.o $LIBROOT/misalign.o $LIBROOT/values-xa.o"
ENDCRT="$LIBROOT/crtn.o"
LIBS="-Y P,$LIBROOT/v8plus:$LIBROOT:/usr/ccs/lib:/lib:/usr/lib -Qy -lm -lc -lsocket -lnsl -ldl"
else
STARTCRT="$LIBROOT/crt1.o $LIBROOT/crti.o $LIBROOT/crtbegin.o"
ENDCRT="$LIBROOT/crtend.o $LIBROOT/crtn.o"
LIBS="-L$LIBROOT -lm -lgcc -lc -lgcc -lsocket -lnsl -ldl"
fi
LINKER="/usr/ccs/bin/ld"
OBJS="-z allextract $CMUCLLIB/lisp.a CORRO.o CORSTA.o CORDYN.o -z defaultextract"
SCRIPT="$CMUCLLIB/$OPSYS$VER-cmucl-linker-script"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment