FreeBSD ocaml support for aarch64

J P <[email protected]>
Newsgroups gmane.os.freebsd.devel.arm,gmane.os.freebsd.devel.ports
Message-ID <CABcCtUTJLy3wF14WO12xpEHgGZnpbGLwwc6xT2LswQJtAVvLLA@mail.gmail.com>
Hi,
lang/ocaml port is marked as broken on aarch64 and I would like to
contribute and have it fixed.

The broken reason is incorrect as of now:
BROKEN_aarch64=         Does not build: sh: as: not found

If I comment this line out, "as" is correctly found given the port
dependency from binutils:
BUILD_DEPENDS=  as:devel/binutils

The build process stops with:
ld: error: can't create dynamic relocation R_AARCH64_LDST64_ABS_LO12_NC
against symbol: camlUnix in readonly segment; recompile object files with
-fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in unix.a(unix.o)
>>> referenced by unix.ml:863
>>>               unix.o:(camlUnix__waitpid_non_intr_1853) in archive unix.a

ld: error: too many errors emitted, stopping now (use -error-limit=0 to see
all errors)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
File "caml_startup", line 1:
Error: Error during linking
gmake[4]: *** [../Makefile:74: unix.cmxs] Error 2
gmake[4]: Leaving directory
'/wrkdirs/usr/ports/lang/ocaml/work/ocaml-4.05.0/otherlibs/unix'
gmake[3]: *** [Makefile:1055: otherlibrariesopt] Error 2
gmake[3]: Leaving directory
'/wrkdirs/usr/ports/lang/ocaml/work/ocaml-4.05.0'
gmake[2]: *** [Makefile:465: opt.opt] Error 2
gmake[2]: Leaving directory
'/wrkdirs/usr/ports/lang/ocaml/work/ocaml-4.05.0'
gmake[1]: *** [Makefile:531: world.opt] Error 2
gmake[1]: Leaving directory
'/wrkdirs/usr/ports/lang/ocaml/work/ocaml-4.05.0'
*** Error code 1

Stop.
make: stopped in /usr/ports/lang/ocaml

Trying to fix this issue by adding -fPIC to CONFIGURE_ARGS does nothing, in
the sense that the option actually adds -fPIC to ld args, but the error
remains.

So I went the other way and changed LDFLAGS as suggested by the error
message:
LDFLAGS_aarch64=        -Wl,-z,notext

In this case I hit an obscure error when making with make -j <numcpus>:
boot/ocamlrun ./ocamlopt -g -nostdlib -I stdlib -I otherlibs/dynlink
-strict-sequence -principal -absname -w +a-4-9-41-42-44-45-48 -warn-error A
-bin-annot -safe-string -strict-formats -I utils -I parsing -I typing -I
bytecomp -I middle_end -I middle_end/base_types -I asmcomp -I driver -I
toplevel -c middle_end/simplify_boxed_integer_ops.ml
File "/usr/ports/lang/ocaml/work/ocaml-4.05.0/_none_", line 1:
Warning 58: no cmx file was found in path for module Compilenv, and its
interface was not compiled with -opaque
boot/ocamlrun ./ocamlopt -g -nostdlib -I stdlib -I otherlibs/dynlink
-strict-sequence -principal -absname -w +a-4-9-41-42-44-45-48 -warn-error A
-bin-annot -safe-string -strict-formats -I utils -I parsing -I typing -I
bytecomp -I middle_end -I middle_end/base_types -I asmcomp -I driver -I
toplevel -c middle_end/simplify_primitives.ml
File "/usr/ports/lang/ocaml/work/ocaml-4.05.0/asmcomp/selection.ml", line 1:
Error: Some fatal warnings were triggered (1 occurrences)
gmake[4]: *** [Makefile:1270: asmcomp/selection.cmx] Error 2
gmake[4]: *** Waiting for unfinished jobs....
gmake[4]: Leaving directory '/usr/ports/lang/ocaml/work/ocaml-4.05.0'
gmake[3]: *** [Makefile:464: opt.opt] Error 2
gmake[3]: Leaving directory '/usr/ports/lang/ocaml/work/ocaml-4.05.0'
gmake[2]: *** [Makefile:531: world.opt] Error 2
gmake[2]: Leaving directory '/usr/ports/lang/ocaml/work/ocaml-4.05.0'
*** [do-build] Error code 1

make[1]: stopped in /usr/ports/lang/ocaml
1 error

make[1]: stopped in /usr/ports/lang/ocaml
*** [stage] Error code 2

make: stopped in /usr/ports/lang/ocaml
1 error

make: stopped in /usr/ports/lang/ocaml

If I continue without -j, ld fails with a similar error:
ld: error: relocation R_AARCH64_LDST64_ABS_LO12_NC cannot be used against
symbol camlUnix; recompile with -fPIC

Note: -fPIC is enabled.

I am stuck, can someone suggest how to proceed? Thank you.

BR,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.