Version française
Home     About     Download     Resources     Contact us    
Browse thread
Native thread in O'Caml 1.06
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: Native thread in O'Caml 1.06
> I've a problem using threads with ocamlopt v 1.06.
> ocamlopt doesn't know -thread option.
> There is no native lib in $(LIBDIR)/threads

Your're right, the installation of otherlibs/systhreads is broken in
release 1.06.  The patch below (against the 1.06 distribution) fixes
the problem.  Just apply it, do "make clean" in otherlibs/systhreads,
and "make all opt install" in the toplevel directory.

Note also that you'll need to add "-cclib -lunix" on the command-line
when linking with that version of the threads library.

Sorry for the inconvenience,

- Xavier Leroy

Index: ocaml/driver/optcompile.ml
diff -c ocaml/driver/optcompile.ml:1.22 ocaml/driver/optcompile.ml:1.23
*** ocaml/driver/optcompile.ml:1.22	Fri Aug 22 10:55:38 1997
--- ocaml/driver/optcompile.ml	Tue Nov 18 18:14:53 1997
***************
*** 9,15 ****
  (*                                                                     *)
  (***********************************************************************)
  
! (* $Id: optcompile.ml,v 1.22 1997/08/22 08:55:38 xleroy Exp $ *)
  
  (* The batch compiler *)
  
--- 9,15 ----
  (*                                                                     *)
  (***********************************************************************)
  
! (* $Id: optcompile.ml,v 1.23 1997/11/18 17:14:53 xleroy Exp $ *)
  
  (* The batch compiler *)
  
***************
*** 24,31 ****
     then the standard library directory. *)
  
  let init_path () =
!   load_path :=
!     "" :: List.rev (Config.standard_library :: !Clflags.include_dirs);
    Env.reset_cache()
  
  (* Return the initial environment in which compilation proceeds. *)
--- 24,35 ----
     then the standard library directory. *)
  
  let init_path () =
!   let dirs =
!     if !Clflags.thread_safe then
!      Filename.concat Config.standard_library "threads" :: !Clflags.include_dirs
!     else
!      !Clflags.include_dirs in
!   load_path := "" :: List.rev (Config.standard_library :: dirs);
    Env.reset_cache()
  
  (* Return the initial environment in which compilation proceeds. *)
Index: ocaml/driver/optmain.ml
diff -c ocaml/driver/optmain.ml:1.29 ocaml/driver/optmain.ml:1.30
*** ocaml/driver/optmain.ml:1.29	Thu May 15 15:26:34 1997
--- ocaml/driver/optmain.ml	Tue Nov 18 18:14:54 1997
***************
*** 9,15 ****
  (*                                                                     *)
  (***********************************************************************)
  
! (* $Id: optmain.ml,v 1.29 1997/05/15 13:26:34 xleroy Exp $ *)
  
  open Config
  open Clflags
--- 9,15 ----
  (*                                                                     *)
  (***********************************************************************)
  
! (* $Id: optmain.ml,v 1.30 1997/11/18 17:14:54 xleroy Exp $ *)
  
  open Config
  open Clflags
***************
*** 84,89 ****
--- 84,90 ----
         "-pp", Arg.String(fun s -> preprocessor := Some s),
               "<command>  Pipe sources through preprocessor <command>";
         "-S", Arg.Set keep_asm_file, " Keep intermediate assembly file";
+        "-thread", Arg.Set thread_safe, " Use thread-safe standard library";
         "-unsafe", Arg.Set fast,
               " No bounds checking on array and string access";
         "-v", Arg.Unit print_version_number, " Print compiler version number";
Index: ocaml/otherlibs/systhreads/Makefile
diff -c ocaml/otherlibs/systhreads/Makefile:1.5 ocaml/otherlibs/systhreads/Makefile:1.7
*** ocaml/otherlibs/systhreads/Makefile:1.5	Mon Nov 17 14:04:15 1997
--- ocaml/otherlibs/systhreads/Makefile	Wed Nov 19 11:00:26 1997
***************
*** 6,12 ****
  BYTECODE_C_OBJS=posix_b.o
  NATIVECODE_C_OBJS=posix_n.o
  
