Skip to content

OCaml 4.13.1 fails to compile on Alpine / RISC-V #10957

@kit-ty-kate

Description

@kit-ty-kate

OCaml 4.13.1 segfaults during the compilation process on Alpine/riscv64

../../ocamlc.opt -g -nostdlib -I ../../stdlib -c -for-pack Dynlink_compilerlibs -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66-70 -warn-error +A -bin-annot -safe-string -strict-formats -I byte \
          -I dynlink_compilerlibs -o dynlink_compilerlibs/binutils.cmo dynlink_compilerlibs/binutils.ml
[..]
make[4]: *** [Makefile:181: dynlink_compilerlibs/binutils.cmo] Segmentation fault
make[4]: *** Waiting for unfinished jobs....

See https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/30066 for details.

From what I can see they only do the equivalent of:

./configure CC=gcc AS="gcc -c" ASPP="gcc -c"
make world.opt

and have the following patch:

--- a/configure	2021-02-24 13:49:29.000000000 +0000
+++ b/configure	2021-09-25 17:08:37.549751090 +0000
@@ -14487,17 +14487,23 @@ fi
 # e.g. Ubuntu >= 17.10 for i386, which uses the glibc dynamic loader.

 case $arch in #(
-  amd64|s390x|none) :
+  amd64|aarch64|s390x|none) :
     # ocamlopt generates PIC code or doesn't generate code at all
-     ;; #(
+    ;; #(
   *) :
     case $host in #(
-  # expected to match "*-linux-musl" as well as "*-linux-musleabi*"
-    *-linux-musl*) :
-    # Alpine and other musl-based Linux distributions
-       common_cflags="-no-pie $common_cflags" ;; #(
-  *) :
-     ;;
+      i?86-*-linux-musl*) :
+        # Alpine and other musl-based Linux distributions, 32bit x86,
+        # disable DT_TEXTREL, see https://github.com/ocaml/ocaml/issues/9800
+        common_cflags="-Wl,-z,notext -no-pie $common_cflags"
+        mksharedlib="$mksharedlib -Wl,-z,notext"
+        mkmaindll="$mkmaindll -Wl,-z,notext";; #(
+      # expected to match "*-linux-musl" as well as "*-linux-musleabi*"
+      *-linux-musl*) :
+        # Alpine and other musl-based Linux distributions
+        common_cflags="-no-pie $common_cflags" ;; #(
+      *) :
+      ;;
 esac ;;
 esac

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions