gcl-devel
[Top][All Lists]
Advanced

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

[Gcl-devel] Re: Using compiler::link


From: Camm Maguire
Subject: [Gcl-devel] Re: Using compiler::link
Date: 29 May 2008 11:05:28 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Waldek -- 

        1) Please excuse my very low bandwidth at the moment.  [ I am
           changing jobs at present, and anticipate having more time
           for gcl when done. ]

        2) compilier::link links via ld, so all module init function
           names must be unique.  In addition, it must compile a
           master init routine to call all the module init routines by
           name in normal C fashion, hence this routine.  As you
           state, there is code to find the elf or bfd init_ symbol in
           this case given a .o file, which is present at this time,
           but what results from this is an address to the function in
           the possibly loaded .o file at compiler::link time -- what one does
           not have is same address in the image produced by ld separately.

        3) Why do you need to ever call compiler::link on windows?
           :native-reloc should be set here, and any
        conditionalization based on this flag should work.

        4) Nevertheless, I think commenting out the #ifdef is a good
           idea, and will try to get it tested soon.  I will be gone
           until Sunday out of town.

        5) Martin, please excuse, I do not know to which email you
           refer -- if I've overlooked it please accept my apologies
           and feel free to resend if desired.

Take care,

Waldek Hebisch <address@hidden> writes:

> As Camm Maguire indicated, on some Debian architectures gcl can
> not create core images and must use compiler::link insted.
> 
> Below is a patch (diff to revision 286) that builds FriCAS using
> compiler::link.
> 
> I would like to include this patch in default version, but
> ATM we can not do this: currently compiler::link does not work
> on Windows.  
> 
> It is possible that a simple fix (just commenting out three lines)
> to gcl will allow compiler::link to work see:
> 
> http://groups.google.com/group/fricas-devel/msg/fa2dd417de15b7e7
> 
> however, I can not test this.
> 
> diff -ru trunk.bb/src/boot/Makefile.in trunk/src/boot/Makefile.in
> --- trunk.bb/src/boot/Makefile.in     2008-05-26 21:23:00.000000000 +0200
> +++ trunk/src/boot/Makefile.in        2008-05-26 21:23:15.000000000 +0200
> @@ -1,5 +1,4 @@
>  AXIOM_LOCAL_LISP_source = initial-env.lisp
> -AXIOM_LOCAL_LISP_object = $(AXIOM_LOCAL_LISP_source:.lisp=.$(LISPOBJEXT))
>  
>  address@hidden@
>  
> @@ -80,25 +79,17 @@
>  
>  ifeq ($(lisp_flavor),gcl)
>  
> -$(AXIOM_LOCAL_LISP): $(srcdir)/$(AXIOM_LOCAL_LISP_source)
> -     echo '(load "$(srcdir)/$(AXIOM_LOCAL_LISP_source)")' \
> -          '(in-package "FRICAS-LISP")' \
> -          '(save-core "$@")' | $(LISPSYS)
> -
> -$(BOOTSYS_EXE_TARGETS): %/bootsys$(EXEEXT): \
> -            $(OBJECTS) $(AXIOM_LOCAL_LISP)
> -     $(axiom_build_document) --tag=lisp --mode=link --output=$@ \
> -             --use=$(AXIOM_LOCAL_LISP) '$(patsubst %, "%", $(OBJECTS))'
> -
> -$(axiom_build_bindir)/bootsys$(EXEEXT): $(OBJECTS) $(AXIOM_LOCAL_LISP)
> -     $(axiom_build_document) --tag=lisp --mode=link --output=$(BASE)$@ \
> -             --use=$(AXIOM_LOCAL_LISP) '$(patsubst %, "%", $(OBJECTS))'
> +AXIOM_LOCAL_LISP_object = $(srcdir)/$(AXIOM_LOCAL_LISP_source)
>  
>  else
>  
> +AXIOM_LOCAL_LISP_object = $(AXIOM_LOCAL_LISP_source:.lisp=.$(LISPOBJEXT))
> +
>  $(AXIOM_LOCAL_LISP_object): %.$(LISPOBJEXT): $(srcdir)/%.lisp
>       $(COMPILE_LISP) --use=$(LISPSYS) $<
>  
> +endif
> +
>  $(AXIOM_LOCAL_LISP): $(AXIOM_LOCAL_LISP_object)
>       $(axiom_build_document) --tag=lisp --mode=link --output=$@ \
>                  --use=$(LISPSYS) \
> @@ -115,8 +106,6 @@
>               --use=$(LISPSYS) \
>               '$(patsubst %, "%", $(AXIOM_LOCAL_LISP_object) $(OBJECTS))'
>  
> -endif
> -
>  .PRECIOUS: %.$(LISPOBJEXT)
>  .PRECIOUS: %.clisp
>  .PRECIOUS: %.boot
> diff -ru trunk.bb/src/interp/Makefile.in trunk/src/interp/Makefile.in
> --- trunk.bb/src/interp/Makefile.in   2008-05-26 21:23:01.000000000 +0200
> +++ trunk/src/interp/Makefile.in      2008-05-26 22:06:11.000000000 +0200
> @@ -143,7 +143,7 @@
>  
>  ${SAVESYS} ${AXIOMSYS}: makeint.lisp \
>      ${DEPSYS} ${OBJS}  util.$(LISPOBJEXT) \
> -    $(srcdir)/sys-pkg.lisp \
> +    sys-pkg.lisp \
>      ${OCOBJS} ${OPOBJS} ${BROBJS} \
>      database.date ${INOBJS} ${ASCOMP} ${ASAUTO} \
>      ${NAGBROBJS} ${TRANOBJS} \
> @@ -176,14 +176,14 @@
>         '"${AXIOM}")' >> makeint.lisp
>       @ echo '(in-package "BOOT")' >> makeint.lisp
>       echo '#-:ecl(load "$(srcdir)/../algebra/warm.data")' >> makeint.lisp
> -     echo '#-:ecl(|clearClams|)' >> makeint.lisp
> +     echo '#-(or :gcl :ecl) (|clearClams|)' >> makeint.lisp
>       @ echo '#+:akcl (setq compiler::*suppress-compiler-notes* t)' >> 
> makeint.lisp
>       @ echo '#+:akcl (si::gbc-time 0)' >> makeint.lisp
>  
>  ${SAVESYS}:
> -     echo '(load "makeint.lisp") #-:ecl(VMLISP::reclaim)' \
> -             '#+:ecl(FRICAS-LISP::make-program "$(BASE)$@" nil)' \
> -             '#-:ecl(BOOT::spad-save "$(BASE)$@" t)' | ${LOADSYS}
> +     echo '(load "makeint.lisp") #-(or :gcl :ecl) (VMLISP::reclaim)' \
> +             '#+(or :gcl :ecl) (FRICAS-LISP::make-program "$(BASE)$@" nil)' \
> +             '#-(or :gcl :ecl) (BOOT::spad-save "$(BASE)$@" t)' | ${LOADSYS}
>  
>       @ echo 6 ${SAVESYS} created
>  
> @@ -242,9 +242,9 @@
>  
>  ${AXIOMSYS}:
>       echo '(defparameter FRICAS-LISP::*building-axiomsys* t)' \
> -        '(load "makeint.lisp") #-:ecl(VMLISP::reclaim)' \
> -        '#+:ecl(FRICAS-LISP::make-program "$(BASE)$@" nil)' \
> -        '#-:ecl(BOOT::spad-save "$(BASE)$@" t)' \
> +        '(load "makeint.lisp") #-(or :gcl :ecl) (VMLISP::reclaim)' \
> +        '#+(or :gcl :ecl) (FRICAS-LISP::make-program "$(BASE)$@" nil)' \
> +        '#-(or :gcl :ecl) (BOOT::spad-save "$(BASE)$@" t)' \
>               | DAASE="$(BASE)$(axiom_targetdir)" ${LOADSYS}
>       @ echo 6a ${AXIOMSYS} created
>  exposed.lsp: $(axiom_src_algdir)/exposed.lsp.pamphlet
> @@ -308,3 +308,5 @@
>       @ echo 11 making $@ from $<
>       echo '(progn (boottran::boottocl "$<" "$@") (${BYE}))' | ${DEPSYS}
>  
> +sys-pkg.lisp: $(srcdir)/sys-pkg.lisp
> +     cp $< $@
> Tylko w trunk/src/interp: Makefile.in.orig
> diff -ru trunk.bb/src/interp/util.lisp trunk/src/interp/util.lisp
> --- trunk.bb/src/interp/util.lisp     2008-05-26 21:23:01.000000000 +0200
> +++ trunk/src/interp/util.lisp        2008-05-26 23:25:13.000000000 +0200
> @@ -752,7 +752,7 @@
>  (defun build-interpsys (load-files parse-files comp-files browse-files
>               translate-files nagbr-files asauto-files spad)
>    (declare (ignore nagbr-files))
> -  #-:ecl
> +  #-(or :gcl :ecl)
>    (progn
>        (mapcar #'load load-files)
>        (interpsys-image-init parse-files comp-files browse-files
> @@ -767,45 +767,60 @@
>             (setf |$createLocalLibDb| t)
>         )
>    )
> -  #+:ecl
> -  (progn
> +  #+(or :gcl :ecl)
> +  (let ((initforms nil))
>        (setf FRICAS-LISP::*fricas-initial-lisp-objects*
>             (append FRICAS-LISP::*fricas-initial-lisp-objects*
> -                   '("sys-pkg.o" "util.o")
> +                   '(#+:gcl "sys-pkg.lisp" #-:gcl "sys-pkg.o" "util.o")
>                     load-files))
>        (dolist (el `(("parse-files" ,parse-files)
>                      ("comp-files" ,comp-files)
>                      ("browse-files" ,browse-files)
>                      ("translate-files" ,translate-files)
>                      ("asauto-files" ,asauto-files)))
> -          (c:build-fasl (concatenate 'string spad "/autoload/" (car el))
> -                        :lisp-files (nth 1 el)))
> -      (let ((initforms nil))
> -          (dolist (el '(*YEARWEEK* *BUILD-VERSION* timestamp
> -                    |$createLocalLibDb|))
> -              (if (boundp el)
> -                  (push (list 'defparameter el (symbol-value el))
> -                        initforms)))
> -          (push `(interpsys-ecl-image-init ,spad) initforms)
> -          (setf initforms (reverse initforms))
> -          (push `progn initforms)
> -          (setf FRICAS-LISP::*fricas-initial-lisp-forms* initforms)
> -      )
> +          (let ((sym (intern (concatenate
> +                               'string "*" (car el)
> +                               "-autoload-list*")))
> +                (fnames #+:gcl(nth 1 el)
> +                        #+:ecl(list 
> +                                 (concatenate 'string "/autoload/" (car 
> el)))))
> +            #+:ecl
> +            (c:build-fasl (concatenate 'string spad "/autoload/" (car el))
> +                        :lisp-files (nth 1 el))
> +            (push `(defparameter ,sym (quote ,fnames)) initforms)
> +      ))
> +      (dolist (el '(*YEARWEEK* *BUILD-VERSION* timestamp
> +                    |$createLocalLibDb|
> +                    #+:gcl compiler::*default-system-p* ))
> +          (if (boundp el)
> +              (push (list 'defparameter el (symbol-value el))
> +                    initforms)))
> +      (push `(defparameter $spadroot ,spad) initforms)
> +
> +      #+:gcl
> +      (push `(setf system::*top-level-hook* #'interpsys-ecl-image-init)
> +            initforms)
> +      #+:ecl
> +      (push `(interpsys-ecl-image-init) initforms)
> +
> +      (setf initforms (reverse initforms))
> +      (push `progn initforms)
> +      (setf FRICAS-LISP::*fricas-initial-lisp-forms* initforms)
>    )
>  )
>  
> -(defun interpsys-ecl-image-init (spad)
> +(defun interpsys-ecl-image-init ()
>       (format *standard-output* "Starting interpsys~%")
> -     (format *standard-output* "spad = ~s~%" spad)
> +     (format *standard-output* "spad = ~s~%" $spadroot)
>       (force-output  *standard-output*)
>       ;;; (load (concatenate 'string spad "/autoload/"  "parini.lsp"))
>       (interpsys-image-init
> -           (list (concatenate 'string spad "/autoload/"  "parse-files"))
> -           (list (concatenate 'string spad "/autoload/" "comp-files"))
> -           (list (concatenate 'string spad "/autoload/" "browse-files"))
> -           (list (concatenate 'string spad "/autoload/" "translate-files"))
> -           (list (concatenate 'string spad "/autoload/" "asauto-files"))
> -           spad)
> +           |*parse-files-autoload-list*|
> +           |*comp-files-autoload-list*|
> +           |*browse-files-autoload-list*|
> +           |*translate-files-autoload-list*|
> +           |*asauto-files-autoload-list*|
> +           $spadroot)
>        (format *standard-output* "before fricas-restart~%")
>        (force-output  *standard-output*)
>        (fricas-restart))
> diff -ru trunk.bb/src/lisp/fricas-lisp.lisp trunk/src/lisp/fricas-lisp.lisp
> --- trunk.bb/src/lisp/fricas-lisp.lisp        2008-05-26 21:23:01.000000000 
> +0200
> +++ trunk/src/lisp/fricas-lisp.lisp   2008-05-26 22:45:16.000000000 +0200
> @@ -130,7 +130,7 @@
>  
>  ;;; Making (linking) program
>  
> -#-:ecl
> +#-(or :gcl :ecl)
>  (defun make-program (core-image lisp-files)
>      (load-lisp-files lisp-files)
>      (save-core core-image))
> @@ -147,7 +147,23 @@
>               :ld-flags *fricas-extra-c-files*))
>      (quit))
>  
> -
> +#+:gcl
> +(defun make-program (core-image lisp-files)
> +    (compiler::link (append *fricas-initial-lisp-objects* lisp-files)
> +                    core-image
> +                    (format nil 
> +                    "(progn (let ((*load-path* (cons ~S *load-path*))
> +                                  (si::*load-types* ~S))
> +                                (compiler::emit-fn t))
> +                            (when (fboundp (quote si::sgc-on))
> +                                  (si::sgc-on nil))
> +                            (setq compiler::*default-system-p* t)
> +                            ~S)"
> +                            si::*system-directory*
> +                            (quote (list ".lsp"))
> +                            *fricas-initial-lisp-forms*)
> +                    *fricas-extra-c-files*)
> +    (quit))
>  
>  ;;; -----------------------------------------------------------------
>  
> @@ -226,7 +242,7 @@
>  ))               
>  
>  (defun c-args-to-gcl (arguments)
> -   (declare (safety 3))
> +   (declare (optimize (safety 3)))
>     (mapcar (lambda (x) (c-type-to-ffi (nth 1 x))) arguments))
>  
>  (defun gcl-foreign-call (name c-name return-type arguments)
> diff -ru trunk.bb/src/lisp/Makefile.in trunk/src/lisp/Makefile.in
> --- trunk.bb/src/lisp/Makefile.in     2008-05-26 21:23:01.000000000 +0200
> +++ trunk/src/lisp/Makefile.in        2008-05-26 21:23:15.000000000 +0200
> @@ -38,22 +38,21 @@
>  
>  do_it.gcl: fricas-lisp.lisp fricas-package.lisp
>       @axiom_gcl_rsym_hack@
> -     echo '(load "fricas-package.lisp") (load "fricas-lisp.lisp")' \
> -          '(setq compiler::*default-system-p* t)' \
> -          '(compile-file "fricas-lisp.lisp")' | $(FRICAS_LISP)
> -     echo '(compiler::link nil "prelisp" ' \
> -              ' (format nil "(progn (let ((*load-path* (cons ~S 
> *load-path*))'\
> -                                        ' (si::*load-types* ~S))' \
> -                                       ' (compiler::emit-fn t))' \
> -                                  ' (when (fboundp (quote si::sgc-on))' \
> -                                        ' (si::sgc-on nil))' \
> -                                  ' (setq compiler::*default-system-p* t))"' 
> \
> -                      ' si::*system-directory* (quote (list ".lsp")))' \
> -               '  "$(lisp_c_objects) @axiom_c_runtime_extra@")' \
> -            | $(FRICAS_LISP)
> -     echo '(load "fricas-package.lisp") (load "fricas-lisp.$(OBJEXT)")' \
> -          '(in-package "FRICAS-LISP") (save-core "$(OUT)/lisp$(EXEEXT)")' \
> -         | ./prelisp$(EXEEXT)
> +     echo '(in-package "FRICAS-LISP")' > fricas-gcl.lisp
> +     echo '(defvar *fricas-extra-c-files*' \
> +                      '"$(lisp_c_objects) @axiom_c_runtime_extra@")' \
> +              >> fricas-gcl.lisp
> +     echo "(defvar *fricas-initial-lisp-forms* nil)" >> fricas-gcl.lisp
> +     echo "(defvar *fricas-initial-lisp-objects* (quote (" \
> +            $(patsubst %, "\"$(BASE)$(abs_builddir)/%\"", \
> +              fricas-package.lisp fricas-gcl.lisp fricas-lisp.o) ")))" \
> +              >> fricas-gcl.lisp
> +     echo '(load "fricas-package.lisp") (load "fricas-gcl.lisp")' \
> +             '(load "fricas-lisp.lisp")' \
> +             '(in-package "FRICAS-LISP")' \
> +             '(setq compiler::*default-system-p* t)' \
> +             '(compile-file "fricas-lisp.lisp")' \
> +             '(make-program "${OUT}/lisp" nil)' | $(FRICAS_LISP)
>       $(STAMP) $@
>  
>  fricas-lisp.lisp: $(srcdir)/fricas-lisp.lisp
> 
> -- 
>                               Waldek Hebisch
> address@hidden 
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

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