opam-repository icon indicating copy to clipboard operation
opam-repository copied to clipboard

ocaml-secondary-compiler.4.08.1-1 fails to compile on FreeBSD

Open kit-ty-kate opened this issue 3 years ago • 6 comments

https://discuss.ocaml.org/t/freebsd-opam-install-dune-fails/8616

cc @dra27

kit-ty-kate avatar Oct 13 '21 10:10 kit-ty-kate

also reported https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259888

The underlying issue seems to be multiple definitions of caml_debug_info in 4.08.1 (and smaller) -- where the ocaml-secondary carries a local patch to add -fno-common to the gcc arguments -- but now this also happens with clang (>= 11).

Since there are other issues with old versions of OCaml, maybe it is a good time to upgrade the "ocaml-secondary-compiler" to 4.13.1?

hannesm avatar Nov 17 '21 10:11 hannesm

I hit this problem as well. I tried modifying the ocaml-secondary-compiler package definition to add -fcommon to the compiler flags for LLVM (like the existing fix-gcc10 patch already does), but then it fails later in the build with:

cc -c -DSYS_freebsd -I../runtime -DMODEL_default -o amd64.o amd64.S || \
{ echo "If your assembler produced syntax errors, it is probably";\
          echo "unhappy with the preprocessor. Check your assembler, or";\
          echo "try producing amd64.o by hand.";\
          exit 2; }
amd64.S:727:9: error: changed section flags for .rodata.cst8, expected: 0x12
        .section .rodata.cst8,"a",@progbits
        ^
amd64.S:727:9: error: changed section entsize for .rodata.cst8, expected: 8
        .section .rodata.cst8,"a",@progbits
        ^

I just changed the package to compile with gcc instead, and didn't have any problems after that. I have no idea whether 4.13.1 fixes the problem in some way. If an upgrade is not imminent, I can debug further and produce a patch for inclusion in opam-repository. Please let me know if that'd be worthwhile and I'll be happy to try and get this issue fixed.

markjdb avatar Aug 26 '22 19:08 markjdb

Looks like the native FreeBSD package for ocaml has a patch for amd64.S: https://github.com/freebsd/freebsd-ports/blob/main/lang/ocaml/files/patch-asmrun_amd64.S

markjdb avatar Aug 26 '22 19:08 markjdb

Note that ocaml-secondary-compiler is just necessary for dune on OCaml < 4.08, above it is is not needed anymore so upgrading your compiler to 4.13.1 would "fix" this issue for you as you wouldn't encounter it in the first place

kit-ty-kate avatar Aug 29 '22 11:08 kit-ty-kate

Note that ocaml-secondary-compiler is just necessary for dune on OCaml < 4.08, above it is is not needed anymore so upgrading your compiler to 4.13.1 would "fix" this issue for you as you wouldn't encounter it in the first place

Thanks. Looks like there is some WIP to update the packaged ocaml compiler, but I'm not sure how long it'll take to land (and after that, how long it'll take to become available on stable branches). If a patch for ocaml-secondary-compiler would be welcome in the meantime, I'll work on getting that done.

markjdb avatar Aug 30 '22 16:08 markjdb

Sure, a patch would be welcome

kit-ty-kate avatar Aug 30 '22 16:08 kit-ty-kate