Permalink
Browse files

Chargement dynamique de primitives C

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3677 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information...
1 parent f9b64c9 commit 9eaedc5493c04930ad34f3cd761eb31babf9b7ca xleroy committed Aug 28, 2001
Showing with 3,411 additions and 1,630 deletions.
  1. +58 −56 .depend
  2. +8 −1 Changes
  3. +6 −2 Makefile
  4. +5 −3 Makefile.nt
  5. +11 −5 README.win32
  6. +7 −1 asmcomp/asmlink.ml
  7. +9 −3 asmrun/.depend
  8. BIN boot/ocamlc
  9. BIN boot/ocamllex
  10. +1 −0 bytecomp/bytelibrarian.ml
  11. +44 −26 bytecomp/bytelink.ml
  12. +2 −0 bytecomp/bytelink.mli
  13. +8 −0 bytecomp/bytesections.ml
  14. +3 −0 bytecomp/bytesections.mli
  15. +149 −0 bytecomp/dll.ml
  16. +56 −0 bytecomp/dll.mli
  17. +0 −1 bytecomp/meta.ml
  18. +0 −1 bytecomp/meta.mli
  19. +29 −39 bytecomp/symtable.ml
  20. +26 −14 byterun/.depend
  21. +439 −140 byterun/.depend.nt
  22. +7 −5 byterun/Makefile
  23. +26 −14 byterun/Makefile.nt
  24. +12 −11 byterun/alloc.c
  25. +17 −16 byterun/alloc.h
  26. +13 −13 byterun/array.c
  27. +4 −4 byterun/backtrace.c
  28. +4 −4 byterun/backtrace.h
  29. +12 −11 byterun/callback.c
  30. +15 −13 byterun/callback.h
  31. +2 −2 byterun/compact.h
  32. +7 −7 byterun/compare.c
  33. +8 −8 byterun/custom.c
  34. +11 −11 byterun/custom.h
  35. +212 −0 byterun/dynlink.c
  36. +33 −0 byterun/dynlink.h
  37. +16 −15 byterun/extern.c
  38. +13 −13 byterun/fail.c
  39. +17 −17 byterun/fail.h
  40. +1 −1 byterun/finalise.c
  41. +42 −42 byterun/floats.c
  42. +8 −8 byterun/gc_ctrl.c
  43. +2 −2 byterun/hash.c
  44. +3 −3 byterun/instrtrace.c
  45. +20 −20 byterun/intern.c
  46. +6 −6 byterun/interp.c
  47. +33 −29 byterun/intext.h
  48. +71 −71 byterun/ints.c
  49. +41 −41 byterun/io.c
  50. +16 −16 byterun/io.h
  51. +2 −1 byterun/lexing.c
  52. +3 −3 byterun/major_gc.h
  53. +2 −2 byterun/md5.c
  54. +2 −2 byterun/md5.h
  55. +10 −10 byterun/memory.h
  56. +5 −10 byterun/meta.c
  57. +4 −4 byterun/minor_gc.h
  58. +43 −0 byterun/misc.c
  59. +32 −2 byterun/misc.h
  60. +7 −7 byterun/mlvalues.h
  61. +8 −8 byterun/obj.c
  62. +53 −0 byterun/osdeps.h
  63. +2 −1 byterun/parsing.c
  64. +6 −2 byterun/prims.h
  65. +1 −1 byterun/printexc.c
  66. +1 −1 byterun/printexc.h
  67. +1 −1 byterun/roots.c
  68. +6 −6 byterun/roots.h
  69. +4 −4 byterun/signals.c
  70. +9 −9 byterun/signals.h
  71. +7 −7 byterun/stacks.c
  72. +6 −6 byterun/stacks.h
  73. +43 −29 byterun/startup.c
  74. +3 −3 byterun/startup.h
  75. +11 −11 byterun/str.c
  76. +19 −105 byterun/sys.c
  77. +2 −3 byterun/sys.h
  78. +8 −8 byterun/terminfo.c
  79. +198 −0 byterun/unix.c
  80. +5 −5 byterun/weak.c
  81. +106 −15 byterun/win32.c
  82. +26 −3 config/Makefile-templ
  83. +7 −3 config/Makefile.nt
  84. +7 −0 config/auto-aux/solaris-ld
  85. +5 −0 config/s-templ.h
  86. +85 −12 configure
  87. +1 −1 debugger/.depend
  88. +2 −1 debugger/Makefile
  89. +3 −1 driver/main.ml
  90. +2 −0 driver/main_args.ml
  91. +1 −0 driver/main_args.mli
  92. +2 −0 driver/optmain.ml
  93. +8 −9 otherlibs/bigarray/Makefile
  94. +23 −10 otherlibs/bigarray/Makefile.nt
  95. +23 −23 otherlibs/bigarray/bigarray_stubs.c
  96. +2 −2 otherlibs/bigarray/mmap_unix.c
  97. +24 −12 otherlibs/bigarray/mmap_win32.c
  98. +7 −6 otherlibs/dbm/Makefile
  99. +8 −6 otherlibs/dynlink/.depend
  100. +1 −1 otherlibs/dynlink/Makefile
  101. +1 −1 otherlibs/dynlink/Makefile.nt
  102. +10 −2 otherlibs/dynlink/dynlink.ml
  103. +1 −0 otherlibs/dynlink/dynlink.mli
  104. +7 −10 otherlibs/graph/Makefile
  105. +2 −2 otherlibs/labltk/browser/Makefile.nt
  106. +8 −5 otherlibs/labltk/lib/Makefile
  107. +3 −3 otherlibs/labltk/lib/Makefile.nt
  108. +5 −5 otherlibs/labltk/support/Makefile
  109. +1 −0 otherlibs/labltk/support/Makefile.common
  110. +21 −9 otherlibs/labltk/support/Makefile.nt
  111. +2 −2 otherlibs/labltk/support/cltkCaml.c
  112. +2 −2 otherlibs/labltk/support/cltkEval.c
  113. +2 −2 otherlibs/labltk/support/cltkEvent.c
  114. +8 −8 otherlibs/labltk/support/cltkFile.c
  115. +1 −1 otherlibs/labltk/support/cltkMain.c
  116. +1 −1 otherlibs/labltk/support/cltkMisc.c
  117. +2 −2 otherlibs/labltk/support/cltkTimer.c
  118. +4 −4 otherlibs/labltk/support/cltkVar.c
  119. +2 −2 otherlibs/labltk/support/cltkWait.c
  120. +34 −5 otherlibs/num/.depend.nt
  121. +12 −10 otherlibs/num/Makefile
  122. +24 −9 otherlibs/num/Makefile.nt
  123. +4 −1 otherlibs/num/bignum/Makefile
  124. +71 −32 otherlibs/num/bignum/Makefile.nt
  125. +29 −29 otherlibs/num/nat_stubs.c
  126. +4 −2 otherlibs/num/test/Makefile
  127. +7 −7 otherlibs/num/test/Makefile.nt
  128. +7 −7 otherlibs/str/Makefile
  129. +31 −14 otherlibs/str/Makefile.nt
  130. +8 −8 otherlibs/str/strstubs.c
  131. +14 −9 otherlibs/systhreads/Makefile
  132. +20 −15 otherlibs/systhreads/Makefile.nt
  133. +2 −2 otherlibs/systhreads/Tests/Makefile.nt
  134. +39 −27 otherlibs/systhreads/win32.c
  135. +6 −6 otherlibs/threads/Makefile
  136. +2 −2 otherlibs/unix/.depend
  137. +7 −7 otherlibs/unix/Makefile
  138. +2 −2 otherlibs/unix/accept.c
  139. +1 −1 otherlibs/unix/access.c
  140. +2 −2 otherlibs/unix/addrofstr.c
  141. +1 −1 otherlibs/unix/alarm.c
  142. +2 −2 otherlibs/unix/bind.c
  143. +1 −1 otherlibs/unix/chdir.c
  144. +1 −1 otherlibs/unix/chmod.c
  145. +1 −1 otherlibs/unix/chown.c
  146. +1 −1 otherlibs/unix/chroot.c
  147. +1 −1 otherlibs/unix/close.c
  148. +1 −1 otherlibs/unix/closedir.c
  149. +2 −2 otherlibs/unix/connect.c
  150. +1 −1 otherlibs/unix/dup.c
  151. +2 −2 otherlibs/unix/dup2.c
  152. +3 −1 otherlibs/unix/envir.c
  153. +2 −2 otherlibs/unix/errmsg.c
  154. +1 −1 otherlibs/unix/execv.c
  155. +1 −1 otherlibs/unix/execve.c
  156. +4 −2 otherlibs/unix/execvp.c
  157. +1 −1 otherlibs/unix/exit.c
  158. +2 −2 otherlibs/unix/fchmod.c
  159. +2 −2 otherlibs/unix/fchown.c
  160. +6 −6 otherlibs/unix/fcntl.c
  161. +1 −1 otherlibs/unix/fork.c
  162. +2 −2 otherlibs/unix/ftruncate.c
  163. +3 −3 otherlibs/unix/getcwd.c
  164. +1 −1 otherlibs/unix/getegid.c
  165. +1 −1 otherlibs/unix/geteuid.c
  166. +1 −1 otherlibs/unix/getgid.c
  167. +2 −2 otherlibs/unix/getgr.c
  168. +2 −2 otherlibs/unix/getgroups.c
  169. +4 −4 otherlibs/unix/gethost.c
  170. +3 −3 otherlibs/unix/gethostname.c
  171. +1 −1 otherlibs/unix/getlogin.c
  172. +2 −2 otherlibs/unix/getpeername.c
  173. +1 −1 otherlibs/unix/getpid.c
  174. +1 −1 otherlibs/unix/getppid.c
  175. +4 −4 otherlibs/unix/getproto.c
  176. +2 −2 otherlibs/unix/getpw.c
  177. +4 −4 otherlibs/unix/getserv.c
  178. +2 −2 otherlibs/unix/getsockname.c
  179. +2 −2 otherlibs/unix/gettimeofday.c
  180. +1 −1 otherlibs/unix/getuid.c
  181. +4 −4 otherlibs/unix/gmtime.c
  182. +4 −4 otherlibs/unix/itimer.c
  183. +1 −1 otherlibs/unix/kill.c
  184. +1 −1 otherlibs/unix/link.c
  185. +2 −2 otherlibs/unix/listen.c
  186. +3 −3 otherlibs/unix/lockf.c
  187. +1 −1 otherlibs/unix/lseek.c
  188. +1 −1 otherlibs/unix/mkdir.c
  189. +3 −3 otherlibs/unix/mkfifo.c
  190. +2 −2 otherlibs/unix/nice.c
  191. +1 −1 otherlibs/unix/open.c
  192. +1 −1 otherlibs/unix/opendir.c
  193. +1 −1 otherlibs/unix/pipe.c
  194. +2 −2 otherlibs/unix/putenv.c
  195. +1 −1 otherlibs/unix/read.c
  196. +1 −1 otherlibs/unix/readdir.c
  197. +2 −2 otherlibs/unix/readlink.c
  198. +1 −1 otherlibs/unix/rename.c
  199. +2 −2 otherlibs/unix/rewinddir.c
  200. +1 −1 otherlibs/unix/rmdir.c
  201. +2 −2 otherlibs/unix/select.c
  202. +10 −10 otherlibs/unix/sendrecv.c
  203. +1 −1 otherlibs/unix/setgid.c
  204. +1 −1 otherlibs/unix/setsid.c
  205. +1 −1 otherlibs/unix/setuid.c
  206. +2 −2 otherlibs/unix/shutdown.c
  207. +6 −6 otherlibs/unix/signals.c
  208. +1 −1 otherlibs/unix/sleep.c
  209. +2 −2 otherlibs/unix/socket.c
  210. +2 −2 otherlibs/unix/socketaddr.h
  211. +2 −2 otherlibs/unix/socketpair.c
  212. +22 −22 otherlibs/unix/sockopt.c
  213. +3 −3 otherlibs/unix/stat.c
  214. +2 −2 otherlibs/unix/strofaddr.c
  215. +2 −2 otherlibs/unix/symlink.c
  216. +12 −12 otherlibs/unix/termios.c
  217. +1 −1 otherlibs/unix/time.c
  218. +1 −1 otherlibs/unix/times.c
  219. +2 −2 otherlibs/unix/truncate.c
  220. +1 −1 otherlibs/unix/umask.c
  221. +1 −1 otherlibs/unix/unlink.c
  222. +3 −3 otherlibs/unix/utimes.c
  223. +3 −3 otherlibs/unix/wait.c
  224. +1 −1 otherlibs/unix/write.c
  225. +36 −6 otherlibs/win32unix/.depend
  226. +24 −12 otherlibs/win32unix/Makefile.nt
  227. +1 −1 otherlibs/win32unix/accept.c
  228. +1 −1 otherlibs/win32unix/bind.c
  229. +2 −2 otherlibs/win32unix/channels.c
  230. +2 −2 otherlibs/win32unix/close.c
  231. +3 −3 otherlibs/win32unix/close_on.c
  232. +1 −1 otherlibs/win32unix/connect.c
  233. +4 −7 otherlibs/win32unix/createprocess.c
  234. +2 −2 otherlibs/win32unix/dup.c
  235. +2 −2 otherlibs/win32unix/dup2.c
  236. +41 −0 otherlibs/win32unix/errmsg.c
  237. +1 −1 otherlibs/win32unix/getpeername.c
  238. +1 −1 otherlibs/win32unix/getpid.c
  239. +1 −1 otherlibs/win32unix/getsockname.c
  240. +1 −1 otherlibs/win32unix/gettimeofday.c
  241. +2 −2 otherlibs/win32unix/link.c
  242. +1 −1 otherlibs/win32unix/listen.c
  243. +2 −2 otherlibs/win32unix/lseek.c
  244. +1 −1 otherlibs/win32unix/mkdir.c
  245. +2 −2 otherlibs/win32unix/open.c
  246. +2 −2 otherlibs/win32unix/pipe.c
  247. +2 −2 otherlibs/win32unix/read.c
  248. +1 −1 otherlibs/win32unix/select.c
  249. +4 −4 otherlibs/win32unix/sendrecv.c
  250. +1 −1 otherlibs/win32unix/shutdown.c
  251. +1 −1 otherlibs/win32unix/sleep.c
  252. +1 −1 otherlibs/win32unix/socket.c
  253. +8 −8 otherlibs/win32unix/sockopt.c
  254. +3 −3 otherlibs/win32unix/startup.c
  255. +1 −1 otherlibs/win32unix/system.c
  256. +112 −39 otherlibs/win32unix/unixsupport.c
  257. +1 −0 otherlibs/win32unix/unixsupport.h
  258. +3 −3 otherlibs/win32unix/windir.c
  259. +3 −3 otherlibs/win32unix/winwait.c
  260. +2 −2 otherlibs/win32unix/write.c
  261. +17 −1 tools/Makefile
  262. +1 −0 tools/ocamlcp.ml
  263. +108 −0 tools/ocamlmklib.tpl
  264. +11 −4 toplevel/topdirs.ml
  265. +1 −1 toplevel/toploop.ml
  266. +2 −1 utils/clflags.ml
  267. +8 −0 utils/config.mli
  268. +4 −1 utils/config.mlp
