bvaugon / ocamlcc Goto Github PK
View Code? Open in Web Editor NEWOCaml bytecode to C compiler
License: Other
OCaml bytecode to C compiler
License: Other
Dear ocamlcc developers,
I just installed ocamlcc with OPAM, and tried to compile a bytecode program. But I got the following error:
ld: unknown option: -E
collect2: ld returned 1 exit status
Error: command '/usr/bin/gcc -D_FILE_OFFSET_BITS=64 /var/folders/d3/bn5myb2950n5q31dc87xt9dm0000gn/T/tmp-ocamlcc-bdaef2.c -o fib.out -I /Users/john/.opam/system/include/ocamlcc -I /Users/john/.opam/system/include/ocamlcc/ocamlcc-byterun-4.00 -lm -ldl -lcurses -Wl,-E -O3 -Wall' failed.
I'm using MacOS X 10.8 with OCaml 4.00.1. Everything works fine if I manually compile the generated C file without the option -Wl,-E.
If I use the Unix module then ocamlcc fails to link (even if I used -custom to generate the bytecode), and I have to manually add to -ccopts to make it link.
Testcase:
$ cat >x.ml <<EOF
let () =
Printf.printf "Time: %f\n" (Unix.gettimeofday ())
EOF
$ ocamlfind ocamlc -package unix x.ml -linkpkg -o x.byte
$ ocamlcc -verbose x.byte
+ Running '"/home/edwin/.opam/4.00.1/bin/ocamlclean" "x.byte" -o "/tmp/tmp-ocamlcc-435ea7.byte"'... [0.10s]
+ Loading "/tmp/tmp-ocamlcc-435ea7.byte"..... [0.01s]
+ Decompiling functions.... [0.01s]
+ Folding closures... [0.01s]
+ Remapping stack access... [0.00s]
+ Computing cell types..... [0.09s]
+ Cleaning functions..... [0.00s]
+ Generating C code... [0.01s]
+ Generating "/tmp/tmp-ocamlcc-f2c38d.c"... [0.02s]
+ Removing "/tmp/tmp-ocamlcc-435ea7.byte"... done
+ Running '/home/edwin/bin/gcc -D_FILE_OFFSET_BITS=64 /tmp/tmp-ocamlcc-f2c38d.c -I /home/edwin/.opam/4.00.1/include/ocamlcc -I /home/edwin/.opam/4.00.1/include/ocamlcc/ocamlcc-byterun-4.00 -lm -ldl -lcurses -Wl,-E -O3 -Wall'.../tmp/cc5Zsv1r.o: In function `f4823':
tmp-ocamlcc-f2c38d.c:(.text+0xce2): undefined reference to `unix_gettimeofday'
/tmp/cc5Zsv1r.o: In function `ocamlcc_bytecode_main':
tmp-ocamlcc-f2c38d.c:(.text+0x32c9b): undefined reference to `unix_inet_addr_of_string'
tmp-ocamlcc-f2c38d.c:(.text+0x32ccc): undefined reference to `unix_inet_addr_of_string'
tmp-ocamlcc-f2c38d.c:(.text+0x32d91): undefined reference to `unix_inet_addr_of_string'
tmp-ocamlcc-f2c38d.c:(.text+0x32e79): undefined reference to `unix_inet_addr_of_string'
tmp-ocamlcc-f2c38d.c:(.text+0x32f87): undefined reference to `unix_gettimeofday'
collect2: error: ld returned 1 exit status
[6.09s]
Error: command '/home/edwin/bin/gcc -D_FILE_OFFSET_BITS=64 /tmp/tmp-ocamlcc-f2c38d.c -I /home/edwin/.opam/4.00.1/include/ocamlcc -I /home/edwin/.opam/4.00.1/include/ocamlcc/ocamlcc-byterun-4.00 -lm -ldl -lcurses -Wl,-E -O3 -Wall' failed.
+ Removing "/tmp/tmp-ocamlcc-f2c38d.c"... done
$ ocamlfind ocamlc x.ml -package unix -linkpkg -o x.byte -custom
$ ocamlcc -verbose x.byte
+ Running '"/home/edwin/.opam/4.00.1/bin/ocamlclean" "x.byte" -o "/tmp/tmp-ocamlcc-c868a0.byte"'... [0.11s]
+ Loading "/tmp/tmp-ocamlcc-c868a0.byte"..... [0.01s]
+ Decompiling functions.... [0.01s]
+ Folding closures... [0.01s]
+ Remapping stack access... [0.00s]
+ Computing cell types..... [0.12s]
+ Cleaning functions..... [0.00s]
+ Generating C code... [0.01s]
+ Generating "/tmp/tmp-ocamlcc-30d075.c"... [0.02s]
+ Removing "/tmp/tmp-ocamlcc-c868a0.byte"... done
+ Running '/home/edwin/bin/gcc -D_FILE_OFFSET_BITS=64 /tmp/tmp-ocamlcc-30d075.c -I /home/edwin/.opam/4.00.1/include/ocamlcc -I /home/edwin/.opam/4.00.1/include/ocamlcc/ocamlcc-byterun-4.00 -lm -ldl -lcurses -Wl,-E -O3 -Wall'.../tmp/ccFu7kNe.o: In function `f4823':
tmp-ocamlcc-30d075.c:(.text+0xce2): undefined reference to `unix_gettimeofday'
/tmp/ccFu7kNe.o: In function `ocamlcc_bytecode_main':
tmp-ocamlcc-30d075.c:(.text+0x32c9b): undefined reference to `unix_inet_addr_of_string'
tmp-ocamlcc-30d075.c:(.text+0x32ccc): undefined reference to `unix_inet_addr_of_string'
tmp-ocamlcc-30d075.c:(.text+0x32d91): undefined reference to `unix_inet_addr_of_string'
tmp-ocamlcc-30d075.c:(.text+0x32e79): undefined reference to `unix_inet_addr_of_string'
tmp-ocamlcc-30d075.c:(.text+0x32f87): undefined reference to `unix_gettimeofday'
collect2: error: ld returned 1 exit status
[6.11s]
Error: command '/home/edwin/bin/gcc -D_FILE_OFFSET_BITS=64 /tmp/tmp-ocamlcc-30d075.c -I /home/edwin/.opam/4.00.1/include/ocamlcc -I /home/edwin/.opam/4.00.1/include/ocamlcc/ocamlcc-byterun-4.00 -lm -ldl -lcurses -Wl,-E -O3 -Wall' failed.
+ Removing "/tmp/tmp-ocamlcc-30d075.c"... done
$ ocamlcc -verbose x.byte -ccopts -L`ocamlfind query unix` -ccopts -lunix
+ Running '"/home/edwin/.opam/4.00.1/bin/ocamlclean" "x.byte" -o "/tmp/tmp-ocamlcc-d9b53c.byte"'... [0.08s]
+ Loading "/tmp/tmp-ocamlcc-d9b53c.byte"..... [0.01s]
+ Decompiling functions.... [0.01s]
+ Folding closures... [0.01s]
+ Remapping stack access... [0.00s]
+ Computing cell types..... [0.09s]
+ Cleaning functions..... [0.00s]
+ Generating C code... [0.01s]
+ Generating "/tmp/tmp-ocamlcc-a7b66f.c"... [0.02s]
+ Removing "/tmp/tmp-ocamlcc-d9b53c.byte"... done
+ Running '/home/edwin/bin/gcc -D_FILE_OFFSET_BITS=64 /tmp/tmp-ocamlcc-a7b66f.c -I /home/edwin/.opam/4.00.1/include/ocamlcc -I /home/edwin/.opam/4.00.1/include/ocamlcc/ocamlcc-byterun-4.00 -lm -ldl -lcurses -Wl,-E -O3 -Wall "-L/home/edwin/.opam/4.00.1/lib/ocaml" "-lunix"'... [6.11s]
+ Removing "/tmp/tmp-ocamlcc-a7b66f.c"... done
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.