gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] FreeBSD port (Was: Re: NetBSD/sparc port?)


From: Mark Murray
Subject: [Gcl-devel] FreeBSD port (Was: Re: NetBSD/sparc port?)
Date: Thu, 11 Sep 2003 20:11:14 +0100

Hi

I'm trying to fix GCL for FreeBSD, taking a lead from the NetBSD
work.

Camm Maguire writes:
> Greetings!
> 
> Basically this is just a means to get the wordsize on the machine.
> 
> #define ELFW(a) Mjoin(ELF,Mjoin(__ELF_NATIVE_CLASS,Mjoin(_,a)))
> 
> is supposed to exapand to ELF32a or ELF64a.  You can just define a
> constant for the machine your using as a first start.

I'm getting similar problems, but its not easy for me to see how to
apply the above.

I'm using some heavily hacked h/FreeBSD.(defs|h) files (attached),
and a handful of other patches (also attached).

My compile failure looks like

cc -O -pipe -mcpu=pentiumpro -DVOL=volatile -I/usr/ports/lang/gcl/work/gcl-2.5.3
/o -fsigned-char -Wall  -fomit-frame-pointer -Wall -DVOL=volatile -fsigned-char
-fwritable-strings -pipe -fomit-frame-pointer -I/usr/ports/lang/gcl/work/gcl-2.5
.3/o -I../h -I../o -o rsym rsym.c
In file included from rsym.c:18:
rsym_elf.c:31: error: syntax error before "pheader"
rsym_elf.c:31: warning: type defaults to `int' in declaration of `pheader'
rsym_elf.c:31: warning: data definition has no type or storage class
rsym_elf.c:32: error: syntax error before "eheader"
rsym_elf.c:32: warning: type defaults to `int' in declaration of `eheader'
rsym_elf.c:32: warning: data definition has no type or storage class
rsym_elf.c:33: error: syntax error before '*' token
rsym_elf.c:33: warning: type defaults to `int' in declaration of `symbol_table'
rsym_elf.c:33: warning: data definition has no type or storage class
rsym_elf.c:92: error: syntax error before '*' token
rsym_elf.c:92: warning: type defaults to `int' in declaration of 
`section_headers'
rsym_elf.c:92: warning: data definition has no type or storage class
rsym_elf.c: In function `get_section_number':
rsym_elf.c:99: error: request for member `e_shnum' in something not a structure 
or union

... etc, and it it barfing on lines that look like

#include <elf.h>
ElfW(Phdr) pheader;  <----- Line 31.
ElfW(Ehdr) eheader;
ElfW(Sym) *symbol_table;
int text_index,data_index,bss_index,sbss_index;
#undef SYM_NAME
#undef EXT_and_TEXT_BSS_DAT
#define mjoin(a,b) a ## b
#define Mjoin(a,b) mjoin(a,b)
#define ELFW(a) Mjoin(ELF,Mjoin(__ELF_NATIVE_CLASS,Mjoin(_,a)))

The closest set of Elf(32|64)_* typedefs that I can find are 

/usr/include/sys/elf32.h:typedef u_int32_t      Elf32_Addr;
/usr/include/sys/elf32.h:typedef u_int16_t      Elf32_Half;
/usr/include/sys/elf32.h:typedef u_int32_t      Elf32_Off;
/usr/include/sys/elf32.h:typedef int32_t                Elf32_Sword;
/usr/include/sys/elf32.h:typedef u_int32_t      Elf32_Word;
/usr/include/sys/elf32.h:typedef u_int32_t      Elf32_Size;
/usr/include/sys/elf32.h:typedef Elf32_Off      Elf32_Hashelt;

... and an equivalent set for the 64-bit case.

> How do we get GCL taken up by the BSD distros?  Is there any mechanism
> for systematizing these builds (i.e. 3Bsd x i386,sparc,...)

Take this to be a serious FreeBSD effort. The FreeBSD ports collection
will auto-build and distribute this port if it works.

I'm motivated to get this right, now, because I _really_ want
Maxima. :-)

M
--
Mark Murray
iumop ap!sdn w,I idlaH
#include "bsd.h"

#ifndef __ELF__
#error FreeBSD systems use ELF
#endif

#undef HAVE_AOUT
#define HAVE_AOUT <elf.h>
#define HAVE_ELF

#include <link.h>

#define ELF_TEXT_BASE  DBEGIN

#undef SET_REAL_MAXPAGE
#define SET_REAL_MAXPAGE do { struct rlimit data_rlimit; \
                              extern char etext; \
                               real_maxpage = MAXPAGE ;\
        getrlimit(RLIMIT_DATA, &data_rlimit); \
        real_maxpage = ((unsigned int)&etext/PAGESIZE \
                        + data_rlimit.rlim_cur/PAGESIZE - 
ELF_TEXT_BASE/PAGESIZE); \
        if (real_maxpage > MAXPAGE) \
                real_maxpage = MAXPAGE ; } while(0)

#ifdef USE_DLOPEN
#define SPECIAL_RSYM "rsym_elf.c"
#define SEPARATE_SFASL_FILE "fasldlsym.c"
#else
#ifdef HAVE_LIBBFD
#define SEPARATE_SFASL_FILE "sfaslbfd.c"
#else
#if !defined(__i386__) && !defined(__sparc__)
#error Can only do non-bfd relocs for i386 and sparc
#endif
#define SPECIAL_RSYM "rsym_elf.c"
#define SEPARATE_SFASL_FILE "sfaslelf.c"
#endif
#endif

#define UNEXEC_USE_MAP_PRIVATE
#define UNIXSAVE "unexelf.c"

#undef HAVE_SIGVEC
#define HAVE_SIGACTION
/* make this a noop */
#define SETUP_SIG_STACK
#ifndef HAVE_SV_ONSTACK
#define SV_ONSTACK 0
#endif

/* unblock signals m and n, and set val to signal_mask(m) | signal_mask(n)
   if they were set */
#define SIG_UNBLOCK_SIGNALS(val,m,n) \
    current_mask = sigblock(0);  \
    sigsetmask(~(sigmask(m)) & ~(sigmask(n)) & current_mask); \
    result = (current_mask & sigmask(m) ? signal_mask(m) : 0) \
      | (current_mask & sigmask(n) ? signal_mask(n) : 0);

#undef RUN_PROCESS

#define IEEEFLOAT
       
#undef HAVE_XDR

#define USE_ULONG_

/* we dont need to worry about zeroing fp->_base , to prevent  */
#define FCLOSE_SETBUF_OK 

/* #define DATA_BEGIN((TXTRELOC+header.a_text+(SEGSIZ-1)) & ~(SEGSIZ-1)); */
#define DATA_BEGIN (char *)(char *)N_DATADDR(header);

#define PAGSIZ          (NBPG)
#define SEGSIZ          (NBPG * CLSIZE)
#define TXTRELOC        0

#define USE_DIRENT
#define GETPATHNAME
#define PATHNAME_CACHE  10


#define INSTALL_SEGMENTATION_CATCHER \
         (void) signal(SIGSEGV,segmentation_catcher)


/* get the fileno of a FILE* */
#define FILENO(x) fileno(x)

#define ULONG_DEFINED

#undef LD_COMMAND
#define LD_COMMAND(command,main,start,input,ldarg,output) \
  sprintf(command, "ld -d -S -N -x -A %s -T %x %s %s -o %s", \
            main,start,input,ldarg,output)

#define SET_SESSION_ID() (setpgrp() ? -1 : 0)

#define CLEANUP_CODE \
  setbuf(stdin,0); \
   setbuf(stdout,0);

#define INIT_CORE_END terminal_io->sm.sm_object0->sm.sm_fp = 
stdin;terminal_io->sm.sm_object1->sm.sm_fp = stdout;

