Ocaml 4.12.1 build error on latest Ubuntu (21.10)

Hello guys,

It’s pretty strange, I’ve got a big bad bug when compiling ocaml 4.12.1 (via opam or from fresh, genuine INRIA tarball) which I haven’t seen reported here or on the caml mailing list of INRIA.

I’ve tried using opam or tarball, gcc 11.2.0 or clang 13 (4 tests, all fails at the same place)

Here it is:

#=== ERROR while compiling ocaml-base-compiler.4.12.1 =========================#
# context     2.0.8 | linux/x86_64 |  | https://opam.ocaml.org#7247859e
# path        ~/.opam/4.12.1/.opam-switch/build/ocaml-base-compiler.4.12.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build make -j1
# exit-code   2
# env-file    ~/.opam/log/ocaml-base-compiler-1931-c61e7b.env
# output-file ~/.opam/log/ocaml-base-compiler-1931-c61e7b.out
### output ###
# [...]
# gcc -c -O2 -fno-strict-aliasing -fwrapv -Wall -Wdeclaration-after-statement -fno-common -fexcess-precision=standard -fno-tree-vrp -ffunction-sections -g  -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE   -DCAMLDLLIMPORT= -DNATIVE_CODE -DTARGET_amd64 -DMODEL_default -DSYS_linux   -o signals.n.o signals.c
# gcc -c -O2 -fno-strict-aliasing -fwrapv -Wall -Wdeclaration-after-statement -fno-common -fexcess-precision=standard -fno-tree-vrp -ffunction-sections -g  -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE   -DCAMLDLLIMPORT= -DNATIVE_CODE -DTARGET_amd64 -DMODEL_default -DSYS_linux   -o signals_nat.n.o signals_nat.c
# signals_nat.c:184:13: error: variably modified ‘sig_alt_stack’ at file scope
#   184 | static char sig_alt_stack[SIGSTKSZ];
#       |             ^~~~~~~~~~~~~
# make[3]: *** [Makefile:367: signals_nat.n.o] Error 1
# make[3]: Leaving directory '/home/philippe/.opam/4.12.1/.opam-switch/build/ocaml-base-compiler.4.12.1/runtime'
# make[2]: *** [Makefile:765: makeruntimeopt] Error 2
# make[2]: Leaving directory '/home/philippe/.opam/4.12.1/.opam-switch/build/ocaml-base-compiler.4.12.1'
# make[1]: *** [Makefile:215: opt.opt] Error 2
# make[1]: Leaving directory '/home/philippe/.opam/4.12.1/.opam-switch/build/ocaml-base-compiler.4.12.1'
# make: *** [Makefile:275: world.opt] Error 2

now gcc -v:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.2.0-7ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2)

Do have I a problem on my ubuntu box or is it a not yet noticed failure?
Thanks for your time, regards.

Neither, this problem was introduced in upstream glibc, see the discussion at Dynamically allocate the alternate signal stack by xavierleroy · Pull Request #10266 · ocaml/ocaml · GitHub. The fix is included in 4.13.

Cheers,
Nicolas

1 Like

OK, thank you for the hint!