[Caml-list] Segfault in ARM EABI for programm compiled with ocamlopt 3.12.0
For some time now I'm after a bug hitting a program of mine when compiled on ARM with ocaml 3.12.0. I initially though my own C code was misbehaving but the program keep crashing, although not as early, if I comment out all calls to the C functions. The segfaults happen frequently during the GC, in oldify_one or oldify_mopup, but also in a few other places such as camlList__rev_append or caml__apply2 or any other places as well. In caml_oldify_one, for instance, the segfault always happen at the same location : the assertion that sz is not 0 (and of course when you read the code it's pretty clear that sz=0 correspond to the case "already forwarded" that's handled at the beginning of the function). The pattern, then, is that a register (usually r0, r2 or r5) is restored from the stack after a call to a function that might call the GC (or to a call to the GC itself), then dereferenced. It's obvious inspecting the stack with gdb that this very word was changed during the call and a value like 0, 3 or 1024 is read back into the register instead of an mlvalue. I didn't managed (yet) to reduce the size of the program to a small show case, and I am under the impression that all these components are required in order for the bug to happen 'fast enough' : - threads - floats - call to C function (greatly reduce the time to wait before the crash) I am also under the impression that the bug is affected by the new stack alignment requirement (because in one occurrence, calling or not a function that does nothing from within a function hit by the bug reduced drastically the probability of the bug, and the major difference I saw was that on one version of the function the stack size was 16 bytes and the other 24 bytes (16+4 apparently for the address of a "module" structure, aligned up to 24 bytes). I thus manually checked the generated framesets but they were allright as far as I understand them. Now I'm a little desperate since each recompile+test takes about 20 minutes and the bug is so erratic ; so if someone here is familiar with ARM arch and in particular the difference between old and new ABI please suggest me what I should check, or any hint whatsoever. I'd be very much grateful as this consumes a lot of my spare time. Also, I'm compiling ocaml with gcc 4.2.1 - do you think it may be a problem with gcc not following the very same ABI ? Also I've run the testsuite but it did not reveal anything. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
[Caml-list] help with ocaml makefiles
Each time I need more debug information for the ocaml runtime itself (which hopefully is not often) I recompile Ocaml adding various "-g" and "-O0" here and there in some makefiles. But I've noticed there are some special targets and rules, specifically in byterun/Makefile, that seams to be there for that very purpose (the suffix rules for .d.c extention). So I suppose there is a standard way to compile ocaml in debugging mode. Do someone have some knowledge to share about this ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
[Caml-list] Checking for caml version from C
Hello ! I'm using ocaml 3.11 and 3.12 and I'm writting some C code that use caml_enter/leave_blocking_section. I'd like to know if there is a standard way to check for Ocaml version with the C preprocessor in order to switch to caml_release/acquire_runtime_system if version is >= 3.12 ? I grepped for VERSION in all the caml/*.h files without success. How am I supposed to do ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] More re GC hanging
> For some reason, I was able to edit that file using emacs, even when > echo wouldn't work. maybe you wrote "sudo echo 0 > file" or something similar which perfoms the echo as root but the redirection as normal user ?___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
[Caml-list] Encoding of (constructor * with * tuple)
Hello list. I'm using ocaml version 3.12.0+beta1, and reading the manual here : http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html#toc130 I have this datatype : type color_specs = Array of vertex_array | Uniq of color where : type color = int * int * int * int type vertex_array = (nativeint, Bigarray.nativeint_elt, Bigarray.c_layout) Bigarray.Array2.t Values of type color_specs are passed to a C function. >From the manual, I though that the value would be encoded in a block with a tag of 0 (for Array) or 1 (Uniq). If Array, wosize would be 1 and the first and only field would be a pointer to the bigarray, and if Uniq then the wosize would be 4 and the four fields would be the unboxed integers. But apparently I'm wrong since for the Uniq case the wosize is still 1 and the first field points to the tupple of 4 ints which is allocated separately, despite that the manual clearly says : "Non-constant constructors declared with a n-tuple as argument are represented by a block of size n, tagged with the constructor number; the n fields contain the components of its tuple argument." So who's wrong ? ocamlc ? the manual ? or just me :-) ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Architectures with natdynlink support...
> Maybe adding a ./configure option would be more flexible? I'm for it, or just add MIPS on the list of supported targets. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Inspect and dump values on the OCaml heap
> I am convinced that such things have *no* usefulness. If you > are trying to debug your data structure, state its global > invariants, prove (at whatever level of formality you are most > comfortable with) that all API functions preserve the invariants, > and use the module system to hide functions that do not > preserve them. You will be done faster than trying to make > sense of graphs and your code will be better. Visualizing data structures does no prevent you from proving some invariant and can give some other kind of informations, like spotting unexpected (ir)regularities, wrong proofs, etc... Why oppose both ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Inspect and dump values on the OCaml heap
I think this kind of dot output can be very informative if accurate enough, for instance as a pedagogical or debug purpose. That, and the fact that large graphs are beautiful. Large graphs are like to nightly skies : it's always nice to stare at them even if you are not knowledgeable in the field :) May I suggest gitorious instead of github for hosting this ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Debugging C and OCaml
-[ Mon, Mar 01, 2010 at 07:27:03PM +, Mark Shinwell ] > > What's "where" ? > > A gdb command. Sorry for the noise I failed to get info for this command. Knew it under name "bt" BTW. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Debugging C and OCaml
-[ Mon, Mar 01, 2010 at 03:19:41PM +, Mark Shinwell ] > That said, ocamlopt-compiled assembly code is fairly easy to > read, and you should be able to get something resembling a backtrace using > "where". What's "where" ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Unable to reach fixpoint building ocaml 3.11.2 on cygwin
-[ Tue, Jan 26, 2010 at 11:00:07AM -0800, Ed Keith ] > > > boot/ocamlc ocamlc differ: byte 137, line 2 > > Any other ideas? Maybe looking at the diff more closely could bring some ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] general question, was Re: OCaml is broken
> following this discussion, i am not so sure anymore, if ocaml is a good > decision. may be i got this discussion wrong, but if ocaml is dying out, i > might have to look for another functional programming language to use with my > project. Every programming language suffers its trolls and flamewars. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Re: What is CPAN? (was: Re: Hoogle for Ocaml)
-[ Fri, Dec 04, 2009 at 12:57:35AM +, Sylvain Le Gall ] > Yes of course. You can use ocamlcore.org website to do that. I have > already a proof of concept using "uscan" + Debian watch file, to scan > for new upstream on a weekly basis. Why not using godi_make fetch in all available build dirs, which will download everything not already present in the distfiles directory ? I'm trying this right now, then I will firewall everything but my test box and see if I can make use of this as a backup... Should we switch to GODI mailing list now ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: What is CPAN? (was: Re: [Caml-list] Hoogle for Ocaml)
> > (1) A network of redundant mirrors which means you can always get the > > tarball you need, even when the original site is down: If I understand correctly, GODI site does not store any of the source tarballs, but the makefiles download the sources directly from their respective home, does it ? Can't we use the MASTER_SITE_BACKUP make variables to have one or several backup sites ? If it's usefull I can try to setup a server to download every possible source tarballs and serve as such a site backup. But would it be usefull ? > > (2) CPAN unpacks each tarball and makes the source and documentation > > available in a browsable way: Why is it any better than something like that : http://docs.camlcity.org/docs/godipkg/3.10/godi-frontc/doc/godi-frontc/html/Ctoxml.html > > (3) An excellent search tool: Ok. > > (4) A central namespace registry for Perl modules. Once someone has > > the name 'Net::FTPServer', if you want to write an FTP server, you > > know you need to give it a different name. Ok ; unfortunately no such authority is required to name the few (compared to perl) ocaml libraries. > > (5) A testing network. > > (6) A place where you can browse everything that Perl supports: That would be nice to have in Godi as well. > > (7) A command line tool to download and install CPAN modules: I like godi_console (despite laking fancy colors :-), although I'd like a simpler command line tool to be available as well. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Hoogle for Ocaml
> Not really .. I have been meaning for several years to implement > something like *CPAN* for OCaml. CPAN is much more than what people > here seem to think it is. Out of curiosity, what's in CPAN that's not in GODI ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Missing the cmi files required to use toplevellib.cma
> Have you tried ocamlobjinfo? We install it along with OCaml in Debian. > (tools/objinfo.ml in OCaml source code) I saw it once, then forget completely about it. I'm going to have a look, thank you ! ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Missing the cmi files required to use toplevellib.cma
> You might also want to look at 'cmigrep'. I did not know this tool. Looks very usefull ! > This is really a packaging issue. I believe that Debian already ship > the compiled sources to OCaml as a separate package, mostly for this > reason. Ok ; I installed ocaml with inria's Makefile which does not install them. Apparently, from cmigrep Makefile, it seams that godi have them installed as well. So they are more commonly installed than I though and I have no reason to worries any more. Thank you ! ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
[Caml-list] Missing the cmi files required to use toplevellib.cma
While learning OCaml, I just coded a small program that dumps the full content of a cmi file. I find this more usefull than ocamlbrowser or to use the toplevel to have a small command line driven dumper, and it was also a good pretext to have a look under the cover. The problem is : most of the usefull types and functions are installed in the toplevellib.cma but I can't use this without the proper cmi files (I need config.cmi for cmi_magic_number, printtyp.cmi and typemod.cmi for printing signatures, but env.cmi would be nice to have as well for read_signature). Of course I can use those left in ocaml-3.11.1 directory after compilation, but having them installed would help the creation and distribution of such tools. But maybe there is an other way to use toplevellib.cma that I'm unaware of ? If not, then why not install these cmi files along with toplevellib ? Anyway, if anyone is interrested the tool is attached. open Format let want_magic = ref false let want_crc = ref false let want_name = ref false let want_flags = ref false let want_sig = ref false let simplify_sig = ref false (* Stolen from env.ml - would be great of exported *) type flags = Rectypes let print_flags flags = let flag_name = function | Rectypes -> "Rectypes" in printf "@[Flags@ =@ [...@[" ; List.iter (fun f -> printf "%s@ " (flag_name f)) flags ; printf "]...@]@]...@." let print_magic m = printf "@[Cmi magic number@ =@ %s (%s)@]...@." m (if m = Config.cmi_magic_number then "OK" else "Wrong!") let print_name name = printf "@[Name@ =@ %...@]@." name let print_crcs crcs = let print_crc (modname, crc) = printf "@[%s [...@]@ " modname (String.escaped crc) in printf "@[CRCs = @[" ; List.iter print_crc crcs ; printf "@]...@]@." let print_sig sign = fprintf std_formatter "@[Signature@ =@ @[<1>%...@]@]...@." Printtyp.signature (if !simplify_sig then (Typemod.simplify_signature sign) else sign) (* Reading persistent structures from .cmi files - Stolen from typing/env.ml * We'd rather use this instead of Env.read_signature so that we get all * components of the cmi files, not just signature *) let process_cmi_file filename = let show_sig = !want_sig || (not !want_magic && not !want_crc && not !want_name && not !want_flags) in let ic = open_in_bin filename in let magic_len = String.length (Config.cmi_magic_number) in let buffer = String.create magic_len in really_input ic buffer 0 magic_len ; let (name, sign) = input_value ic in let crcs = input_value ic in let flags = input_value ic in close_in ic ; if !want_magic then print_magic buffer ; if !want_name then print_name name ; if !want_crc then print_crcs crcs ; if !want_flags then print_flags flags ; if show_sigthen print_sig sign let process_file fname = if Filename.check_suffix fname "cmi" then process_cmi_file fname else printf "Don't know what to do with file '%s'\n" fname let _ = Arg.parse [ "-magic",Arg.Set want_magic, " Display cmi magic number" ; "-name", Arg.Set want_name," Display module name" ; "-crc", Arg.Set want_crc, " Display CRC" ; "-flags",Arg.Set want_flags, " Display flags" ; "-sig", Arg.Set want_sig, " Display signature" ; "-simplify", Arg.Set simplify_sig, " Do not simplify the signature" ] process_file "Syntax : cmidump [options] files... Shows the content of cmi files. If no option is given, shows only the signature. Possible options : " OCAMLC = ocamlfind ocamlc OCAMLDEP = ocamlfind ocamldep OCAMLFLAGS= -w Ae -g EXTCMI = env.cmi printtyp.cmi typemod.cmi config.cmi .PHONY: all clean install uninstall all: checkcmi cmidump cmidump: cmidump.cmo $(OCAMLC) -o $@ /usr/local/lib/ocaml/toplevellib.cma $(OCAMLFLAGS) $^ checkcmi: @for i in $(EXTCMI) ; do if ! test -f $$i ; then echo "Ocamlc will fail if it cant access $$i" ; fi ; done # Common rules .SUFFIXES: .ml .mli .cmo .cmi .cmx .ml.cmo: $(OCAMLC) $(OCAMLFLAGS) -I /usr/local/lib/ocaml -c $< .mli.cmi: $(OCAMLC) $(OCAMLFLAGS) -c $< # Clean up clean: rm -f cmidump.cmi *.cmo *.s # Dependencies .depend: *.ml $(OCAMLDEP) *.ml > .depend include .depend ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] OC4MC : OCaml for Multicore architectures
> Visual Basic has been a *lot* faster than OCaml for several years now, not > (...) Even Python (...) Java and C#. They are far more popular than OCaml for > many > reasons but parallel threads to make efficient multicore programming easy is > a big one. In general you sounds like a reasonable and knowledgeable person, yet in some messages you seam to completely lose contact with reality. Either you have a small kid at home who steals your identity when you are away, or, considering that it always happens when the toppic gets close to concurrency or the dotnet platform, you might be suffering in some way. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] OC4MC : OCaml for Multicore architectures
> Should we tell them that using CPU for nothing (side-effect for using > a "slow language") has a bad effect on global warming? Could it be a > wake-up call? :-p It also has bad effect on battery life, but that does not refrain them from releasing full software stacks for embedded devices based on these languages :-/ ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] OC4MC : OCaml for Multicore architectures
> Until now, OCaml sucked at parallelism. (...) OCaml programmers > can write OCaml programs that use multicore machines efficiently > for the first time. Subtle and strongly argumented, as expected. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] OC4MC : OCaml for Multicore architectures
> > Wow! 2.6x faster on 2 cores is good. ;-) > > Isn't that impossible? Or is the multicore GC better than the single > threaded one? (Sorry if this is a stupid or obvious question) There are so many factors that makes the running time unpredictable that nothing is surprising any more. Haven't you read this paper [1] about the length of an environment variable causing a program to be 10% faster or slower ? :) [1]: http://www-plan.cs.colorado.edu/diwan/asplos09.pdf ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Scilab: Why not written in OCaml?
> ...why is that program not written with INRIA's Ocaml? Probably for the same reason than all Princeton university programs are not written in SML/NJ (so I guess) ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Why don't you use batteries?
> OCaml needs more people. Where are the French, by the way? ;-) They are loading Ariane rockets with ADA :-) ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Why don't you use batteries?
> Using a very simple analysis from > http://en.wikipedia.org/wiki/Usage_share_of_desktop_operating_systems, > 97.14%[1] of the computers in the world run an OS which does not have a > "Linux"-style package manager (very sad, but true). With OCaml you can distribute native code programs, so the installation problem is relevant only to programmers. As only a very small portion of these "computers in the world" are used as programming work-stations, we can't conclude much from this measure. We'd rather have to know what share of computers used by programmers to write software does not come with a decent package system. I guess this would be much less impressive. Also, OCaml is not the only system that's harder to install on windows than on Unix : Haskell's Cabal have difficulties on windows also, for instance. I bet something like ActivePython came _after_ python was already popular and had many libraries that were easy to install on Linux only, and not the other way around. > In vain hope of not starting a flame war, In other words, you would like to be read but not answered ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Why don't you use batteries?
> 5) It's difficult to compile against I tried to use it once but failed to find documentation on how to use it with OCamlMakefile. > 8) Other (please explain) I'm still learning OCaml and I'm afraid that batteries, beeing both a library and sort of replacement for OCaml (replace compiler, toplevel...), would be too complex to comprehend. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] lazy vs fun
I had to read it three times, but I now understand the issue. I initialy though the first version was somewhat bugged :-) Now I understand why the second one is better. This kind of optimisation is very interresting (not capturing all the scope when building a closure). I will look for it now. And BTW, if I find the proper name for this technique in the book that I'm currently reading (The Impl. of Func. Prog. Lang.) then I will post it here to refresh your memory :) ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] lazy vs fun
> Oops. > The following makes it possible for f to be garbage-collected: ...? Because the fact that the fun calls f does not count as a reference ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
[Caml-list] Patch for native compiler on mips64el-linux-gnu
Works for me on loongson2F under experimental gentoo for n32 ABI. diff -u -r ocaml-3.11.1/asmcomp/mips/arch.ml my_ocaml/asmcomp/mips/arch.ml --- ocaml-3.11.1/asmcomp/mips/arch.ml 2002-11-29 16:03:36.0 +0100 +++ my_ocaml/asmcomp/mips/arch.ml 2009-08-09 23:18:31.0 +0200 @@ -35,7 +35,7 @@ let big_endian = match Config.system with -"ultrix" -> false +"ultrix" | "gnu" -> false | "irix" -> true | _ -> fatal_error "Arch_mips.big_endian" diff -u -r ocaml-3.11.1/asmcomp/mips/emit.mlp my_ocaml/asmcomp/mips/emit.mlp --- ocaml-3.11.1/asmcomp/mips/emit.mlp 2004-01-05 21:25:56.0 +0100 +++ my_ocaml/asmcomp/mips/emit.mlp 2009-08-23 12:11:58.0 +0200 @@ -252,7 +252,7 @@ | Lop(Icall_ind) -> ` move $25, {emit_reg i.arg.(0)}\n`; liveregs i live_25; -` jal {emit_reg i.arg.(0)}\n`; +` jal $25\n`; (* {emit_reg i.arg.(0)}\n; Equivalent but avoids "Warning: MIPS PIC call to register other than $25" on GNU as *) `{record_frame i.live}\n` | Lop(Icall_imm s) -> liveregs i 0; @@ -269,7 +269,7 @@ liveregs i 0; ` move $25, {emit_reg i.arg.(0)}\n`; liveregs i live_25; -` j {emit_reg i.arg.(0)}\n` +` j $25\n` | Lop(Itailcall_imm s) -> if s = !function_name then begin ` b {emit_label !tailrec_entry_point}\n` @@ -277,11 +277,11 @@ let n = frame_size() in if !contains_calls then ` lw $31, {emit_int(n - 4)}($sp)\n`; + ` la $25, {emit_symbol s}\n`; if !uses_gp then ` lw $gp, {emit_int(n - 8)}($sp)\n`; if n > 0 then ` addu $sp, $sp, {emit_int n}\n`; - ` la $25, {emit_symbol s}\n`; liveregs i live_25; ` j $25\n` end @@ -305,8 +305,13 @@ begin match chunk with Double_u -> (* Destination is not 8-aligned, hence cannot use l.d *) -` ldl $24, {emit_addressing addr i.arg 0}\n`; -` ldr $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`; +if big_endian then begin + ` ldl $24, {emit_addressing addr i.arg 0}\n`; + ` ldr $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n` +end else begin + ` ldl $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`; + ` ldr $24, {emit_addressing addr i.arg 0}\n` +end; ` dmtc1 $24, {emit_reg dest}\n` | Single -> ` l.s {emit_reg dest}, {emit_addressing addr i.arg 0}\n`; @@ -328,8 +333,13 @@ Double_u -> (* Destination is not 8-aligned, hence cannot use l.d *) ` dmfc1 $24, {emit_reg src}\n`; -` sdl $24, {emit_addressing addr i.arg 1}\n`; -` sdr $24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n` +if big_endian then begin + ` sdl $24, {emit_addressing addr i.arg 1}\n`; + ` sdr $24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n` +end else begin + ` sdl $24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n`; + ` sdr $24, {emit_addressing addr i.arg 1}\n` +end | Single -> ` cvt.s.d $f31, {emit_reg src}\n`; ` s.s $f31, {emit_addressing addr i.arg 1}\n` @@ -552,16 +562,18 @@ (* There are really two groups of registers: $sp and $30 always point to stack locations $2 - $21 never point to stack locations. *) - ` .noalias $2,$sp; .noalias $2,$30; .noalias $3,$sp; .noalias $3,$30\n`; - ` .noalias $4,$sp; .noalias $4,$30; .noalias $5,$sp; .noalias $5,$30\n`; - ` .noalias $6,$sp; .noalias $6,$30; .noalias $7,$sp; .noalias $7,$30\n`; - ` .noalias $8,$sp; .noalias $8,$30; .noalias $9,$sp; .noalias $9,$30\n`; - ` .noalias $10,$sp; .noalias $10,$30; .noalias $11,$sp; .noalias $11,$30\n`; - ` .noalias $12,$sp; .noalias $12,$30; .noalias $13,$sp; .noalias $13,$30\n`; - ` .noalias $14,$sp; .noalias $14,$30; .noalias $15,$sp; .noalias $15,$30\n`; - ` .noalias $16,$sp; .noalias $16,$30; .noalias $17,$sp; .noalias $17,$30\n`; - ` .noalias $18,$sp; .noalias $18,$30; .noalias $19,$sp; .noalias $19,$30\n`; - ` .noalias $20,$sp; .noalias $20,$30; .noalias $21,$sp; .noalias $21,$30\n\n`; + if Config.system = "irix" then begin +` .noalias $2,$sp; .noalias $2,$30; .noalias $3,$sp; .noalias $3,$30\n`; +` .noalias $4,$sp; .noalias $4,$30; .noalias $5,$sp; .noalias $5,$30\n`; +` .noalias $6,$sp; .noalias $6,$30; .noalias $7,$sp; .noalias $7,$30\n`; +` .noalias $8,$sp; .noalias $8,$30; .noalias $9,$sp; .noalias $9,$30\n`; +` .noalias $10,$sp; .noalias $10,$30; .noalias $11,$sp; .noalias $11,$30\n`; +` .noalias $12,$sp; .noalias $12,$30; .noalias $13,$sp; .noalias $13,$30\n`; +` .noalias $14,$sp; .noalias $14,$30; .noalias $15,$sp; .noalias $15,$30\n`; +` .noali
Re: [Caml-list] Native compilation for today's MIPS
Done ! At least, now coq compiles and seams to run OK. I encountered a strange bug, anyway, and would like some advice about my fix. Also, this bug do not seams related to my particular architecture and, as far as I can tell, would hit any MIPS. At various occasions the coqtop program jumped in the wrong places. This was due to the code emited for some tail calls : | Lop(Itailcall_imm s) -> if s = !function_name then begin ` b {emit_label !tailrec_entry_point}\n` end else begin let n = frame_size() in if !contains_calls then ` lw $31, {emit_int(n - 4)}($sp)\n`; if !uses_gp then ` lw $gp, {emit_int(n - 8)}($sp)\n`; if n > 0 then ` addu$sp, $sp, {emit_int n}\n`; ` la $25, {emit_symbol s}\n`; liveregs i live_25; ` j $25\n` end Now when !uses_gp is true, then the gp register is restored. Only then the address of symbol s is fetched into register $25, and jumped to. The problem is : the pseudo instruction 'la' may result in some code that uses gp to reach the global offset table and read the address from there. The assembler will then assume that the gp is the one that was setup at the begening of the function, and not the one that's just restored from the stack. Maybe for small programs the value of gp is always the same (I only vaguely understand this global pointer thing) but it is not the case for coq. So I merely moved upward the 'la' instruction, before the 'lw gp,stack'. And it works, apparently. What do you think ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Good book about ML compilation ?
> I much preferred another of Appel's books as an introduction to writing a > compiler: > > http://www.amazon.com/Compiling-Continuations-Andrew-W-Appel/dp/052103311X/ref=pd_sim_b_3_img Looks interresting also. Thank you both for your advices. > However, you could probably learn far more efficiently from another resource. > In particular, you can easily thrash today's ML compilers by using some of > the excellent tools and libraries like LLVM and more modern techniques like > monomorphization during JIT compilation. You might also want tuples as > structs to relieve the stress on the GC. These are some of the techniques I > am using for HLVM and the results speak for themselves (and I am describing > them in detail in OCaml Journal articles). This is also very interresting, and I already tried to install HLVM once. But my free time, as well as the lack of freely available documentation on this interresting project, force me to wait longer before jumping in. > If you want to learn how ML is (or should be) compiled then I think your best > bet is probably to ask here. I also recommend reading the source code to the > OCaml and F# compilers. Are you also interested in GCs? I think OCaml's GC is well documented compared to the other parts of the system (but probably this is because I ignore what everyone involved in writing a compiler already know). ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Good book about ML compilation ?
> For functional programming specifically, you might try Simon > Peyton-Jones's book "The Implementation of Functional Programming > Languages". This used to be available free here, but as I write the > website is down: > > http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ It works right now, and seams interresting indeed. Thank you for this valuable bookmark. I hope they use the same designations as in OCaml source for the more abstract concept :) > Best way to find out how OCaml is implemented is to read > the source. Yes, I'm doing plenty of that now. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
[Caml-list] Good book about ML compilation ?
Hello ! Suppose I want to learn how ML is compiled, and especialy how OCaml is compiled, it's various internal lambda representations and the like. Would this book : http://www.amazon.com/Modern-Compiler-Implementation-Andrew-Appel/dp/0521607647/ be a good one ? It's hard to tell what this book's worth from the customer advices ; it's especialy hard to tell if it fits well to OCaml or not. ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
[Caml-list] OCaml on Mips for IRIX n32 : why not 64bits ?
The question might look stupid, but I'm wondering why uintnat was not chosen to be "long long" on this architecture. Maybe the ARCH_SIXTYFOUR version of Ocaml was not ready at that time ? Or is there a downside at using the full 64bits registers on this arch that I'm unable to see ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Native compilation for today's MIPS
-[ Wed, Aug 12, 2009 at 02:12:26PM +0200, David MENTRE ] > Hello, > > > ldl t8,7(a1) > > ldr t8,0(a1) > > > Is this a problem you fixed in the compiler? Well, it's not really a bug since the MIPs compiler was tailored for bigendians. But if one want a MIPS compiler also for little endians this is something that must be changed in mips/emit.ml (this, and a couple of other things). For now I'm just experimenting. I will build an actual patch for people interrested when/if I become confident with the result. I just learnt that Debian is willing to create a mips64el distribution in addition to their venerable mips and mipsel versions. OCaml native compiler would be fine to have. Anyway, I have many other things to debug (like dynamic sharing) :) ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Native compilation for today's MIPS
> 1004b6cc: 68b8ldl t8,0(a1); Mips strange but > clever way to load a possibly unaligned doubleword into t8. > 1004b6d0: 6cb80007ldr t8,7(a1) Too clever for me apparently. Of course on a little endian CPU that must be : ldl t8,7(a1) ldr t8,0(a1) This problem is gone. Now camlp4 is compiled, and unison seams to work. Im going to try it on all Ocaml programs I can find to stress it a little bit. :-) ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Native compilation for today's MIPS
First, correcting myself, since I managed to confuse true and false : -[ Tue, Aug 11, 2009 at 12:11:00PM +0200, ri...@happyleptic.org ] > 1004b670: 24010001li at,1; a1 = true No, 1 is false. True would be 3. Thus : > 1004b674: 10410051beq v0,at,1004b7bc <$173> ; cmp previous > return value with true, and if so goto $173 where we left Of course, we break out of this sequence of "&&"s if the test is false. > 1004b6a4: 24010001li at,1; true > 1004b6a8: 10410041beq v0,at,1004b7b0 <$174> ; if both > stamps are eq, goto $174 which is equivalent to $147. Same remark as above. > ; The end when dataUnchanged is true. We could have reused $174 or $173. > ; So each time you write a && b && c you end up with 3 different true(s) ? So here at the end, dataUnchanged is false. But this does change much to the problem. So, After this little training, deciphering the second code (the one whithout FPU code which happen to work) is a piece of cake. Basically, instead of the FP registers comparison we have this : 1004b718 <$180>: 1004b718: 8fa5000clw a1,12(sp) ; a1 = [sp+12], aka t0 1004b71c: 3c18100clui t8,0x100c ; t8 = 0x100c+2244 -> same C function than before (equality test) 1004b720: 0c033a9ejal 100cea78 ; call it... 1004b724: 271808c4addiu t8,t8,2244 Ie the added function "is_same a b = a = b" had the (well known) consequence to replace the inline equality testing by the generic C version. So, the bug lies in the inline equality function for float values. Stay tunned ! :-) ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] Native compilation for today's MIPS
We are in August and there is nothing on TV. So why not read a little MIPS assembly instead ? I commented the part of unison's code that was looping forever, and while doing so I think I started to understand what's wrong with it. Remember this code from fileinfo.ml : let unchanged fspath path info = (* The call to [Util.time] must be before the call to [get] *) let t0 = Util.time () in let info' = get true fspath path in let dataUnchanged = Props.same_time info.desc info'.desc && stamp info = stamp info' && if Props.time info'.desc = t0 then begin prerr_endline ("infotime="^(string_of_float (Props.time info'.desc))^" et t0="^(string_of_float t0)); Unix.sleep 1; false end else true in ... Here is the commented assembly (best viewed in 16.9 aspect ratio :-) Please if you have some knowlodge on Mips assembly check that Im correct. Also, if you have some knowledge on Ocaml internals feel free to fill the missing bits of information. Or if you are just currious about what OCaml code looks like, the Mips wikipedia page provide almost all the information required to understand the following code. The code demonstrate some very good surprises, and some other less so. ; The three input params are in a4, a5 and a6. ; I was expecting Ocaml to follow regular conventions (use a0-a3 instead) ; but apparently it's not the case. There seams to be something in there ; already. 1004b608 : 1004b608: 27bdffe0addiu sp,sp,-32 ; sp -= 32 (make some room for our temp storage) 1004b60c: afbf001csw ra,28(sp) ; save return address in [sp+28] 1004b610: afbc0018sw gp,24(sp) ; save global pointer (?) in [sp+24] 1004b614: 3c180011lui t8,0x11 ; t8 = 0x11 1004b618: 27187eb8addiu t8,t8,32440 ; t8 += 32440 -> t8 = 0x117eb8 1004b61c: 0338e02ddaddu gp,t9,t8; gp = t9 + t8 (what's in t9 ? something like caml_young_ptr ?) 1004b620: afa8sw a4,0(sp); our params are : a4 = fspath, a5 = path, a6 = info, all boxed. Save them. 1004b624: afa90004sw a5,4(sp); onto [sp+0], [sp+1] and [sp+2] 1004b628: afaa0008sw a6,8(sp) 1004b62c: 0c01c5a5jal 10071694; call time() 1004b630: 24080001li a4,1; Funny Mips trick #1 : this is executed simultaneously from the previous jump, and gives the only argument (which is unit) 1004b634: afa2000csw v0,12(sp) ; save returned time in [sp+12] ( = t0, boxed float according to signature) 1004b638: 24080003li a4,3; a4 = 3 (true in Ocaml language) 1004b63c: 8fa9lw a5,0(sp); a5 = fspath 1004b640: 0c012c9ejal 1004b278 ; called with true (a4), fspath, path 1004b644: 8faa0004lw a6,4(sp); remember trick#1, here is path. 1004b648: afa20004sw v0,4(sp); save return value in [sp+4] (info') ; Notice here how we reused the location of path, which is no more used. Wow! ; We need here to have a look at info and info' type : ; info type = { typ : typ; inode : int; ctime : float; desc : Props.t; osX : Osx.info} ; where ; Props.t type is = { perm : Perm.t; uid : Uid.t; gid : Gid.t; time : Time.t; typeCreator : TypeCreator.t; length : Uutil.Filesize.t } 1004b64c: 8c52000clw s2,12(v0) ; s2 = [v0+12] ie info'.desc 1004b650: 8fae0008lw t2,8(sp); t2 = [sp+8] ie info (our third param) 1004b654: 8dd1000clw s1,12(t2) ; s1 = [info+12] ie info.desc 1004b658: 3c101015lui s0,0x1015 ; s0 = 0x1012 (some external symbol ?) 1004b65c: 8e10f0a4lw s0,-3932(s0); s0 = something 3932 bytes before it 1004b660: 8e0a002clw a6,44(s0) ; a6 = this_thing.eleventh_slot ? ie a way to reach module Unix.time (see below) ? 1004b664: 8e49000clw a5,12(s2) ; a5 = info'.desc[12] ie info'.desc.time 1004b668: 0c013889jal 1004e224 ; call Props.same, which does not exist according to props.ml 1004b66c: 8e28000clw a4,12(s1) ; (mips trick#1 again) a4 = info.desc[12] ie info.desc.time ; But we have in props.ml this one : ; let same_time p p' = Time.same p.time p'.time ; Look like we have here inter-module inlining. ; How is it possible ? Perhaps a "same" fucntion is added into Props module with an additionnal parameter to points to Time module, ; and this info is available somehow in props.cmi ? 1004b670: 24010001li at,1; a1 = true 1004b674: 10410051beq v0,at,1004b7bc <$173> ; cmp
Re: [Caml-list] Native compilation for today's MIPS
I managed to spot a problem with this small piece of code, which is the last function of unison's fileinfo module : let unchanged fspath path info = (* The call to [Util.time] must be before the call to [get] *) let t0 = Util.time () in let info' = get true fspath path in let dataUnchanged = Props.same_time info.desc info'.desc && stamp info = stamp info' && if Props.time info'.desc = t0 then begin prerr_endline ("infotime="^(string_of_float (Props.time info'.desc))^" et t0="^(string_of_float t0)); (* THIS POOR STYLE LINE IS FROM ME *) Unix.sleep 1; false end else true in ... As is, the generated code does not work as intended : although Props.time infos'.desc and t0 are two distinct floats, the = test behave like the values were equal and this function loop while it shouldn't. The corresponding code is : 1004b608 : 1004b608: 27bdffe0addiu sp,sp,-32 1004b60c: afbf001csw ra,28(sp) 1004b610: afbc0018sw gp,24(sp) 1004b614: 3c180011lui t8,0x11 1004b618: 27187eb8addiu t8,t8,32440 1004b61c: 0338e02ddaddu gp,t9,t8 1004b620 <$180>: 1004b620: afa8sw a4,0(sp) 1004b624: afa90004sw a5,4(sp) 1004b628: afaa0008sw a6,8(sp) 1004b62c: 0c01c5a5jal 10071694 1004b630: 24080001li a4,1 1004b634 <$181>: 1004b634: afa2000csw v0,12(sp) 1004b638: 24080003li a4,3 1004b63c: 8fa9lw a5,0(sp) 1004b640: 0c012c9ejal 1004b278 1004b644: 8faa0004lw a6,4(sp) 1004b648 <$182>: 1004b648: afa20004sw v0,4(sp) 1004b64c: 8c52000clw s2,12(v0) 1004b650: 8fae0008lw t2,8(sp) 1004b654: 8dd1000clw s1,12(t2) 1004b658: 3c101015lui s0,0x1015 1004b65c: 8e10f0a4lw s0,-3932(s0) 1004b660: 8e0a002clw a6,44(s0) 1004b664: 8e49000clw a5,12(s2) 1004b668: 0c013889jal 1004e224 1004b66c: 8e28000clw a4,12(s1) 1004b670 <$183>: 1004b670: 24010001li at,1 1004b674: 10410051beq v0,at,1004b7bc <$173> 1004b678: nop 1004b67c: 0c012d44jal 1004b510 1004b680: 8fa80004lw a4,4(sp) 1004b684 <$184>: 1004b684: afa2sw v0,0(sp) 1004b688: 0c012d44jal 1004b510 1004b68c: 8fa80008lw a4,8(sp) 1004b690 <$185>: 1004b690: 0040202dmovea0,v0 1004b694: 8fa5lw a1,0(sp) 1004b698: 3c18100clui t8,0x100c 1004b69c: 0c033a96jal 100cea58 1004b6a0: 271808a4addiu t8,t8,2212 1004b6a4 <$186>: 1004b6a4: 24010001li at,1 1004b6a8: 10410041beq v0,at,1004b7b0 <$174> 1004b6ac: nop 1004b6b0: 8faa0004lw a6,4(sp) 1004b6b4: 8d48000clw a4,12(a6) 1004b6b8: 8d07000clw a3,12(a4) 1004b6bc: 90e6fffclbu a2,-4(a3) 1004b6c0: 10c7beqza2,1004b6e0 <$179> 1004b6c4: nop 1004b6c8: 8ce5lw a1,0(a3) 1004b6cc: 68b8ldl t8,0(a1) 1004b6d0: 6cb80007ldr t8,7(a1) 1004b6d4: 44b80800dmtc1 t8,$f1 1004b6d8: 1005b 1004b6f0 <$178> 1004b6dc: nop 1004b6e0 <$179>: 1004b6e0: 8ce4lw a0,0(a3) 1004b6e4: 6898ldl t8,0(a0) 1004b6e8: 6c980007ldr t8,7(a0) 1004b6ec: 44b80800dmtc1 t8,$f1 1004b6f0 <$178>: 1004b6f0: 8fa8000clw a4,12(sp) 1004b6f4: 6918ldl t8,0(a4) 1004b6f8: 6d180007ldr t8,7(a4) 1004b6fc: 44b8dmtc1 t8,$f0 1004b700: nop 1004b704: 46200832c.eq.d $f1,$f0 1004b708: nop 1004b70c: 4525bc1f1004b7a4 <$175> 1004b710: nop 1004b714: 0c020d9djal 10083674 1004b718: nop 1004b71c <$187>: 1004b71c: 0040482dmovea5,v0 1004b720: 3c081015lui a4,0x1015 1004b724: 0c020cdejal 10083378 1004b728: 2508ef1caddiu a4,a4,-4324 1004b72c <$188>: 1004b72c: afa2sw v0,0(sp) 1004b730: 8fa80004lw a4,4(sp) 1004b734: 8d14000clw s4,12(a4) 1004b738: 8e93000clw s3,12(s4) 1004b73c: 9272fffclbu s2,-4(s3) 1004b740: 1244beqzs2,1004b754 <$177> 1004b744: nop 1004b748: 8e7100
[Caml-list] Native compilation for today's MIPS
Hello. I'm trying to make ocaml native compiler works on a Loongson2F processor with a GNU/Linux system. So far, I managed to work around many ABI related issues (I want n32 ABI, because from the configure script it seams closest from the old MIPS assembly emmiter and because "the Internet" thinks it's faster than o32). So, after some minor changes I got ocamlopt and ocamlopt.opt, but the make opt.opt command fails while compiling camlp4 (or sometime the debugger, depending on compilation flags) : ../ocamlopt.opt -nostdlib -c -g -I camlp4 -I stdlib -o camlp4/Camlp4_import.cmx camlp4/Camlp4_import.ml Fatal error: exception Invalid_argument("index out of bounds") whatever OCAMLRUNPARAM settings I try, I have no backtrace. So to figure out where this is comming from I tried gdb but with not much luck : This GDB was configured as "mips64el-unknown-linux-gnu"... (gdb) b caml_array_bound_error Breakpoint 1 at 0x1016d708: file fail.c, line 192. (gdb) r Starting program: ocamlopt.opt -nostdlib -I ../stdlib -c -g -I camlp4 -I stdlib -o camlp4/Camlp4_import.cmx camlp4/Camlp4_import.ml Breakpoint 1, caml_array_bound_error () at fail.c:192 192 if (! array_bound_error_bucket_inited) { (gdb) bt #0 caml_array_bound_error () at fail.c:192 #1 0x1016cff8 in caml_c_call () at mips.s:192 Backtrace stopped: frame did not save the PC Now I'm running out of ideas. I have cleared all gcc warnings about ABI mismatch but I suspect something is still wrong in this area. Being new both to Mips and to OCaml does not help, neither. So I humbly request for any pointers or ideas about what to look for. Also, I have to say these flawed ocamlopt and ocamlopt.opt compilers can actually compile my own poor production of ML programs, which then appear to run normaly, so Im lacking ML programs of intermediate "difficulty" to experiment. Is there a test suite somewhere I could use to test the compiler ? Should I test some particular language construct in particular ? What's your opinion ? ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Re: [Caml-list] ocamlgraph predecessors
> What you're asking is similar to the problem of finding the predecessor > of an arbitrary node in a singly-linked-list. You have no option but to > scan the whole list to find its predecessor. If you had a > doubly-linked-list, predecessor lookups would work easily, but that's a > different data structure, with much more overhead. Much more overhead, really ? So this is for performance reasons that all functionnal languages promote singly-linked lists, while for instance in Linux every list is implemented with a doubly linked list for purely ideological reasons ? :-) ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs