GithubHelp home page GithubHelp logo

ekdohibs / camlboot Goto Github PK

View Code? Open in Web Editor NEW
91.0 91.0 6.0 13.56 MB

Experiment on how to bootstrap the OCaml compiler

License: MIT License

Makefile 1.36% OCaml 83.17% Shell 2.14% Standard ML 0.01% Scheme 13.32%
ocaml

camlboot's People

Contributors

brianhempel avatar curiousleo avatar ekdohibs avatar gasche avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

camlboot's Issues

document the time required to bootstrap

Before even considering reproducing a debootstrap experiment, I would want to know how long it's going to take, or at least how long it took for people who did it in the past. I complain about other projects not providing this information, but we don't either. I'm opening this issue to track this: we should include complete build time on someone's machine directly in the README.

Something to cite?

Excellent project! I modified the OCaml-based interpreter to provide dynamic program traces in order to build a live programming environment for OCaml (unexplained teaser screenshot below).

I would like to know how to cite this project. Would you be able to add a CITATION.cff file? Or at least, how should I write the author list for citing the interpreter written in OCaml?

Thanks a bunch. Camlboot is excellent work that saved me weeks if not months of time!

Screenshot 2021-10-13 at 2 53 14 PM

Amazing project!

This is exciting. I have been wondering about bootstrapping Ocaml for a while. I have not test build yet but I saw this is able to build ocamlc.

What are you opinions about transforming the code into scheme somehow, in order to bootstrap of a basic scheme interpreter written in C?

The reason I suggest scheme is that macros enable us to manipulate the scheme language to be much more like ocaml in all ways except the surface syntax.

port to ocaml 4.09

Hi!

I've started working on porting camlboot to ocaml 4.09 and I'm having some issues. Guix still has ocaml 4.09, so that's why it felt like the natural next step. I guess I would have more issues if I tried to port to the latest OCaml anyway :)

I managed to build generated files like the lexer and parser. I had to assume menhir was available (bootstrapped from ocaml 4.07 :D, and we need to copy its menhirLib.{ml,mli} into boot/menhir in ocaml's source directory), changed some file locations when they moved to another place in ocaml's sources and fixed some issues with building ocamllex. I created a branch at https://github.com/roptat/camlboot/tree/4.09 and at https://github.com/roptat/ocaml/tree/4.09-camlboot. I had to implement a few missing primitives and fix interpreter/interp.ml to load ocaml's sources properly.

Now I can run make _boot/ocamlc and it builds up to interp.byte. However, when running it I get this error:

./interp -nopervasives -nostdlib -w -20-21 -I ../../interpreter -c stdopt.mli
Code raised exception: Assert_failure#7 (, 0, 0)

which doesn't help figuring out what went wrong :/

If it helps, I get the same error with no arguments, like ./interp, in about the same time so I guess the issue happens very early in OCaml's initialization.

Any ideas would be appreciated :)

Support i686?

Since I pushed camlboot to Guix, we kinda need to support the platform it supports (well, I can also fix that by not using camlboot on i686). Here is the error I get (see https://ci.guix.gnu.org/build/18557/log/raw):

mkdir -p lex/
../../ocaml-src/byterun/ocamlrun lex.boot.byte ../../ocaml-src/lex/lexer.mll -o lex/lexer.ml
Fatal error: exception Failure("input_value: object too large to be read back on a 32-bit platform")
make[1]: *** [Makefile:28: lex/lexer.ml] Error 2

Is this an issue with lex.boot.byte (because we maybe only create bytecode for 64 bit architectures), or with lexer.mll (because maybe it creates huge objects)?

"Hello world" build instructions

Building interp and interpopt + supporting files

cd camlboot and extract the ocaml-4.07.0 source release to this directory. Edit the following lines of interp.ml (they must be absolute paths, relative paths will not work):

[1202] let stdlib_path = "/path/to/camlboot/ocaml-4.07.0/stdlib"
[1344] let compiler_path = "/path/to/camlboot/ocaml-4.07.0"

Make a copy of ocaml-4.07.0/utils/profile.ml called ocaml-4.07.0/utils/profile.ml.noprof and add the following to line 99 of (disables profiling that uses unsupported features of the interpreter)

let record_call ?(accumulate = false) name f = f ()

You should be able to build interp now with make. btu you'll need to get get into the ocaml-4.07.0 directory to build some files to actually run it:

bash configure
( cd stdlib/ ; make sys.ml )
make utils/config.ml
make ocamlyacc ; cp yacc/ocamlyacc boot/ ; make parsing/parser.ml
make CAMLLEX=ocamllex CAMLRUN=ocamlrun parsing/lexer.ml
make bytecomp/runtimedef.ml
make CAMLLEX=ocamllex CAMLRUN=ocamlrun CAMLC=ocamlc bytecomp/opcodes.ml

Building the ocaml std library with camlboot interpopt

Back to camlboot. If all was successful ./interp should print a newline and exit. You can also make interpopt. Now to build the standard library (you might want to enable parallel building for this export MAKEFLAGS='-j 8'):

export CAMLC=`pwd`/interpopt
cd ocaml-4.07.0/stdlib/
touch ../ocamlc
chmod +x ./Compflags
make CAMLC=$CAMLC CAMLRUN=ocamlrun

Building hello world with interpopt

echo 'print_string "Hello world!\n";;' > hw.ml
./interpopt -nostdlib -I ./ocaml-4.07.0/stdlib hw.ml
ocamlrun ./a.out

Infix operators have reduce/reduce conflicts

Steps to reproduce

Try the infix branch, and run compile.scm. You will get a warning %% Reduce/Reduce conflict (reduce 84, reduce 48) on 'RPAREN' in state 96. I don't know the source of the conflict.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.