Permalink
Browse files

Add Boot support for native load unit specification in foreign

function import.
  • Loading branch information...
GabrielDosReis committed Dec 29, 2016
1 parent a8a3b2c commit 2bd3cc876cc90b8e28e0e8d88a5982f69729f867
View
@@ -1,3 +1,8 @@
2016-12-29 Gabriel Dos Reis <gdr@axiomatics.org>
* config/open-axiom.m4 (oa_shrlib_prefix): New AC_SUBST'd variable.
* config/var-def.mk (oa_shrlib_prefix): New.
2016-02-14 Bill Page <bill.page@newsynthesis.org>
* config/open-axiom.m4 (X_PRE_LIBS): Fix typo.
View
@@ -436,6 +436,7 @@ oa_lisp_flavor = @oa_lisp_flavor@
oa_optimize_options = @oa_optimize_options@
oa_quiet_flags = @oa_quiet_flags@
oa_shrlib_flags = @oa_shrlib_flags@
oa_shrlib_prefix = @oa_shrlib_prefix@
oa_shrobj_flags = @oa_shrobj_flags@
oa_src_algdir = @oa_src_algdir@
oa_src_datadir = @oa_src_datadir@
View
@@ -632,7 +632,7 @@ AC_DEFINE_UNQUOTED([OPENAXIOM_HOST_LISP_PRECISION],
dnl --------------------------------------
dnl -- OPENAXIOM_DYNAMIC_MODULE_SUPPORT --
dnl --------------------------------------
dnl Infer compiler flags and file extensions associated
dnl Infer compiler flags, file prefix and extensions associated
dnl with dynamic module support.
dnl We need to link some C object files into in the Lisp images we
dnl use. Some Lisps (e.g. GCL, ECL) support inclusion of ``ordinary''
@@ -646,6 +646,7 @@ AC_DEFUN([OPENAXIOM_DYNAMIC_MODULE_SUPPORT],[
AC_SUBST(oa_use_libtool_for_shared_lib)
AC_SUBST(oa_shrobj_flags)
AC_SUBST(oa_shrlib_flags)
AC_SUBST(oa_shrlib_prefix)
oa_use_libtool_for_shared_lib=no
oa_shrobj_flags=
oa_shrlib_flags=
@@ -654,6 +655,8 @@ oa_shrlib_flags=
LT_PREREQ([2.2.6])
LT_INIT([pic-only dlopen win32-dll shared])
AC_SUBST([LIBTOOL_DEPS])
# Most targets use 'lib' prefix, as in 'libOpenAxiom'.
oa_shrlib_prefix='lib'
# Give me extension of libraries
AC_SUBST(shared_ext)
AC_SUBST(libext)
@@ -663,6 +666,8 @@ case $host in
*mingw*|*cygwin*)
oa_shrobj_flags='-prefer-pic'
oa_shrlib_flags="-shared -Wl,--export-all-symbols"
# Windows platforms don't need a prefix
oa_shrlib_prefix=
;;
*darwin*)
oa_shrobj_flags='-dynamic'
View
@@ -61,6 +61,7 @@ CXXFLAGS = @CXXFLAGS@
LDFLAGS = @LDFLAGS@
OBJEXT = @OBJEXT@
EXEEXT = @EXEEXT@
oa_shrlib_prefix = @oa_shrlib_prefix@
# this includes leading period
SHREXT = @shared_ext@
# extension of the archive library; this does not include period
View
@@ -700,6 +700,7 @@ LIBTOOL
OBJDUMP
DLLTOOL
AS
oa_shrlib_prefix
oa_shrlib_flags
oa_shrobj_flags
oa_use_libtool_for_shared_lib
@@ -9280,6 +9281,7 @@ func_stripname_cnf ()
oa_use_libtool_for_shared_lib=no
oa_shrobj_flags=
oa_shrlib_flags=
@@ -16755,6 +16757,8 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
# Most targets use 'lib' prefix, as in 'libOpenAxiom'.
oa_shrlib_prefix='lib'
# Give me extension of libraries
@@ -16764,6 +16768,8 @@ case $host in
*mingw*|*cygwin*)
oa_shrobj_flags='-prefer-pic'
oa_shrlib_flags="-shared -Wl,--export-all-symbols"
# Windows platforms don't need a prefix
oa_shrlib_prefix=
;;
*darwin*)
oa_shrobj_flags='-dynamic'
View
@@ -1,3 +1,17 @@
2016-12-29 Gabriel Dos Reis <gdr@axiomatics.org>
* lisp/core.lisp.in ($NativeModulePrefix): Define and export.
* boot/ast.boot (%Ast): Ad %LoadUnit alternative.
(genImportDeclaration): Take a third parameter. Update caller.
* boot/parser.boot (bpProvenance): New.
(bpImport): Use it to parse load unit specification.
* boot/translator.boot ($foreignLoadUnits): New.
(translateToplevel): Update.
(loadNativeModule): Tidy.
(loadSystemRuntimeCore): Likewise.
* lib/Makefile.in: Tidy reference to shared library pathname.
* lisp/Makefile.in (edit): Translate oa_shrlib_prefix.
2016-12-26 Gabriel Dos Reis <gdr@axiomatics.org>
* interp/i-output.boot (appChar): Don't modify string parameter.
View
@@ -368,6 +368,7 @@ oa_lisp_flavor = @oa_lisp_flavor@
oa_optimize_options = @oa_optimize_options@
oa_quiet_flags = @oa_quiet_flags@
oa_shrlib_flags = @oa_shrlib_flags@
oa_shrlib_prefix = @oa_shrlib_prefix@
oa_shrobj_flags = @oa_shrobj_flags@
oa_src_algdir = @oa_src_algdir@
oa_src_datadir = @oa_src_datadir@
View
@@ -552,6 +552,7 @@ oa_lisp_flavor = @oa_lisp_flavor@
oa_optimize_options = @oa_optimize_options@
oa_quiet_flags = @oa_quiet_flags@
oa_shrlib_flags = @oa_shrlib_flags@
oa_shrlib_prefix = @oa_shrlib_prefix@
oa_shrobj_flags = @oa_shrobj_flags@
oa_src_algdir = @oa_src_algdir@
oa_src_datadir = @oa_src_datadir@
View
@@ -396,6 +396,7 @@ oa_lisp_flavor = @oa_lisp_flavor@
oa_optimize_options = @oa_optimize_options@
oa_quiet_flags = @oa_quiet_flags@
oa_shrlib_flags = @oa_shrlib_flags@
oa_shrlib_prefix = @oa_shrlib_prefix@
oa_shrobj_flags = @oa_shrobj_flags@
oa_src_algdir = @oa_src_algdir@
oa_src_datadir = @oa_src_datadir@
View
@@ -61,7 +61,8 @@ structure %Ast ==
%Module(%Symbol,%List,%List) -- module declaration
%Namespace(%Symbol) -- namespace AxiomCore
%Import(%Ast) -- import module; import namespace foo
%ImportSignature(%Symbol,%Signature) -- import function declaration
%LoadUnit(%Symbol) -- System.LoadUnit lib
%ImportSignature(%Symbol,%Signature,%Domain) -- import function declaration
%Record(%List,%List) -- Record(num: %Short, den: %Short)
%AccessorDef(%Symbol,%Ast) -- numerator == (.num)
%TypeAlias(%Head, %List) -- type alias definition
@@ -1950,11 +1951,13 @@ $ffs := nil
++ Generate an import declaration for `op' as equivalent of the
++ foreign signature `sig'. Here, `foreign' operationally means that
++ the entity is from the C language world.
genImportDeclaration(op, sig) ==
genImportDeclaration(op, sig, dom) ==
sig isnt ["%Signature", op', m] => coreError '"invalid signature"
m isnt ["%Mapping", t, s] => coreError '"invalid function type"
if s ~= nil and symbol? s then s := [s]
$ffs := [op,:$ffs]
if dom is ["%LoadUnit",lib] and not symbolMember?(lib,$foreignLoadUnits) then
$foreignLoadUnits := [lib,:$foreignLoadUnits]
%hasFeature KEYWORD::GCL => genGCLnativeTranslation(op,s,t,op')
%hasFeature KEYWORD::SBCL => genSBCLnativeTranslation(op,s,t,op')
View
@@ -1,6 +1,6 @@
-- Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd.
-- All rights reserved.
-- Copyright (C) 2007-2014, Gabriel Dos Reis.
-- Copyright (C) 2007-2016, Gabriel Dos Reis.
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
@@ -518,9 +518,21 @@ bpModule ps ==
bpPush(ps,%Module(bpPop3 ps,bpPop2 ps,bpPop1 ps))
nil
++ Provenance:
++ IN Application
bpProvenance ps ==
bpEqKey(ps,"IN") =>
bpApplication ps or return bpTrap ps
x := bpPop1 ps
x isnt [["ELT","System","LoadUnit"],['QUOTE,lib]] =>
bpGeneralErrorHere ps
bpPush(ps,%LoadUnit lib)
bpPush(ps,nil)
++ Parse a module import, or a import declaration for a foreign entity.
++ Import:
++ IMPORT Signature FOR Name
++ IMPORT Signature IN Application FOR Name
++ IMPORT Name
++ IMPORT NAMESPACE LongName
bpImport ps ==
@@ -533,10 +545,11 @@ bpImport ps ==
bpRequire(ps,function bpName)
bpEqPeek(ps,"COLON") =>
bpRestore(ps,a)
bpRequire(ps,function bpSignature) and
(bpEqKey(ps,"FOR") or bpTrap ps) and
bpRequire(ps,function bpName) and
bpPush(ps,%ImportSignature(bpPop1 ps, bpPop1 ps))
bpRequire(ps,function bpSignature)
bpProvenance ps
bpEqKey(ps,"FOR") or bpTrap ps
bpRequire(ps,function bpName)
bpPush(ps,%ImportSignature(bpPop1 ps, bpPop2 ps, bpPop1 ps))
bpPush(ps,%Import bpPop1 ps)
false
View
@@ -45,6 +45,9 @@ module translator (evalBootFile, loadNativeModule, loadSystemRuntimeCore,
++ If non nil, holds the name of the current module being translated.
$currentModuleName := nil
++ List of foreign load units mentioned in foreign imports.
$foreignLoadUnits := []
++ Stack of foreign definitions to cope with CLisp's odd FFI interface.
$foreignsDefsForCLisp := []
@@ -53,6 +56,10 @@ reallyPrettyPrint(x,st == _*STANDARD_-OUTPUT_*) ==
writeNewline st
genModuleFinalization(stream) ==
loadUnits := [symbolName x for x in $foreignLoadUnits]
if loadUnits ~= [] then
loadUnitsForm := ["MAP",quote "loadNativeModule",quote loadUnits]
reallyPrettyPrint(atLoadOrExecutionTime loadUnitsForm,stream)
$ffs = nil => nil
$currentModuleName = nil => coreError '"current module has no name"
setFFS := ["SETQ","$dynamicForeignFunctions",
@@ -448,8 +455,8 @@ translateToplevel(ps,b,export?) ==
bootImport symbolName m
[["IMPORT-MODULE", symbolName m]]
%ImportSignature(x, sig) =>
genImportDeclaration(x, sig)
%ImportSignature(x, sig, dom) =>
genImportDeclaration(x, sig, dom)
%TypeAlias(lhs, rhs) => [genTypeAlias(lhs,rhs)]
@@ -602,6 +609,7 @@ associateRequestWithFileType(Option '"compile", '"boot",
++ Load native dynamically linked module
loadNativeModule m ==
m := strconc($NativeModulePrefix,m,$NativeModuleExt)
%hasFeature KEYWORD::SBCL =>
apply(bfColonColon("SB-ALIEN","LOAD-SHARED-OBJECT"),
[m,KEYWORD::DONT_-SAVE,true])
@@ -615,4 +623,4 @@ loadNativeModule m ==
loadSystemRuntimeCore() ==
%hasFeature KEYWORD::ECL or %hasFeature KEYWORD::GCL => nil
loadNativeModule strconc('"libopen-axiom-core",$NativeModuleExt)
loadNativeModule '"open-axiom-core"
View
@@ -1,4 +1,4 @@
# Copyright (C) 2007-2014, Gabriel Dos Reis.
# Copyright (C) 2007-2016, Gabriel Dos Reis.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -60,7 +60,7 @@ libspad_objects = $(libspad_SOURCES:.c=.lo)
oa_installed_corelib = $(oa_target_libdir)/libopen-axiom-core.$(LIBEXT)
ifeq (@oa_use_dynamic_lib@,yes)
oa_installed_corelib += $(oa_target_libdir)/libopen-axiom-core$(SHREXT)
oa_installed_corelib += $(oa_target_libdir)/$(oa_shrlib_prefix)open-axiom-core$(SHREXT)
endif
subdir = src/lib/
@@ -83,7 +83,7 @@ $(oa_target_libdir)/libopen-axiom-core.$(LIBEXT): \
# Don't put the shared lib here -- place it directly in its final home;
# we don't want to pick it accidently.
$(oa_target_libdir)/libopen-axiom-core$(SHREXT): \
$(oa_target_libdir)/$(oa_shrlib_prefix)open-axiom-core$(SHREXT): \
$(libopen_axiom_core_objects)
$(mkdir_p) $(oa_target_libdir)
$(CXXLINK_SHRLIB) $(oa_shrlib_flags) -o $@ \
@@ -109,7 +109,7 @@ mostlyclean-local:
@rm -f *.$(OBJEXT) *.lo
clean-local: mostlyclean-local
@rm -f $(oa_target_libdir)/libopen-axiom-core$(SHREXT)
@rm -f $(oa_target_libdir)/$(oa_shrlib_prefix)open-axiom-core$(SHREXT)
@rm -f libopen-axiom-core.$(LIBEXT)
@rm -f libspad.$(LIBEXT)
@rm -fr .libs _libs
View
@@ -1,4 +1,4 @@
# Copyright (C) 2007-2014, Gabriel Dos Reis.
# Copyright (C) 2007-2016, Gabriel Dos Reis.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -156,6 +156,7 @@ edit = sed \
-e 's|@host[@]|$(host)|g' \
-e 's|@build[@]|$(build)|g' \
-e 's|@target[@]|$(target)|g' \
-e 's|@oa_shrlib_prefix[@]|$(oa_shrlib_prefix)|g' \
-e 's|@SHREXT[@]|$(SHREXT)|g' \
-e 's|@LIBEXT[@]|$(LIBEXT)|g' \
-e 's|@oa_c_runtime_extra[@]|$(patsubst %,"%",$(oa_c_runtime_extra))|g' \
View
@@ -3,7 +3,7 @@
;; Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd.
;; All rights reserved.
;;
;; Copyright (C) 2007-2015, Gabriel Dos Reis.
;; Copyright (C) 2007-2016, Gabriel Dos Reis.
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
@@ -186,6 +186,7 @@
"$delayedFFI"
"$useLLVM"
"$effectiveFaslType"
"$NativeModulePrefix"
"$NativeModuleExt"
"$systemInstallationDirectory"
"$NativeTypeTable"
@@ -469,6 +470,10 @@
#+:ecl (pathname-type (compile-file-pathname "foo.lisp" :system-p t))
#-:ecl |$faslType|)
;; Prefix of pathname for file containers of native load units.
(defconstant |$NativeModulePrefix|
"@oa_shrlib_prefix@")
;; Extension of file containers for native shared libraries.
(defconstant |$NativeModuleExt|
(cond (|$useDynamicLink| "@SHREXT@")
View
@@ -358,6 +358,7 @@ oa_lisp_flavor = @oa_lisp_flavor@
oa_optimize_options = @oa_optimize_options@
oa_quiet_flags = @oa_quiet_flags@
oa_shrlib_flags = @oa_shrlib_flags@
oa_shrlib_prefix = @oa_shrlib_prefix@
oa_shrobj_flags = @oa_shrobj_flags@
oa_src_algdir = @oa_src_algdir@
oa_src_datadir = @oa_src_datadir@
View
@@ -373,6 +373,7 @@ oa_lisp_flavor = @oa_lisp_flavor@
oa_optimize_options = @oa_optimize_options@
oa_quiet_flags = @oa_quiet_flags@
oa_shrlib_flags = @oa_shrlib_flags@
oa_shrlib_prefix = @oa_shrlib_prefix@
oa_shrobj_flags = @oa_shrobj_flags@
oa_src_algdir = @oa_src_algdir@
oa_src_datadir = @oa_src_datadir@

0 comments on commit 2bd3cc8

Please sign in to comment.