Skip to content

Instantly share code, notes, and snippets.

@ralt
Created May 22, 2020 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralt/3288f886c5a2baf7c7160c78af02aef2 to your computer and use it in GitHub Desktop.
Save ralt/3288f886c5a2baf7c7160c78af02aef2 to your computer and use it in GitHub Desktop.
modified src/libraries.lisp
@@ -372,7 +372,7 @@ This will need to be extended as we test on more OSes."
(load-foreign-library-path name library-path search-path)))
(:or (try-foreign-library-alternatives name (rest thing) search-path))))))
-(defun %do-load-foreign-library (library search-path)
+(defun %do-load-foreign-library (library search-path type)
(flet ((%do-load (lib name spec)
(when (foreign-library-spec lib)
(with-slots (handle pathname) lib
@@ -392,7 +392,7 @@ This will need to be extended as we test on more OSes."
(first library)
(file-namestring library)))))
(lib (make-instance 'foreign-library
- :type :system
+ :type type
:name lib-name
:spec `((t ,library))
:search-path search-path)))
@@ -406,7 +406,7 @@ This will need to be extended as we test on more OSes."
(pathname (namestring thing))
(t thing)))
-(defun load-foreign-library (library &key search-path)
+(defun load-foreign-library (library &key search-path (type :system))
"Loads a foreign LIBRARY which can be a symbol denoting a library defined
through DEFINE-FOREIGN-LIBRARY; a pathname or string in which case we try to
load it directly first then search for it in *FOREIGN-LIBRARY-DIRECTORIES*;
@@ -422,16 +422,16 @@ or finally list: either (:or lib1 lib2) or (:framework <framework-name>)."
;; errors.
(ignore-some-conditions (foreign-library-undefined-error)
(close-foreign-library library))
- (%do-load-foreign-library library search-path))
+ (%do-load-foreign-library library search-path type))
;; Offer these restarts that will retry the call to
;; %LOAD-FOREIGN-LIBRARY.
(retry ()
:report "Try loading the foreign library again."
- (load-foreign-library library :search-path search-path))
+ (load-foreign-library library :search-path search-path :type type))
(use-value (new-library)
:report "Use another library instead."
:interactive read-new-value
- (load-foreign-library new-library :search-path search-path)))))
+ (load-foreign-library new-library :search-path search-path :type type)))))
(defmacro use-foreign-library (name)
`(load-foreign-library ',name))
modified toolchain/c-toolchain.lisp
@@ -368,7 +368,7 @@ is bound to a temporary file name, then atomically renaming that temporary file
(defmethod perform ((o load-op) (c c-file))
(let ((o (second (input-files o c))))
- (cffi:load-foreign-library (file-namestring o) :search-path (list (pathname-directory-pathname o)))))
+ (cffi:load-foreign-library (file-namestring o) :search-path (list (pathname-directory-pathname o)) :type :grovel-wrapper)))
(setf (find-class 'asdf::c-file) (find-class 'c-file))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment