Skip to content

Commit 7f9e10d

Browse files
author
Andy Ray
committed
info on compiling ocaml
1 parent 5120397 commit 7f9e10d

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

rpi/CompilingOcaml.md

+64
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,68 @@ mkdir /usr/ports
6363
mount <ip_addr_of_server>:/home/.../freebsd/fs/ports /var/ports
6464
```
6565

66+
# Compiling OCaml
67+
68+
I am using the official 4.01.0 release tarball initially.
69+
70+
Initially a `make world` seems to be OK and build a functioning interpreter. Getting
71+
a native code compiler is a bit more effort.
72+
73+
The `configure` script will not detect a native code compiler for this platform so
74+
we need to start hacking. My first attempt was to add a clause
75+
76+
```
77+
# Configure the native-code compiler
78+
...
79+
armv6*-*-freebsd*) arch=arm; model=armv6; system=freebsd;;
80+
...
81+
```
82+
83+
This requires a further change to asmrun/arm.S at the top.
84+
85+
```
86+
elif defined(Sys_linux_eabi) || defined(Sys_frebsd)
87+
```
88+
89+
to get the clx macro defined. This isnt exactly our architecture but it seems a
90+
reasonable lowest common denominator for now.
91+
92+
Further arm.S does not compile correctly as the makefile uses `gcc` to assemble
93+
and preprocess. Changing to `cc` gets this compiled.
94+
95+
```
96+
cc -c -DSYS_freebsd -DMODEL_armv6 -o arm.o arm.S
97+
```
98+
99+
Finally we modify asmcomp/arch.ml at the very top so that `Config.sysytem = "freebsd"`
100+
maps to EABI.
101+
102+
Now we can run `make opt` and get a native code compiler. However, on running it we get
103+
104+
```
105+
% ocamlopt test.ml
106+
/usr/bin/ld: ERROR: Source object /tmp/camlstartupd0882d.o has EABI version 0, but target a.out has EABI version 5
107+
/usr/bin/ld: failed to merge target specific data of file /tmp/camlstartupd0882d.o
108+
/usr/bin/ld: ERROR: Source object /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/std_exit.o has EABI version 0, but target a.out has EABI version 5
109+
/usr/bin/ld: failed to merge target specific data of file /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/std_exit.o
110+
/usr/bin/ld: ERROR: Source object test.o has EABI version 0, but target a.out has EABI version 5
111+
/usr/bin/ld: failed to merge target specific data of file test.o
112+
/usr/bin/ld: ERROR: Source object /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(pervasives.o) has EABI version 0, but target a.out has EABI version 5
113+
/usr/bin/ld: failed to merge target specific data of file /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(pervasives.o)
114+
/usr/bin/ld: ERROR: Source object /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(list.o) has EABI version 0, but target a.out has EABI version 5
115+
/usr/bin/ld: failed to merge target specific data of file /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(list.o)
116+
/usr/bin/ld: ERROR: Source object /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(char.o) has EABI version 0, but target a.out has EABI version 5
117+
/usr/bin/ld: failed to merge target specific data of file /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(char.o)
118+
/usr/bin/ld: ERROR: Source object /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(string.o) has EABI version 0, but target a.out has EABI version 5
119+
/usr/bin/ld: failed to merge target specific data of file /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(string.o)
120+
/usr/bin/ld: ERROR: Source object /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(sys.o) has EABI version 0, but target a.out has EABI version 5
121+
/usr/bin/ld: failed to merge target specific data of file /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(sys.o)
122+
/usr/bin/ld: ERROR: Source object /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(buffer.o) has EABI version 0, but target a.out has EABI version 5
123+
/usr/bin/ld: failed to merge target specific data of file /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(buffer.o)
124+
/usr/bin/ld: ERROR: Source object /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(printf.o) has EABI version 0, but target a.out has EABI version 5
125+
/usr/bin/ld: failed to merge target specific data of file /home/pi/dev/ocaml/ocaml-4.01.0-install/lib/ocaml/stdlib.a(printf.o)
126+
cc: error: linker command failed with exit code 1 (use -v to see invocation)
127+
File "caml_startup", line 1:
128+
Error: Error during linking
129+
```
66130

0 commit comments

Comments
 (0)