Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 566006 - dev-lang/ocaml-4.02.3[ocamlopt] fails to build on musl
Summary: dev-lang/ocaml-4.02.3[ocamlopt] fails to build on musl
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo Team for the ML programming language family
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-17 04:34 UTC by Justin Keogh
Modified: 2021-01-17 17:40 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
/var/tmp/portage/dev-lang/ocaml-4.02.3/temp/build.log (build.log,245.11 KB, text/plain)
2015-11-17 04:34 UTC, Justin Keogh
Details
emerge --info '=dev-lang/ocaml-4.02.3::gentoo' (emerge_info,5.64 KB, text/plain)
2015-11-17 04:35 UTC, Justin Keogh
Details
emerge -pqv '=dev-lang/ocaml-4.02.3::gentoo' (emerge_pqv,199 bytes, text/plain)
2015-11-17 04:38 UTC, Justin Keogh
Details
/var/tmp/portage/dev-lang/ocaml-4.02.3/temp/environment (environment,93.48 KB, text/plain)
2015-11-17 04:39 UTC, Justin Keogh
Details
build.log with "emake world -n" (ocaml-4.02.3_build.log_with_emake_world_-n,135.72 KB, text/plain)
2015-11-18 03:34 UTC, Justin Keogh
Details
Proposed patch against ocaml-4.02.3 (ocaml-4.02.3-configure.patch,523 bytes, patch)
2015-11-18 06:51 UTC, Felix Janda
Details | Diff
build.log with "emake world -n" and patch 417262 (ocaml-4.02.3_build.log_with_emake_world_-n_and_patch_417262,153.14 KB, text/plain)
2015-11-18 19:10 UTC, Justin Keogh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Keogh 2015-11-17 04:34:34 UTC
Created attachment 417174 [details]
/var/tmp/portage/dev-lang/ocaml-4.02.3/temp/build.log

$ emerge dev-lang/ocaml

fails with:
make otherlibrariesopt ocamltoolsopt ocamlbuild.native
make[1]: Entering directory '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3'
for i in unix str num dynlink bigarray systhreads threads; do \
  (cd otherlibs/$i; make allopt) || exit $?; \
done
make[2]: Entering directory '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3/otherlibs/unix'
../../boot/ocamlrun ../../ocamlopt -nostdlib -I ../../stdlib -c -w +33..39 -warn-error A -bin-annot -g -safe-string -nolabels unix.ml
../../boot/ocamlrun ../../ocamlopt -nostdlib -I ../../stdlib -c -w +33..39 -warn-error A -bin-annot -g -safe-string -nolabels unixLabels.ml
../../boot/ocamlrun ../../tools/ocamlmklib -o unix -oc unix -ocamlopt '../../boot/ocamlrun ../../ocamlopt -nostdlib -I ../../stdlib' -linkall \
         unix.cmx unixLabels.cmx 
