relocate/locate fasl files
Greg Bennett
gwbennett at sentex.ca
Mon Jul 17 16:39:38 UTC 2017
-------------- next part --------------
[1]Good morning from Greg Bennett
[2]Running sbcl-1.3.18 64bit and asdf3.1.5
[3]using GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
[4]under Linux Mint 18.1 64bit
[5]
[6]If there is too much stuff below, apologies. It's not clear to me what is relevant.
[7]I am trying to learn about relocating fasl files and then locating them for loading.
[8]
[9]To do this I have a small system in /home/gwbennett/asdf-tests/
[10]consisting of gb-a.asd which contains (lines [12]-[15])
[11]
[12] (asdf:defsystem "gb-a"
[13] :description "gb-a: a small system"
[14] :components ((:file "gb-a-package")
[15] (:file "a-one" :depends-on ("gb-a-package"))))
[16]
[17]and gb-a-package.lisp which contains (lines [19]-[21])
[18]
[19] ;; This is a-package.lisp
[20](defpackage "GB-A"
[21] (:use "COMMON-LISP" "ASDF"))
[22]
[23]and a-one.lisp which contains (lines [25]-[29])
[24]
[25] (in-package :gb-a)
[26]
[27] (defun a-one (x)
[28] (setf x (+ 1 x))
[29] x)
[30]
[31]I have created gb-lisp.conf in /home/gwbennett/.config/common-lisp/source-registry.conf.d, and it contains (line [32])
[32] (:tree "/home/gwbennett/asdf-tests")
[33]
[34]Modifying code from lisp-in-a-box asdf-extensions.lisp, with thanks to Peter Seibel, I have (lines [35]-[60])
[35](defpackage "GWB-FASLS"
[36] (:use :cl :asdf))
[37]
[38](in-package "GWB-FASLS")
[39] ;;; Build FASLs into a implementation specific directory.
[40]
[41](defparameter *fasl-directory*
[42] (merge-pathnames
[43] (make-pathname
[44] :directory `(:relative "asdf-tests" "binaries"))
[45] (user-homedir-pathname)
[46] ))
[47]
[48](defmethod output-files :around ((operation compile-op) (c source-file))
[49] (let ((defaults (merge-pathnames
[50] ;(make-relative (component-pathname c))
[51] *fasl-directory* (make-relative (component-pathname c)))))
[52] (flet ((relocate-fasl (file)
[53] (make-pathname
[54] :type (pathname-type file) :defaults defaults)))
[55] (mapcar #'relocate-fasl (call-next-method)))))
[56]
[57](defun make-relative (pathname)
[58] (make-pathname
[59] :directory (cons :relative (rest (pathname-directory pathname)))
[60] :defaults pathname))
[61]
[62]I execute (asdf:clear-source-registry) -> No value
[63]and load the modified lisp-in-a-box and make sure I am (in-package :gwb-fasls)
[64]
[65]Then (asdf:load-system "gb-a")
[66]which yields, in slime's repl
[67]; compiling file "/home/gwbennett/asdf-tests/gb-a-package.lisp" (written 28 SEP 2016 08:49:14 AM):
[68]; compiling (DEFPACKAGE "GB-A" ...)
[69]
[70]; /home/gwbennett/asdf-tests/binaries/gb-a-package-TMP.fasl written
[71]; compilation finished in 0:00:00.083
[72]and in the error pane
[73]Couldn't load
[74]#P"/home/gwbennett/.cache/common-lisp/sbcl-1.3.18-linux-x64/home/gwbennett/asdf-tests/binaries/gb-a-package.fasl":
[75]file does not exist.
[76] [Condition of type SB-INT:SIMPLE-FILE-ERROR]
[77]
[78]In /home/gwbennett/asdf-tests there is now a subdirectory binaries in which there is gb-a-package.fasl
[79]as I had hoped.
[80]
[81]I suppose that the error message comes from the facts that the fasl was not written to the default location down in .cache
[82]and that a-one.lisp depends on the package defined in that fasl.
[83]
[84]The options in the error pane include, in position 3,
[85][ACCEPT] Continue, treating loading FASL for #<CL-SOURCE-FILE "gb-a" "gb-a-package"> as having been successful.
[86]so I clicked in this which leads to further output in the slime repl:
[87]WARNING:
[88] loading FASL for #<CL-SOURCE-FILE "gb-a" "gb-a-package"> completed without its input file #P"/home/gwbennett/.cache/common-lisp/sbcl-1.3.18-linux-x64/home/gwbennett/asdf-tests/binaries/gb-a-package.fasl"
[89]; compiling file "/home/gwbennett/asdf-tests/a-one.lisp" (written 24 MAY 2017 04:01:53 PM):
[90]; compiling (IN-PACKAGE :GB-A)
[91]; compiling (DEFUN A-ONE ...)
[92]
[93]; /home/gwbennett/asdf-tests/binaries/a-one-TMP.fasl written
[94]; compilation finished in 0:00:00.100
[95]
[96]and a futher error message
[97]Couldn't load
[98]#P"/home/gwbennett/.cache/common-lisp/sbcl-1.3.18-linux-x64/home/gwbennett/asdf-tests/binaries/a-one.fasl":
[99]file does not exist.
[100] [Condition of type SB-INT:SIMPLE-FILE-ERROR]
[101]
[102]Again I click [ACCEPT] and receive, in the slime repl
[103]WARNING:
[104] loading FASL for #<CL-SOURCE-FILE "gb-a" "a-one"> completed without its input file #P"/home/gwbennett/.cache/common-lisp/sbcl-1.3.18-linux-x64/home/gwbennett/asdf-tests/binaries/a-one.fasl"
[105]T
[106]and asdf-tests/binaries now does contain both gb-a-package.fasl and a-one.fasl
[107]
[108]Further, I can now (in-package :gb-a) which suggests that either gb-a-package.fasl or gb-a-package.lisp has been loaded.
[109]?? I'd like to know which one.
[110]The WARNING at line 87/88 suggests that it is the former but the phrase 'completed without its input file ..'
[111]is baffling to me.
[112]Once in :gb-a, I can also execute,eg., (a-one 11.2) ->12.2
[113]which suggests that the WARNING at lines 103/104 means that asdf-tests/binaries/a-one.fasl was really loaded.
[114]
[115] I seem to have been able to write the fasls to my choice of location, and asdf:load-system seems to
[116] have found them too. To avoid the WARNINGs, how do I tell asdf:load-system not to look in its default
[117] place or to look only in my choice? Perhaps there is an :around method on input-files which will do this,
[118] or perhaps I need a configuration file analogous to source-registry.conf.d/gb-lisp.conf, or perhaps I
[119] completely misunderstand the techniques needed to relocate/locate fasl files.
[120]
[121] Thanks for your patience and you insights
[122] Cheers /Greg Bennett
More information about the asdf-devel
mailing list