mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-04 16:30:48 -08:00
LOAD-FOREIGN-LIBRARY instructs the compiler to use a '-l' flag instead of directly referencing *.so/*.dll library
This commit is contained in:
parent
2ef5cb1753
commit
92f266b8e3
2 changed files with 36 additions and 21 deletions
|
|
@ -205,6 +205,11 @@ ECL 1.0:
|
|||
ecl_char_code(), cl_log1() -> ecl_log1(), cl_log2() -> ecl_log2(),
|
||||
NUMBER_TYPE() -> ECL_NUMBER_TYPE_P().
|
||||
|
||||
- LOAD-FOREIGN-LIBRARY accepts an additional keyword argument :SYSTEM-LIBRARY
|
||||
which, when true, tells ECL to link object files against the system version
|
||||
of that library instead of directly referencing the shared library: i.e. use
|
||||
linker flag -lmylib instead of libmylib.so (Brian Spilsbury)
|
||||
|
||||
* Contributed code:
|
||||
|
||||
- New examples: cmdline/ls.lsp, ffi/uffi.lsp, ffi/cffi.lsp
|
||||
|
|
|
|||
|
|
@ -617,28 +617,38 @@
|
|||
|
||||
(defvar +loaded-libraries+ nil)
|
||||
|
||||
(defun do-load-foreign-library (tmp)
|
||||
(let* ((path (cond ((pathnamep tmp) tmp)
|
||||
((probe-file (setf tmp (string tmp))) tmp)
|
||||
(t (compile-file-pathname tmp :type #+msvc :lib #-msvc :dll))))
|
||||
(filename (namestring path))
|
||||
(pack (find-package "COMPILER")))
|
||||
(unless (find filename ffi::+loaded-libraries+ :test #'string-equal)
|
||||
(setf (symbol-value (intern "*LD-FLAGS*" pack)) (concatenate 'string (symbol-value (intern "*LD-FLAGS*" pack)) " " filename))
|
||||
(setf (symbol-value (intern "*LD-BUNDLE-FLAGS*" pack)) (concatenate 'string (symbol-value (intern "*LD-BUNDLE-FLAGS*" pack)) " " filename))
|
||||
(setf (symbol-value (intern "*LD-SHARED-FLAGS*" pack)) (concatenate 'string (symbol-value (intern "*LD-SHARED-FLAGS*" pack)) " " filename))
|
||||
(push filename ffi::+loaded-libraries+))
|
||||
t))
|
||||
(defun do-load-foreign-library (tmp &optional system-library)
|
||||
(let* ((path (cond ((pathnamep tmp) tmp)
|
||||
((probe-file (setf tmp (string tmp))) tmp)
|
||||
(t (compile-file-pathname tmp :type #+msvc :lib #-msvc :dll))))
|
||||
(filename (namestring path))
|
||||
(pack (find-package "COMPILER"))
|
||||
(flag (if system-library
|
||||
(concatenate 'string "-l" tmp)
|
||||
filename)))
|
||||
(unless (find filename ffi::+loaded-libraries+ :test #'string-equal)
|
||||
(setf (symbol-value (intern "*LD-FLAGS*" pack))
|
||||
(concatenate 'string (symbol-value (intern "*LD-FLAGS*" pack)) " " flag))
|
||||
(setf (symbol-value (intern "*LD-BUNDLE-FLAGS*" pack))
|
||||
(concatenate 'string (symbol-value (intern "*LD-BUNDLE-FLAGS*" pack))
|
||||
" " flag))
|
||||
(setf (symbol-value (intern "*LD-SHARED-FLAGS*" pack))
|
||||
(concatenate 'string (symbol-value (intern "*LD-SHARED-FLAGS*" pack))
|
||||
" " flag))
|
||||
(push filename ffi::+loaded-libraries+))
|
||||
t))
|
||||
|
||||
(defmacro load-foreign-library (filename &key module supporting-libraries force-load)
|
||||
(declare (ignore module force-load supporting-libraries))
|
||||
(let ((compile-form (and (constantp filename)
|
||||
`((eval-when (:compile-toplevel)
|
||||
(do-load-foreign-library ,filename)))))
|
||||
(dyn-form #+dffi (when si::*use-dffi*
|
||||
`((si:load-foreign-module ,filename)))
|
||||
#-dffi nil))
|
||||
`(progn ,@compile-form ,@dyn-form)))
|
||||
(defmacro load-foreign-library (filename &key module supporting-libraries force-load
|
||||
system-library)
|
||||
(declare (ignore module force-load supporting-libraries))
|
||||
(let ((compile-form (and (constantp filename)
|
||||
`((eval-when (:compile-toplevel)
|
||||
(do-load-foreign-library ,filename
|
||||
,system-library)))))
|
||||
(dyn-form #+dffi (when (and (not system-library) si::*use-dffi*)
|
||||
`((si:load-foreign-module ,filename)))
|
||||
#-dffi nil))
|
||||
`(progn ,@compile-form ,@dyn-form))))
|
||||
|
||||
;;;----------------------------------------------------------------------
|
||||
;;; CALLBACKS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue