Skip to content

Commit

Permalink
Fix dynamic linking with SB-LINKABLE-RUNTIME
Browse files Browse the repository at this point in the history
Shared objects were failing to link on the latest SBCL because it specifies
-fno-pie in its CFLAGS, but that invalidates the previously specified -fPIC.
Fix that by specifying -fPIC *after* the SBCL-provided CFLAGS, not *before*.

Also, remove a redundant use of -fPIC, and fix a comment.
  • Loading branch information
fare authored and luismbo committed Feb 21, 2017
1 parent 1c28a96 commit 417d920
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions grovel/asdf.lisp
Expand Up @@ -146,8 +146,7 @@
(alexandria:copy-file tmp-file output-file :if-to-exists :supersede)
(delete-file tmp-file))))


;; Allow for naked :grovel-file and :wrapper-file in asdf definitions.
;; Allow for naked :cffi-grovel-file and :cffi-wrapper-file in asdf definitions.
(setf (find-class 'asdf::cffi-grovel-file) (find-class 'grovel-file))
(setf (find-class 'asdf::cffi-wrapper-file) (find-class 'wrapper-file))

4 changes: 2 additions & 2 deletions toolchain/c-toolchain.lisp
Expand Up @@ -248,7 +248,7 @@ is bound to a temporary file name, then atomically renaming that temporary file

(defun cc-compile (output-file inputs)
(apply 'invoke-builder (list *cc* "-o") output-file
"-c" #-windows "-fPIC" (append *cc-flags* inputs)))
"-c" (append *cc-flags* #-windows '("-fPIC") inputs)))

(defun link-executable (output-file inputs)
(apply 'invoke-builder (list *ld* "-o") output-file
Expand Down Expand Up @@ -354,7 +354,7 @@ is bound to a temporary file name, then atomically renaming that temporary file
(defmethod perform ((o compile-op) (c c-file))
(let ((i (first (input-files o c))))
(destructuring-bind (.o .so) (output-files o c)
(cc-compile .o (list #-windows "-fPIC" i))
(cc-compile .o (list i))
(link-shared-library .so (list .o)))))

(defmethod perform ((o load-op) (c c-file))
Expand Down

0 comments on commit 417d920

Please sign in to comment.