Opened 5 weeks ago

Last modified 4 weeks ago

#70586 new defect

ocaml-bigstringaf does not build if ocaml was built with ccache

Reported by: barracuda156 Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.10.1
Keywords: Cc: pguyot (Paul Guyot), pmetzger (Perry E. Metzger)
Port: ocaml-bigstringaf, ocaml

Description

Is it that ocaml itself should not be built with ccache active? I had to rebuild it in result to make this work.

--->  Building ocaml-bigstringaf
Executing:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_ocaml_ocaml-bigstringaf/ocaml-bigstringaf/work/bigstringaf-0.10.0" && /opt/local/bin/dune build -j 6 --root=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_ocaml_ocaml-bigstringaf/ocaml-bigstringaf/work/bigstringaf-0.10.0 --profile=release --ignore-promoted-rules --no-config --only-packages=bigstringaf --default-target=@install @install 
File ".dune/ccomp/_unknown_", line 1, characters 0-0:
ccache: invalid option -- E
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_ocaml_ocaml-bigstringaf/ocaml-bigstringaf/work/bigstringaf-0.10.0" && /opt/local/bin/dune build -j 6 --root=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_ocaml_ocaml-bigstringaf/ocaml-bigstringaf/work/bigstringaf-0.10.0 --profile=release --ignore-promoted-rules --no-config --only-packages=bigstringaf --default-target=@install @install 
Exit code: 1
Error: Failed to build ocaml-bigstringaf: command execution failed

Change History (9)

comment:1 Changed 5 weeks ago by pmetzger (Perry E. Metzger)

I'm not sure I entirely understand what the circumstances here were. Can you explain how to reproduce the problem?

comment:2 Changed 5 weeks ago by ryandesign (Ryan Carsten Schmidt)

To reproduce, install the ccache port, set configureccache yes in macports.conf, build the ocaml port from source, then try to build the ocaml-bigstringaf port from source.

There are tons of files installed by the ocaml port that contain the fact that ccache was used to build the port:

% port -q contents ocaml | xargs grep ccache
Binary file /opt/local/bin/ocaml matches
Binary file /opt/local/bin/ocamlc matches
Binary file /opt/local/bin/ocamlc.byte matches
Binary file /opt/local/bin/ocamlc.opt matches
Binary file /opt/local/bin/ocamlcmt matches
Binary file /opt/local/bin/ocamlcp matches
Binary file /opt/local/bin/ocamlcp.byte matches
Binary file /opt/local/bin/ocamlcp.opt matches
Binary file /opt/local/bin/ocamldebug matches
Binary file /opt/local/bin/ocamldep matches
Binary file /opt/local/bin/ocamldep.byte matches
Binary file /opt/local/bin/ocamldep.opt matches
Binary file /opt/local/bin/ocamldoc matches
Binary file /opt/local/bin/ocamldoc.opt matches
Binary file /opt/local/bin/ocamlmklib matches
Binary file /opt/local/bin/ocamlmklib.byte matches
Binary file /opt/local/bin/ocamlmklib.opt matches
Binary file /opt/local/bin/ocamlmktop matches
Binary file /opt/local/bin/ocamlmktop.byte matches
Binary file /opt/local/bin/ocamlmktop.opt matches
Binary file /opt/local/bin/ocamlobjinfo matches
Binary file /opt/local/bin/ocamlobjinfo.byte matches
Binary file /opt/local/bin/ocamlobjinfo.opt matches
Binary file /opt/local/bin/ocamlopt matches
Binary file /opt/local/bin/ocamlopt.byte matches
Binary file /opt/local/bin/ocamlopt.opt matches
Binary file /opt/local/bin/ocamloptp matches
Binary file /opt/local/bin/ocamloptp.byte matches
Binary file /opt/local/bin/ocamloptp.opt matches
Binary file /opt/local/bin/ocamlprof matches
Binary file /opt/local/bin/ocamlprof.byte matches
Binary file /opt/local/bin/ocamlprof.opt matches
/opt/local/lib/ocaml/Makefile.config:CC=ccache /usr/bin/clang -arch x86_64
/opt/local/lib/ocaml/Makefile.config:CPP=ccache /usr/bin/clang -arch x86_64 -E
/opt/local/lib/ocaml/Makefile.config:MKDLL=ccache /usr/bin/clang -arch x86_64 -shared                    -flat_namespace -undefined suppress -Wl,-no_compact_unwind                    $(LDFLAGS)
/opt/local/lib/ocaml/Makefile.config:MKMAINDLL=ccache /usr/bin/clang -arch x86_64 -shared                    -flat_namespace -undefined suppress -Wl,-no_compact_unwind                    $(LDFLAGS)
Binary file /opt/local/lib/ocaml/compiler-libs/config.cmt matches
Binary file /opt/local/lib/ocaml/compiler-libs/config.cmx matches
Binary file /opt/local/lib/ocaml/compiler-libs/ocamlcommon.a matches
Binary file /opt/local/lib/ocaml/compiler-libs/ocamlcommon.cma matches
Binary file /opt/local/lib/ocaml/dynlink.a matches
Binary file /opt/local/lib/ocaml/dynlink.cma matches
Binary file /opt/local/lib/ocaml/dynlink_compilerlibs.cmx matches
Binary file /opt/local/lib/ocaml/expunge matches

This doesn't happen if ccache is not used when building ocaml (e.g. when installing a binary of ocaml from our server).

So there are two problems that need to be fixed.

  1. The ocaml port should excise all of these references to ccache from the installed files.
  2. The ocaml-bigstringaf port, and perhaps all ports that use ocaml, need to build using the compiler MacPorts tells them to build with, not the compiler that ocaml was built with.

comment:3 Changed 4 weeks ago by pmetzger (Perry E. Metzger)

The OCaml port doesn't reference ccache in its Portfile. I presume this is a problem caused by someone installing ccache and ccache somehow infecting the OCaml binary anyway?

comment:4 Changed 4 weeks ago by pmetzger (Perry E. Metzger)

(And by "compiler" here, you mean the C compiler and not the OCaml compiler? OCaml is a compiler.)

comment:5 Changed 4 weeks ago by ryandesign (Ryan Carsten Schmidt)

When you set configureccache yes in macports.conf, MacPorts tells ports to use ccache by modifying the value of configure.cc to be e.g. ccache /usr/bin/clang and of course passes that to the build system in the CC environment variable. A similar problem would arise using configuredistcc yes. ocaml is evidently baking the value of CC into itself somewhere and should not do that.

comment:6 Changed 4 weeks ago by pmetzger (Perry E. Metzger)

I suspect it's doing that in order to have any knowledge of where the C compiler is located; it needs the C compiler sometimes. Do you have suggestions on what a clean way to deal with this would be? It still needs to know what the preferred C compiler is (and probably can't adjust that easily on the fly) but it obviously should not be using ccache. What's the right way to get that information?

comment:7 Changed 4 weeks ago by ryandesign (Ryan Carsten Schmidt)

You could discover using if {${configure.ccache}} and if {${configure.distcc}} whether the user has asked to use ccache or distcc. If so, you can use reinplace to remove the ccache or distcc prefix from wherever it has been baked into ocaml.

comment:8 Changed 4 weeks ago by pguyot (Paul Guyot)

The following seems to work:

if {${configure.ccache}} {
    post-configure {
        reinplace "s|=ccache |=|g" ${worksrcpath}/Makefile.config
    }
}
if {${configure.distcc}} {
    post-configure {
        reinplace "s|=distcc |=|g" ${worksrcpath}/Makefile.config
    }
}

But why do we want to use ccache (or distcc) while building ocaml? Most of the time is spent compiling ocaml libraries...

I would simply do:

configure.ccache    no
configure.distcc    no

BTW, the problem is strictly related to ocaml being built with ccache. ocaml-bigstringaf compiles fine with ccache enabled as long as active ocaml was either built without ccache or with the modifications above.

comment:9 Changed 4 weeks ago by pmetzger (Perry E. Metzger)

I think we should probably disable it in the ocaml port, yes.

Note: See TracTickets for help on using tickets.