#define SEEK_TO_END_OFILE(fp) fseek(fp, 0, SEEK_END)
# Machine dependent makefile definitions for FreeBSD

LBINDIR=/bin

OFLAG   = -O -pipe -mcpu=pentiumpro
LIBS    = -lm -lreadline -lcompat

# This CC string will be used for compilation of the system,
# and also in the compiler::*cc* variable for later compilation of
# lisp files.
# (the -pipe is just since our file system is slow..)
CC = cc ${OFLAG} -DVOL=volatile -I$(GCLDIR)/o -fsigned-char -Wall 
$(EXTRA_CFLAGS) -fomit-frame-pointer

LDCC=${CC}

RSYM    = rsym

SFASL   = $(ODIR)/sfasl.o
# When using SFASL it is good to have (si::build-symbol-table)
INITFORM=(si::build-symbol-table)

# Use symbolic links
SYMB=-s

LIBFILES=bsearch.o

# the  make to use for saved_kcp the profiler.
KCP=kcp-bsd
--- configure-new.ac.ORIG       Tue Mar  4 15:05:37 2003
+++ configure-new.ac    Tue Mar  4 15:06:17 2003
@@ -328,7 +328,7 @@
                                    #include <bfd.h>
                                    int main() { symbol_info t; return 0;}],
                                AC_MSG_RESULT(no)
-                               AC_DEFINE(HAVE_LIBBFD)
+                               AC_DEFINE(HAVE_NO_LIBBFD)
                                LIBS="$LIBS  $BFDLIB $IBRLIB",
                                AC_TRY_RUN([#define IN_GCC
                                            #include <bfd.h>
@@ -336,7 +336,7 @@
                                            int main() {symbol_info t; return 
0;}],
                                        AC_MSG_RESULT(yes) 
                                        AC_DEFINE(NEED_CONST)
-                                       AC_DEFINE(HAVE_LIBBFD)
+                                       AC_DEFINE(HAVE_NO_LIBBFD)
                                        LIBS="$LIBS  $BFDLIB $IBRLIB",
                                        AC_MSG_RESULT(cannot use 
bfd),AC_MSG_RESULT(cannot use bfd)),
                                AC_MSG_RESULT(cannot use bfd))
--- configure.in.orig   Wed Feb 26 23:26:41 2003
+++ configure.in        Tue Mar  4 19:58:20 2003
@@ -358,7 +358,7 @@
        # for subconfigurations
        CFLAGS=-g
 else
-       TO3FLAGS="-O6 -fomit-frame-pointer"
+       TO3FLAGS="-fomit-frame-pointer"
        TO2FLAGS="-O"
 fi
 
@@ -568,13 +568,13 @@
 
 if test "$enable_dlopen" = "yes" ; then
 
-       AC_CHECK_LIB(dl,dlopen,have_dl=1,have_dl=0)
+       AC_CHECK_LIB(c,dlopen,have_dl=1,have_dl=0)
        if test "$have_dl" = "0" ; then
-               echo "Cannot find dlopen in -dl"
+               echo "Cannot find dlopen in -lc"
                exit 1
        fi
 
-       TLIBS="$TLIBS -ldl -rdynamic"
+       TLIBS="$TLIBS -lc"
        AC_DEFINE(USE_DLOPEN)
 fi
 
--- h/bsd.h.ORIG        Sat Jul 20 08:10:55 2002
+++ h/bsd.h     Fri Feb 28 22:37:56 2003
@@ -2,8 +2,6 @@
 #define UNIX
 #define AV
 #define SFASL
-#define HAVE_AOUT <a.out.h>
-
 
 #define MEM_SAVE_LOCALS        \
   struct exec header;\
@@ -26,15 +24,10 @@
   fwrite(&stsize, sizeof(stsize), 1, save); \
 filecpy(save, original, stsize - sizeof(stsize))
 
-
 #define NUMBER_OPEN_FILES getdtablesize() 
 
