2001-11-01 Malcy * asmrun/shared.c: new. * asmrun/shinit.c: new. * asmrun/shared.h: new. * otherlibs/natdynlink/*: new. * utils/config.mlp (version): set to 3.03 ALPHA(Shared). (cmx_magic_number): changed. (cmxa_magic_number): changed. library_infos was changed, therefore no longer can be input_valued by old compilers. * utils/clflags.ml (link_shared): set to true if -shared was passed to native code compiler. (link_dynamic): likewise for -dynamic. (nostdlib): likewise for -nostdlib. (noasmrun): likewise for -noasmrun. * driver/optmain.ml (main): handle new command line options: -shared, -dynamic, -noasmrun, -nostdlib. * configure (otherlibraries): added natdynlink. * config/Makefile-templ (OTHERLIBRARIES): added natdynlink. * camlp4/odyl/odyl.ml: now depends on pa_ifdef, needed to use Dynlink for byte and Natdynlink for nativecode respectively. (apply_load): added ifdef OPT to check for .cms files instead of .cmo .cma when camlp4XXX was built with native compiler. * camlp4/odyl/odyl_main.ml (first_arg_no_load): likewise. (loadfile): likewise. * etc/Makefile: modified to build native modules (.cms files). * meta/Makefile: likewise. * odyl/Makefile: new target to build odyl.cmx, plus changes to odyl_main.cmx target (since it now depend on pa_ifdef). * config/Makefile.tpl (.SUFFIXES): added .cms in front. (.cmx.cms): new dependency. * camlp4/Makefile (optp4): add line to build optp4 in camlp4 subdirectory. * camlp4/camlp4/Makefile (CAMLP4OPT): define it as camlp4.opt not phony. ($(CAMLP4OPT)): created necessary commands to build it. * byterun/mlvalues.h (Is_atom): make it point to shared_Is_atom if built as shared runtime. * byterun/intext.h (CODE_SHARED_CODEPOINTER): new definition. (code_checksum): modified defintion if built as shared runtime. * byterun/intern.c (intern_rec): behave differently when deserlializing closures if built as shared runtime. (code_checksum): modified to accept code_area_[start|end] if built as shared runtime. * byterun/extern.c (extern_rec): behave differently when serlializing closures if built as shared runtime. * asmrun/startup.c: do not declare static_data_[start|end], code_area_[start|end], struct segment and minmax_table if built as shared runtime (needed support for this is in shared.c). (init_atoms): if built as shared runtime, only initialize atom_table, do nothing with caml_[code|data]_segments. (caml_main): if built as shared runtime, call needed initialization functions from shared.c and shinit.c. * asmrun/stack.h (caml_globals): do not declarre caml_globals, caml_frametables as extern if built as shared runtime. * asmrun/roots.c (init_frame_descriptors): added call to shared_get_frametable, plus condition since now we can call init_frame_descriptors as many time as new module register itself. (oldify_local_roots): added call to shared_get_globals and code to reintialize frame descriptors if new module was added. (do_roots): likewise. * asmrun/i386.S: .type decorations here and there, plus make symbol caml_start_shared which will point at caml_start_program, this is needed due to ELF visibility constraints. * asmrun/Makefile: added libasmrunm.a(shared runtime) target + necessary support. * asmcomp/printcmm.ml (data_item): added or pattern to handle Cend_symbol. * asmcomp/i386/emit.mlp (emit_float_constant): .type directive. (fundecl): likewise + .size directive at the end. (emit_item): likewise. (begin_assembly): likewise. (end_assembly): likewise, plus if linking shared added call to emit_shared_entry. (emit_shared_entry): new function, takes care of defining proper shared library initialization code. * asmcomp/compilenv.ml (library_infos): added lib_shared flag. (unit_type): new type. describes either module or shared library. * asmcomp/cmmgen.mli (shared_init): definition. (entry_point): changed to reflect signature changes. * asmcomp/cmmgen.ml (emit_constant): insertion of Cend_symbol. (compunit): created per module variable Modname_inited, modified module entry point to behave like this(pseudo): if Module_inited = 0 then begin increment Module_inited; Module_entry (); 1 end else 0;. (entry_point): changed behavior. old way(pseudo): map (fun module -> module_entry (); increment caml_globals_inited) all_modules_referenced new way(pseudo): map (function Module module -> caml_globals_inited += module.entry () | Shared library -> library.entry ()) all_modules_shared_libraries_referenced. (shared_init): create function caml_init_shared(pseudo): map (function Module module -> () | Shared library -> library.init ()) all_modules_shared_libraries_referenced. * asmcomp/cmm.ml (data_item): new tag Cend_symbol, needed to emit proper .size directives. * asmcomp/cmm.mli (data_item): likewise. * asmcomp/asmlink.ml (linking_against_shared): boolean, set to true if linking against shared. (scan_file): modified to work with full [info, crc] pairs not just info, plus some special processing for shared libraries. (make_startup_file): special processing for shared libraries, plus one additional compile_phrase [Cmmgen.shared_init]. (call_linker): special processing for shared libraries [libasmrunm.a, shinit.o]. (link): special processing for shared libraries, different handling of missing implementations, call to Asmlibrarian.create_archive_shared etc. * asmcomp/asmlibrarian.mli (create_archive_shared): definition. * asmcomp/asmlibrarian.ml (create_archive): set shared flag to false. (create_archive_shared): creates lib_name.cmxa with shared flag set, makes GNU linker script named lib_name.a which points to lib_name. * Makefile (ASMCOMP): swap asmlibrarian.cmo asmlink.cmo since later now depends on former. (runtimeopt): create links for libasmrunm.a and shinit.o in stdlib.