Thanks to each of you for the suggestions. I thought I’d try vlaviron’s approach first.
if your changes are on the compiler’s code itself then you need to setup your compiler to produce 32-bits executables.
Yes, I need this. I’m not changing the compiler itself, but adding new library routines to
Gc written in C.
gcc-multilib, I can generate a 32-bit executable but I can’t run it. I don’t know if Ubuntu supports 32-bit executables or, less likely, if it is WSL2-related. (Generating a Win-32 executable wouldn’t help, BTW, because my code relies on having an ELF-format executable–I’m reading the symbol table from the executable file.)
$ gcc -m32 test.c
$ file a.out
a.out: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 3.2.0, BuildID[sha1]=5e7cf908319fd18b454f6d3b57b7caf7af664ff8, not stripped
bash: ./a.out: cannot execute binary file: Exec format error
Separately, I tried your
./configure as well as one with parameters more similar to what’s in the build script (though I couldn’t guess what
prefix should be). Both of them generate a couple hundred lines of output before failing with:
cp runtime/ocamlrun boot/ocamlrun
make -C stdlib \
CAMLC='$(BOOT_OCAMLC) -use-prims ../runtime/primitives' all
make: Entering directory '/mnt/c/proj/ocaml/stdlib'
../boot/ocamlrun ../boot/ocamlc -use-prims ../runtime/primitives -strict-sequence -absname -w +a-4-9-41-42-44-45-48 -g -warn-error A -bin-annot -nostdlib -safe-string -strict-formats -nopervasives -c camlinternalFormatBasics.mli
sed -e "s|%%VERSION%%|`sed -e 1q ../VERSION | tr -d '\r'`|" sys.mlp > sys.ml
../boot/ocamlrun: 1: ../boot/ocamlrun: Syntax error: word unexpected (expecting ")")
Makefile:217: recipe for target 'camlinternalFormatBasics.cmi' failed
make: *** [camlinternalFormatBasics.cmi] Error 2
make: *** Waiting for unfinished jobs....
make: Leaving directory '/mnt/c/proj/ocaml/stdlib'
Makefile:347: recipe for target 'coldstart' failed
make: *** [coldstart] Error 2
make: Leaving directory '/mnt/c/proj/ocaml'
Makefile:476: recipe for target 'world.opt' failed
make: *** [world.opt] Error 2
I’m not sure what to try next.
@ dakk A good thought, although I expect it has the same issue described above. Since I’m adding code to OCaml itself, I need to be able to compile my changes incrementally outside of opam. Building within opam is always a full build (several minutes) while an incremental build with make is only several seconds.