-
 extern char etext;
 
-
-
-
 #define SET_REAL_MAXPAGE do { struct rlimit data_rlimit; \
                                extern char etext; \
                             real_maxpage = MAXPAGE ; \
@@ -56,7 +49,6 @@
        { type_map[page(core_end)]= t_other; \
         core_end = core_end + PAGESIZE;} \
      if (core_end !=x) error("Someone allocated my memory");}} while (0)
- 
      
 #define INIT_ALLOC \
        heap_end = sbrk(0); ROUND_UP_SBRK(heap_end);\
@@ -70,7 +62,6 @@
      
 #define cs_check(x) 
 
-
 #define LD_COMMAND(command,main,start,input,ldarg,output) \
   sprintf(command, "ld -d -N -x -A %s -T %x %s %s -o %s", \
             main,start,input,ldarg,output)
@@ -78,9 +69,6 @@
 #define SYM_UNDEF_P(sym) ((N_SECTION(sym)) == N_UNDEF)
 #define NUM_AUX(sym) 0
 
-       /* the section like N_ABS,N_TEXT,.. */
-
-
   /* We have socket utilities, and can fork off a process
    and get a stream connection with it */
 #define RUN_PROCESS
@@ -89,14 +77,8 @@
 
 #define WANT_VALLOC  
 
-  /* if there is no input there return false */
-#define LISTEN_FOR_INPUT(fp) \
-  if((fp)->_cnt <=0 && (c=0,ioctl((fp)->_file, FIONREAD, &c),c<=0)) \
-     return 0
-
  /* have sys/ioctl.h */
 #define HAVE_IOCTL
-  
 
 #define HAVE_SIGVEC
   
--- h/protoize.h.orig   Thu Sep 11 08:33:59 2003
+++ h/protoize.h        Thu Sep 11 08:34:50 2003
@@ -285,7 +285,6 @@
 /* macros.c:224:OF */ extern void Lmacroexpand_1 (void); /* () */
 /* macros.c:265:OF */ extern object macro_expand (object form); /* (form) 
object form; */
 /* macros.c:344:OF */ extern void init_macros (void); /* () */
-/* main.c:111:OF */ extern int main (int argc, char **argv, char **envp); /* 
(argc, argv, envp) int argc; char **argv; char **envp; */
 /* main.c:346:OF */ extern void install_segmentation_catcher (void); /* () */
 /* main.c:359:OF */ extern void error (char *s); /* (s) char *s; */
 /* main.c:519:OF */ extern object vs_overflow (void); /* () */
--- ./o/readline.d.orig Thu Sep 11 08:07:24 2003
+++ ./o/readline.d      Thu Sep 11 08:07:53 2003
@@ -94,7 +94,6 @@
    the word to complete.  We can use the entire contents of rl_line_buffer
    in case we want to do some simple parsing.  Return the array of matches,
    or NULL if there aren't any. */
-extern char **completion_matches(char *,char *(*)(char *,int));
 static char **rl_completion(char *text, int start, int end) {
        return completion_matches(text, rl_completion_words);
 }
--- o/unixfasl.c.ORIG   Tue Mar  4 14:57:44 2003
+++ o/unixfasl.c        Tue Mar  4 15:01:42 2003
@@ -282,7 +282,7 @@
 static int
 faslink(object faslfile, object ldargstring)
 {
-#if defined(__linux__) && defined(__ELF__)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
   FEerror("faslink() not supported for ELF yet",0);
   return 0;
 #else
--- ./unixport/rsym.c.orig      Thu Sep 11 08:30:41 2003
+++ ./unixport/rsym.c   Thu Sep 11 08:31:27 2003
@@ -80,7 +80,6 @@
        unsigned int i;
        FILE *fp;
        int string_size=0;
-       extern char *malloc();
         
        fp = fopen(filename, RDONLY);
        

reply via email to

[Prev in Thread] Current Thread [Next in Thread]