../../boot/ocamlrun ../../ocamlopt -nostdlib -I ../../stdlib -shared -o unix.cmxs -I . unix.cmxa
sh: -W: invalid option
Usage:  sh [GNU long option] [option] ...
        sh [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --rcfile
        --restricted
        --verbose
        --version
Shell options:
        -ilrsD or -c command or -O shopt_option         (invocation only)
        -abefhkmnptuvxBCHP or -o option
File "caml_startup", line 1:
Error: Error during linking
../Makefile.shared:55: recipe for target 'unix.cmxs' failed
make[2]: *** [unix.cmxs] Error 2
make[2]: Leaving directory '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3/otherlibs/unix'
Makefile:763: recipe for target 'otherlibrariesopt' failed
make[1]: *** [otherlibrariesopt] Error 2
make[1]: Leaving directory '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3'
Makefile:261: recipe for target 'opt' failed
make: *** [opt] Error 2
 * ERROR: dev-lang/ocaml-4.02.3::gentoo failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=dev-lang/ocaml-4.02.3::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-lang/ocaml-4.02.3::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/dev-lang/ocaml-4.02.3/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-lang/ocaml-4.02.3/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3'
 * S: '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3'

 * Messages for package dev-lang/ocaml-4.02.3:

 * Ocaml generates its own native asm, you're using a PIE compiler
 * We have appended -nopie to ocaml build options
 * because linking an executable with pie while the objects are not pic will not work
 * ERROR: dev-lang/ocaml-4.02.3::gentoo failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=dev-lang/ocaml-4.02.3::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-lang/ocaml-4.02.3::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/dev-lang/ocaml-4.02.3/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-lang/ocaml-4.02.3/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3'
 * S: '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3'

Using musl stage3: http://distfiles.gentoo.org/experimental/amd64/musl/stage3-amd64-musl-hardened-20151104.tar.bz2

Full build log and env attached.

Reproducible: Always (same result with MAKEOPTS="-j1")
Comment 1 Justin Keogh 2015-11-17 04:35:41 UTC
Created attachment 417176 [details]
emerge --info '=dev-lang/ocaml-4.02.3::gentoo'
Comment 2 Justin Keogh 2015-11-17 04:38:14 UTC
Created attachment 417178 [details]
emerge -pqv '=dev-lang/ocaml-4.02.3::gentoo'
Comment 3 Justin Keogh 2015-11-17 04:39:15 UTC
Created attachment 417180 [details]
/var/tmp/portage/dev-lang/ocaml-4.02.3/temp/environment
Comment 4 Justin Keogh 2015-11-17 05:44:49 UTC
USE="$USE -ocamlopt" emerge dev-lang/ocaml compiles OK

USE="$USE ocamlopt" emerge dev-lang/ocaml fails
Comment 5 Justin Keogh 2015-11-17 22:43:35 UTC
This blocks net-misc/unison because:

The following USE changes are necessary to proceed:
 (see "package.use" in the portage(5) man page for more details)
# required by net-misc/unison-2.48.3::gentoo
# required by unison (argument)
>=dev-lang/ocaml-4.02.3 ocamlopt
Comment 6 Justin Keogh 2015-11-18 03:32:20 UTC
Changing "emake world" to "emake world -n" in src_compile() of /usr/portage/dev-lang/ocaml/ocaml-4.02.3.ebuild results in a different failure: 

../byterun/caml/instruct.h > opnames.ml
../boot/ocamlrun ../boot/ocamlc -nostdlib -I ../boot -c -strict-sequence -w +27+32..39 -warn-error A -safe-string -I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../asmcomp -I ../driver -I ../toplevel opnames.ml
../boot/ocamlrun ../boot/ocamlc -nostdlib -I ../boot -c -strict-sequence -w +27+32..39 -warn-error A -safe-string -I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../asmcomp -I ../driver -I ../toplevel ../utils/tbl.mli
make[4]: *** No rule to make target '../bytecomp/opcodes.cmo', needed by 'dumpobj.cmo'.  Stop.
make[4]: Leaving directory '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3/tools'
Makefile:720: recipe for target 'ocamltools' failed
make[3]: *** [ocamltools] Error 2
make[3]: Leaving directory '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3'
Makefile:206: recipe for target 'coreall' failed
make[2]: *** [coreall] Error 2
make[2]: Leaving directory '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3'
Makefile:129: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3'
Makefile:137: recipe for target 'world' failed
make: *** [world] Error 2
 * ERROR: dev-lang/ocaml-4.02.3::gentoo failed (compile phase):
 *   emake failed

full build log attached as ocaml-4.02.3_build.log_with_emake_world_-n
Comment 7 Justin Keogh 2015-11-18 03:34:00 UTC
Created attachment 417254 [details]
build.log with "emake world -n"
Comment 8 Justin Keogh 2015-11-18 03:43:04 UTC
This appears to be musl specific, I can not reproduce it on a very similar (same config files, different CHOST) glibc system.
Comment 9 Felix Janda 2015-11-18 06:35:30 UTC
How does the "Configuration summary" look on the glibc system? Are
shared libraries also not supported?

I've just tried compiling on musl (outside of emerge). The configure
output contains

dlopen() found.
Dynamic loading of shared libraries is supported.
mmap() found.

I think it would be good to investigate why you don't have the second
line.
Comment 10 Felix Janda 2015-11-18 06:51:33 UTC
Created attachment 417262 [details, diff]
Proposed patch against ocaml-4.02.3

The configure script has some intricate knowledge about which targets
support shared libraries but has not heard that non-gnu linux might
support them as well...

Please try compiling with this patch.
Comment 11 Justin Keogh 2015-11-18 19:09:02 UTC
Same error with patch applied (I manually verified that /var/tmp/portage/dev-lang/ocaml-4.02.3/work/ocaml-4.02.3/configure was properly patched in src_prepare()). The good news is ./configure now shows the 'Dynamic loading of shared libraries is supported' line.


setlocale() and <locale.h> found.
dlopen() found.
Dynamic loading of shared libraries is supported.
mmap() found.
pwrite() found
stat() supports nanosecond precision.
gethostbyname_r() found (with 6 arguments).
gethostbyaddr_r() found (with 8 arguments).
mkstemp() found
nice() found
Replay debugger supported.
System stack overflow can be detected.
POSIX threads library supported.
Options for linking with POSIX threads: -lpthread
sigwait() found
Bytecode threads library supported.
[WARNING] Cannot compile X11 program.
[WARNING] X11 not found, the "graph" library will not be supported.
[WARNING] BFD library not found, 'objinfo' will be unable to display info on .cmxs files.
Assembler supports CFI

** Configuration summary **

Directories where OCaml will be installed:
        binaries.................. /usr/bin
        standard library.......... /usr/lib/ocaml
        manual pages.............. /usr/share/man (with extension .1)
Configuration for the bytecode compiler:
        C compiler used........... x86_64-gentoo-linux-musl-gcc
        options for compiling..... -march=native -O2 -pipe -O -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
        options for linking....... -Wl,-O1 -Wl,--as-needed -nopie  -Wl,-E  -lm  -lcurses -lpthread
        shared libraries are supported
        options for compiling..... -O -fPIC -march=native -O2 -pipe -O -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
        command for building...... x86_64-gentoo-linux-musl-gcc -shared -Wl,-O1 -Wl,--as-needed -nopie -o lib.so -Wl,-rpath,/a/path objs
Configuration for the native-code compiler:
        hardware architecture..... amd64
        OS variant................ linux
        C compiler used........... x86_64-gentoo-linux-musl-gcc
        options for compiling..... -march=native -O2 -pipe -O  -D_FILE_OFFSET_BITS=64 -D_REENTRANT
        options for linking....... -Wl,-O1 -Wl,--as-needed -nopie   -lm
        assembler ................ x86_64-gentoo-linux-musl-as
        preprocessed assembler ... x86_64-gentoo-linux-musl-gcc -c
        assembler supports CFI ... yes
        with frame pointers....... no
        naked pointers forbidden.. no
        native dynlink ........... true
        profiling with gprof ..... supported
Source-level replay debugger: supported
Additional libraries supported:
        unix str num dynlink bigarray systhreads threads
Configuration for the "num" library:
        target architecture ...... amd64 (asm level 1)
The "graph" library: not supported

** OCaml configuration completed successfully **

full build log attached as ocaml-4.02.3_build.log_with_emake_world_-n_and_patch_417262
Comment 12 Justin Keogh 2015-11-18 19:10:56 UTC
Created attachment 417310 [details]
build.log with "emake world -n" and patch 417262
Comment 13 Felix Janda 2015-11-19 01:58:38 UTC
Is there any reasoning for changing "emake world" to "emake world -n"?
I guess it just breaks everything.
Comment 14 Justin Keogh 2015-11-19 08:17:13 UTC
Yep! I thought it was just extra verbose but no: man make says "Print the commands that would be executed, but do not execute them (except in certain circumstances).". Oops.

Your patch fixes it. I double checked. Without -n, the compile fails with the orig "sh: -W: invalid option".
Comment 15 Felix Janda 2016-04-24 17:41:30 UTC
Submitted the patch upstream:

https://github.com/ocaml/ocaml/pull/558
Comment 16 Felix Janda 2017-03-07 13:09:37 UTC
The patch is now upstream:

https://github.com/ocaml/ocaml/commit/2ddcd4de9b5f4616f9790a26e6e56489366c9137

Could it be added to the in tree ebuilds?
Comment 17 Alexis Ballier gentoo-dev 2017-03-13 10:17:44 UTC
(In reply to Felix Janda from comment #16)
> The patch is now upstream:
> 
> https://github.com/ocaml/ocaml/commit/
> 2ddcd4de9b5f4616f9790a26e6e56489366c9137
> 
> Could it be added to the in tree ebuilds?

That will be in 4.05 I think. I'd prefer not touching anything in 4.04 now that it is stable.
Comment 18 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-01-17 17:40:52 UTC
Is this still an issue?