View
114 .depend

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -8,15 +8,17 @@ Type-checker:
module A: sig module type T = sig module T: M end end
module B: A.T
- Improved efficiency of module type-checking via lazy computation of
- certain summary information.
+ certain signature summary information.
Byte-code compiler:
- Protect against VM stack overflow caused by module initialization code
with many local variables.
+- Support for dynamic loading of the C part of mixed Caml/C libraries.
Native-code compiler:
- Attempt to recover gracefully from system stack overflow. Currently
works on x86 under Linux and BSD.
+- Alpha: work around "as" bug in Tru64 5.1.
Toplevel environment:
- Revised printing of inferred types and evaluation results
@@ -26,10 +28,15 @@ Tools:
- ocamldep: added -pp option to handle preprocessed source files.
Run-time system:
+- Support for dynamic loading of the C part of mixed Caml/C libraries.
+ Currently works under Linux, FreeBSD, Windows, Tru64, Solaris and Irix.
+- Implemented registration of global C roots with a skip list,
+ runs much faster when there are many global C roots.
- Autoconfiguration script: fixed wrong detection of Mac OS X; problem
with the Sparc, gcc 3.0, and float alignment fixed.
Other libraries:
+- All libraries revised to allow dynamic loading of the C part.
- Graphics under X Windows: revised event handling, should no longer lose
mouse events between two calls to wait_next_event(); wait_next_event()
now interruptible by signals.
View
@@ -57,7 +57,7 @@ COMP=bytecomp/lambda.cmo bytecomp/printlambda.cmo \
bytecomp/typeopt.cmo bytecomp/switch.cmo bytecomp/matching.cmo \
bytecomp/translobj.cmo bytecomp/translcore.cmo \
bytecomp/translclass.cmo bytecomp/translmod.cmo \
- bytecomp/simplif.cmo bytecomp/runtimedef.cmo
+ bytecomp/simplif.cmo bytecomp/runtimedef.cmo bytecomp/dll.cmo
BYTECOMP=bytecomp/meta.cmo bytecomp/instruct.cmo bytecomp/bytegen.cmo \
bytecomp/printinstr.cmo bytecomp/opcodes.cmo bytecomp/emitcode.cmo \
@@ -102,7 +102,7 @@ EXPUNGEOBJS=utils/misc.cmo utils/tbl.cmo \
utils/config.cmo utils/clflags.cmo \
typing/ident.cmo typing/path.cmo typing/types.cmo typing/btype.cmo \
typing/predef.cmo bytecomp/runtimedef.cmo bytecomp/bytesections.cmo \
- bytecomp/symtable.cmo toplevel/expunge.cmo
+ bytecomp/dll.cmo bytecomp/symtable.cmo toplevel/expunge.cmo
PERVASIVES=arg array buffer callback char digest filename format gc hashtbl \
lexing list map obj parsing pervasives printexc printf queue random \
@@ -212,6 +212,7 @@ install: FORCE
if test -d $(LIBDIR); then : ; else $(MKDIR) $(LIBDIR); fi
if test -d $(MANDIR); then : ; else $(MKDIR) $(MANDIR); fi
cd byterun; $(MAKE) install
+ echo "$(LIBDIR)" > $(LIBDIR)/ld.conf
cp ocamlc $(BINDIR)/ocamlc$(EXE)
cp ocaml $(BINDIR)/ocaml$(EXE)
cd stdlib; $(MAKE) install
@@ -277,9 +278,11 @@ utils/config.ml: utils/config.mlp config/Makefile
-e 's|%%BYTERUN%%|$(BINDIR)/ocamlrun|' \
-e 's|%%BYTECC%%|$(BYTECC) $(BYTECCCOMPOPTS)|' \
-e 's|%%BYTELINK%%|$(BYTECC) $(BYTECCLINKOPTS)|' \
+ -e 's|%%BYTECCRPATH%%|$(BYTECCRPATH)|' \
-e 's|%%NATIVECC%%|$(NATIVECC) $(NATIVECCCOMPOPTS)|' \
-e 's|%%NATIVELINK%%|$(NATIVECC) $(NATIVECCLINKOPTS)|' \
-e 's|%%PARTIALLD%%|ld -r $(NATIVECCLINKOPTS)|' \
+ -e 's|%%NATIVECCRPATH%%|$(NATIVECCRPATH)|' \
-e 's|%%BYTECCLIBS%%|$(BYTECCLIBS)|' \
-e 's|%%NATIVECCLIBS%%|$(NATIVECCLIBS)|' \
-e 's|%%RANLIBCMD%%|$(RANLIBCMD)|' \
@@ -289,6 +292,7 @@ utils/config.ml: utils/config.mlp config/Makefile
-e 's|%%EXT_OBJ%%|.o|' \
-e 's|%%EXT_ASM%%|.s|' \
-e 's|%%EXT_LIB%%|.a|' \
+ -e 's|%%EXT_DLL%%|.so|' \
utils/config.mlp > utils/config.ml
@chmod -w utils/config.ml
View
@@ -59,7 +59,7 @@ COMP=bytecomp\lambda.cmo bytecomp\printlambda.cmo \
BYTECOMP=bytecomp\meta.cmo bytecomp\instruct.cmo bytecomp\bytegen.cmo \
bytecomp\printinstr.cmo bytecomp\opcodes.cmo bytecomp\emitcode.cmo \
- bytecomp\bytesections.cmo bytecomp\symtable.cmo \
+ bytecomp\bytesections.cmo bytecomp\dll.cmo bytecomp\symtable.cmo \
bytecomp\bytelibrarian.cmo bytecomp\bytelink.cmo
ASMCOMP=asmcomp\arch.cmo asmcomp\cmm.cmo asmcomp\printcmm.cmo \
@@ -99,7 +99,7 @@ EXPUNGEOBJS=utils\misc.cmo utils\tbl.cmo \
utils\config.cmo utils\clflags.cmo \
typing\ident.cmo typing\path.cmo typing\types.cmo typing\btype.cmo \
typing\predef.cmo bytecomp\runtimedef.cmo bytecomp\bytesections.cmo \
- bytecomp\symtable.cmo toplevel\expunge.cmo
+ bytecomp\dll.cmo bytecomp\symtable.cmo toplevel\expunge.cmo
PERVASIVES=arg array buffer callback char digest filename format gc hashtbl \
lexing list map obj parsing pervasives printexc printf queue random \
@@ -206,6 +206,7 @@ install: installbyt installopt
installbyt:
cd byterun & $(MAKEREC) install
+ echo $(LIBDIR)> $(LIBDIR)\ld.conf
cp ocamlc $(BINDIR)\ocamlc.exe
cp ocaml $(BINDIR)\ocaml.exe
cd stdlib & $(MAKEREC) install
@@ -267,7 +268,7 @@ partialclean::
utils\config.ml: utils\config.mlp config\Makefile.nt
@rm -f utils\config.ml
- sed -e "s|%%%%LIBDIR%%%%|$(LIBDIR:\=/)|" \
+ sed -e "s|%%%%LIBDIR%%%%|$(LIBDIR:\=\\\\\\\\)|" \
-e "s|%%%%BYTERUN%%%%|ocamlrun|" \
-e "s|%%%%BYTECC%%%%|$(BYTECC) $(BYTECCCOMPOPTS)|" \
-e "s|%%%%BYTELINK%%%%|$(BYTECC) $(BYTECCLINKOPTS)|" \
@@ -282,6 +283,7 @@ utils\config.ml: utils\config.mlp config\Makefile.nt
-e "s|%%%%EXT_OBJ%%%%|.obj|" \
-e "s|%%%%EXT_ASM%%%%|.asm|" \
-e "s|%%%%EXT_LIB%%%%|.lib|" \
+ -e "s|%%%%EXT_DLL%%%%|.dll|" \
utils\config.mlp > utils\config.ml
@attrib +r utils\config.ml
View
@@ -73,8 +73,9 @@ supported. Windows NT on non-Intel processors has not been tested.
The base bytecode system (ocamlc, ocaml, ocamllex, ocamlyacc, ...)
runs without any additional tools.
-Linking Caml bytecode with C code (ocamlc -custom) requires the
-Microsoft Visual C++ compiler version 6.
+Statically linking Caml bytecode with C code (ocamlc -custom) requires the
+Microsoft Visual C++ compiler version 6. Dynamic loading of DLLs is
+supported out of the box, without additional software.
The native-code compiler (ocamlopt) requires Visual C++ version 6
and the Microsoft assembler MASM version 6.11 or later.
@@ -127,9 +128,14 @@ The command-line tools can be recompiled from the Unix source
distribution (ocaml-X.YZ.tar.gz), which also contains the files modified
for Windows.
-In addition to Visual C++ (version 4, 5 or 6) and MASM 6, you will
-need the CygWin port of GNU tools, available from
-http://sourceware.cygnus.com/cygwin/
+You will need the following software components to perform the recompilation:
+- Windows NT or 2000 (the Makefiles do not work under Windows 95, 98, ME
+ due to differences between NT and 9x command-line interpreters);
+- Visual C++ version 6
+- MASM version 6.11 (see above)
+- The CygWin port of GNU tools, available from
+ http://sourceware.cygnus.com/cygwin/
+- TCL/TK version 8.3 (for the LablTK GUI) (see above).
To recompile, first copy manually the files config/m-nt.h and config/s-nt.h
to config/m.h and config/s.h. Edit config/Makefile.nt as needed.
View
@@ -233,7 +233,7 @@ let call_linker file_list startup_file =
(String.concat " " (List.rev file_list))
| _ ->
if not !Clflags.output_c_object then
- Printf.sprintf "%s %s -o %s -I%s %s %s %s %s %s %s %s"
+ Printf.sprintf "%s %s -o %s -I%s %s %s %s %s %s %s %s %s"
!Clflags.c_linker
(if !Clflags.gprofile then "-pg" else "")
!Clflags.exec_name
@@ -244,6 +244,12 @@ let call_linker file_list startup_file =
(String.concat " "
(List.map (fun dir -> if dir = "" then "" else "-L" ^ dir)
!load_path))
+ (String.concat " "
+ (List.map (fun dir -> if dir = "" then "" else
+ Config.native_c_rpath ^ dir)
+ (!Clflags.dllpaths @
+ Dll.ld_library_path_contents() @
+ Dll.ld_conf_contents())))
(String.concat " " (List.rev !Clflags.ccobjs))
runtime_lib
c_lib
View
@@ -122,7 +122,9 @@ minor_gc.o: minor_gc.c ../byterun/config.h ../byterun/../config/m.h \
../byterun/freelist.h ../byterun/minor_gc.h ../byterun/gc_ctrl.h \
../byterun/signals.h
misc.o: misc.c ../byterun/config.h ../byterun/../config/m.h \
- ../byterun/../config/s.h ../byterun/misc.h
+ ../byterun/../config/s.h ../byterun/misc.h ../byterun/memory.h \
+ ../byterun/gc.h ../byterun/mlvalues.h ../byterun/major_gc.h \
+ ../byterun/freelist.h ../byterun/minor_gc.h
obj.o: obj.c ../byterun/alloc.h ../byterun/misc.h ../byterun/config.h \
../byterun/../config/m.h ../byterun/../config/s.h \
../byterun/mlvalues.h ../byterun/fail.h ../byterun/gc.h \
@@ -293,7 +295,9 @@ minor_gc.d.o: minor_gc.c ../byterun/config.h ../byterun/../config/m.h \
../byterun/freelist.h ../byterun/minor_gc.h ../byterun/gc_ctrl.h \
../byterun/signals.h
misc.d.o: misc.c ../byterun/config.h ../byterun/../config/m.h \
- ../byterun/../config/s.h ../byterun/misc.h
+ ../byterun/../config/s.h ../byterun/misc.h ../byterun/memory.h \
+ ../byterun/gc.h ../byterun/mlvalues.h ../byterun/major_gc.h \
+ ../byterun/freelist.h ../byterun/minor_gc.h
obj.d.o: obj.c ../byterun/alloc.h ../byterun/misc.h ../byterun/config.h \
../byterun/../config/m.h ../byterun/../config/s.h \
../byterun/mlvalues.h ../byterun/fail.h ../byterun/gc.h \
@@ -464,7 +468,9 @@ minor_gc.p.o: minor_gc.c ../byterun/config.h ../byterun/../config/m.h \
../byterun/freelist.h ../byterun/minor_gc.h ../byterun/gc_ctrl.h \
../byterun/signals.h
misc.p.o: misc.c ../byterun/config.h ../byterun/../config/m.h \
- ../byterun/../config/s.h ../byterun/misc.h
+ ../byterun/../config/s.h ../byterun/misc.h ../byterun/memory.h \
+ ../byterun/gc.h ../byterun/mlvalues.h ../byterun/major_gc.h \
+ ../byterun/freelist.h ../byterun/minor_gc.h
obj.p.o: obj.c ../byterun/alloc.h ../byterun/misc.h ../byterun/config.h \
../byterun/../config/m.h ../byterun/../config/s.h \
../byterun/mlvalues.h ../byterun/fail.h ../byterun/gc.h \
View
Binary file not shown.
View
Binary file not shown.
@@ -38,6 +38,7 @@ let copy_compunit ic oc compunit =
(* Add C objects and options and "custom" info from a library descriptor *)
+let lib_sharedobjs = ref []
let lib_ccobjs = ref []
let lib_ccopts = ref []
View
@@ -27,6 +27,8 @@ type error =
| Inconsistent_import of string * string * string
| Custom_runtime
| File_exists of string
+ | Cannot_open_dll of string
+ | Require_custom
exception Error of error
@@ -36,16 +38,14 @@ type link_action =
| Link_archive of string * compilation_unit list
(* Name of .cma file and descriptors of the units to be linked. *)
-(* Add C objects and options and "custom" info from a library descriptor *)
-(* Ignore them if -noautolink or -use-runtime were given *)
+(* Add C objects and options from a library descriptor *)
+(* Ignore them if -noautolink was given *)
let lib_ccobjs = ref []
let lib_ccopts = ref []
let add_ccobjs l =
- if not !Clflags.no_auto_link && String.length !Clflags.use_runtime = 0
- && String.length !Clflags.use_prims = 0
- then begin
+ if not !Clflags.no_auto_link then begin
if l.lib_custom then Clflags.custom_runtime := true;
lib_ccobjs := l.lib_ccobjs @ !lib_ccobjs;
lib_ccopts := l.lib_ccopts @ !lib_ccopts
@@ -65,8 +65,8 @@ let add_ccobjs l =
and b.cma was built with ocamlc -i ... objb1 objb2
lib_ccobjs starts as [],
becomes objb2 objb1 when b.cma is scanned,
- then obja2 obja1 objb2 objb1 when b.cma is scanned.
- Clflags.ccobjs was initially obj2 obj1,
+ then obja2 obja1 objb2 objb1 when a.cma is scanned.
+ Clflags.ccobjs was initially obj2 obj1.
and is set to obj2 obj1 obja2 obja1 objb2 objb1.
Finally, the C compiler is given objb1 objb2 obja1 obja2 obj1 obj2,
which is what we need. (If b depends on a, a.cma must appear before
@@ -249,16 +249,14 @@ let output_debug_info oc =
!debug_info;
debug_info := []
-(* Transform a file name into an absolute file name *)
+(* Output a list of strings with 0-termination *)
-let make_absolute file =
- if Filename.is_relative file
- then Filename.concat (Sys.getcwd()) file
- else file
+let output_stringlist oc l =
+ List.iter (fun s -> output_string oc s; output_byte oc 0) l
(* Create a bytecode executable file *)
-let link_bytecode tolink exec_name copy_header =
+let link_bytecode tolink exec_name standalone =
if Sys.os_type = "MacOS" then begin
(* Create it as a text file for bytecode scripts *)
let c = open_out_gen [Open_wronly; Open_creat] 0o777 exec_name in
@@ -267,35 +265,45 @@ let link_bytecode tolink exec_name copy_header =
let outchan = open_out_gen [Open_wronly; Open_trunc; Open_creat; Open_binary]
0o777 exec_name in
try
- (* Copy the header *)
- if copy_header then begin
+ if standalone then begin
+ (* Copy the header *)
try
- let header =
- if String.length !Clflags.use_runtime > 0
- then "camlheader_ur" else "camlheader" in
- let inchan = open_in_bin (find_in_path !load_path header) in
+ let inchan = open_in_bin (find_in_path !load_path "camlheader") in
copy_file inchan outchan;
close_in inchan
with Not_found | Sys_error _ -> ()
end;
Bytesections.init_record outchan;
- (* The path to the bytecode interpreter (in use_runtime mode) *)
- if String.length !Clflags.use_runtime > 0 then begin
- output_string outchan (make_absolute !Clflags.use_runtime);
- output_char outchan '\n';
- Bytesections.record outchan "RNTM"
- end;
(* The bytecode *)
let start_code = pos_out outchan in
Symtable.init();
Hashtbl.clear crc_interfaces;
+ let sharedobjs = Dll.extract_dll_names !Clflags.ccobjs in
+ if standalone then begin
+ (* Initialize the DLL machinery *)
+ if List.length sharedobjs < List.length !Clflags.ccobjs
+ then raise (Error Require_custom);
+ Dll.add_path !load_path;
+ try Dll.open_dlls sharedobjs
+ with Failure reason -> raise(Error(Cannot_open_dll reason))
+ end;
let output_fun = output_string outchan
and currpos_fun () = pos_out outchan - start_code in
List.iter (link_file output_fun currpos_fun) tolink;
+ if standalone then Dll.close_all_dlls();
(* The final STOP instruction *)
output_byte outchan Opcodes.opSTOP;
output_byte outchan 0; output_byte outchan 0; output_byte outchan 0;
Bytesections.record outchan "CODE";
+ (* DLL stuff *)
+ if standalone then begin
+ (* The extra search path for DLLs *)
+ output_stringlist outchan !Clflags.dllpaths;
+ Bytesections.record outchan "DLPT";
+ (* The names of the DLLs *)
+ output_stringlist outchan sharedobjs;
+ Bytesections.record outchan "DLLS"
+ end;
(* The names of all primitives *)
Symtable.output_primitive_names outchan;
Bytesections.record outchan "PRIM";
@@ -399,7 +407,7 @@ let build_custom_runtime prim_name exec_name =
"Unix" | "Cygwin" ->
Ccomp.command
(Printf.sprintf
- "%s -o %s -I%s %s %s %s %s -lcamlrun %s"
+ "%s -o %s -I%s %s %s %s %s %s -lcamlrun %s"
!Clflags.c_linker
exec_name
Config.standard_library
@@ -408,6 +416,12 @@ let build_custom_runtime prim_name exec_name =
(String.concat " "
(List.map (fun dir -> if dir = "" then "" else "-L" ^ dir)
!load_path))
+ (String.concat " "
+ (List.map (fun dir -> if dir = "" then "" else
+ Config.bytecomp_c_rpath ^ dir)
+ (!Clflags.dllpaths @
+ Dll.ld_library_path_contents() @
+ Dll.ld_conf_contents())))
(String.concat " " (List.rev !Clflags.ccobjs))
Config.bytecomp_c_libraries)
| "Win32" ->
@@ -541,3 +555,7 @@ let report_error ppf = function
fprintf ppf "Error while building custom runtime system"
| File_exists file ->
fprintf ppf "Cannot overwrite existing file %s" file
+ | Cannot_open_dll file ->
+ fprintf ppf "Error on dynamically loaded library: %s" file
+ | Require_custom ->
+ fprintf ppf "Linking with non-Caml, non-shared object files requires the -custom flag"
View
@@ -25,6 +25,8 @@ type error =
| Inconsistent_import of string * string * string
| Custom_runtime
| File_exists of string
+ | Cannot_open_dll of string
+ | Require_custom
exception Error of error
View
@@ -78,6 +78,14 @@ let seek_section ic name =
seek_sec (in_channel_length ic - 16 - 8 * List.length !section_table)
!section_table
+(* Return the contents of a section, as a string *)
+
+let read_section ic name =
+ let len = seek_section ic name in
+ let res = String.create len in
+ really_input ic res 0 len;
+ res
+
(* Return the position of the beginning of the first section *)
let pos_first_section ic =
@@ -44,5 +44,8 @@ val seek_section: in_channel -> string -> int
and return the length of that section. Raise Not_found if no
such section exists. *)
+val read_section: in_channel -> string -> string
+ (* Return the contents of a section, as a string *)
+
val pos_first_section: in_channel -> int
(* Return the position of the beginning of the first section *)
Oops, something went wrong.

0 comments on commit 9eaedc5

Please sign in to comment.