! THREAD_OBJS=thread.cmo condition.cmo event.cmo threadUnix.cmo
  
  GENFILES=thread.ml
  
--- 6,12 ----
  BYTECODE_C_OBJS=posix_b.o
  NATIVECODE_C_OBJS=posix_n.o
  
! THREAD_OBJS=thread.cmo mutex.cmo condition.cmo event.cmo threadUnix.cmo
  
  GENFILES=thread.ml
  
***************
*** 49,57 ****
  install:
  	cp libthreads.a $(LIBDIR)/libthreads.a
  	if test -d $(LIBDIR)/threads; then :; else mkdir $(LIBDIR)/threads; fi
! 	cp thread.cmi mutex.cmi condition.cmi event.cmi threadUnix.cmi threads.cma stdlib.cma $(LIBDIR)/threads
  
  installopt:
  
  .SUFFIXES: .ml .mli .cmo .cmi .cmx
  
--- 49,60 ----
  install:
  	cp libthreads.a $(LIBDIR)/libthreads.a
  	if test -d $(LIBDIR)/threads; then :; else mkdir $(LIBDIR)/threads; fi
! 	cp $(THREAD_OBJS:.cmo=.cmi) threads.cma $(LIBDIR)/threads
! 	rm -f $(LIBDIR)/threads/stdlib.cma
  
  installopt:
+ 	cp libthreadsnat.a $(LIBDIR)/libthreadsnat.a
+ 	cp $(THREAD_OBJS:.cmo=.cmx) threads.cmxa threads.a $(LIBDIR)/threads
  
  .SUFFIXES: .ml .mli .cmo .cmi .cmx
  
Index: ocaml/otherlibs/systhreads/Makefile.nt
diff -c ocaml/otherlibs/systhreads/Makefile.nt:1.14 ocaml/otherlibs/systhreads/Makefile.nt:1.16
*** ocaml/otherlibs/systhreads/Makefile.nt:1.14	Mon Nov 17 14:04:15 1997
--- ocaml/otherlibs/systhreads/Makefile.nt	Wed Nov 19 11:00:47 1997
***************
*** 7,13 ****
  BYTECODE_C_OBJS=win32_b.obj
  NATIVECODE_C_OBJS=win32_n.obj
  
! THREAD_OBJS=thread.cmo condition.cmo event.cmo threadUnix.cmo
  
  GENFILES=thread.ml
  
--- 7,13 ----
  BYTECODE_C_OBJS=win32_b.obj
  NATIVECODE_C_OBJS=win32_n.obj
  
! THREAD_OBJS=thread.cmo mutex.cmo condition.cmo event.cmo threadUnix.cmo
  
  GENFILES=thread.ml
  
***************
*** 50,58 ****
  install:
  	cp libthreads.lib $(LIBDIR)/libthreads.lib
  	if not exist $(LIBDIR)\threads mkdir $(LIBDIR)\threads
! 	cp thread.cmi mutex.cmi condition.cmi event.cmi threadUnix.cmi threads.cma $(LIBDIR)/threads
  
  installopt:
  
  .SUFFIXES: .ml .mli .cmo .cmi .cmx
  
--- 50,61 ----
  install:
  	cp libthreads.lib $(LIBDIR)/libthreads.lib
  	if not exist $(LIBDIR)\threads mkdir $(LIBDIR)\threads
! 	cp $(THREAD_OBJS:.cmo=.cmi) threads.cma $(LIBDIR)/threads
! 	rm -f $(LIBDIR)/threads/stdlib.cma
  
  installopt:
+ 	cp libthreadsnat.a $(LIBDIR)/libthreadsnat.a
+ 	cp $(THREAD_OBJS:.cmo=.cmx) threads.cmxa threads.a $(LIBDIR)/threads
  
  .SUFFIXES: .ml .mli .cmo .cmi .cmx