dune
dune copied to clipboard
How are compiled C++ stubs?
I’m trying to build software that use dune
as build system and have C++ stubs. And compilation fails. I’ve already reported https://github.com/AltGr/ocaml-mccs/issues/12 and https://github.com/janestreet/re2/issues/21.
My understanding is that there are C++ files which must be compiled by a C++ compiler; and dune
asks the OCaml compiler whether it knows about a C compiler and uses the result. Is my understanding correct? Is that supposed to work? Can I manually override this to tell dune
about a C++ compiler (e.g., to trust the CXX
environment variable)?
It's not currently possible, but it seems worth adding support for it. Ideally we want the following:
- a way for the user to set the C++ when compiling one or many projects
- a way for the developer of a project to set once and for all the C++ compiler for their project, in case they use the specific features of a particular compiler
- a way to set the default C++ compiler when compiling dune
- have a hardcoded list of common C++ compilers and choose the appropriate default when none is specified. So that most of the time things just work without configuration needed
a way for the developer of a project to set once and for all the C++ compiler for their project, in case they use the specific features of a particular compiler
Just a note: but I think this customization should again be scoped using env
(or something similar).
Agreed
This is still broken: it is impossible to build opam
with mccs
enabled, since dune
uses C compiler for C++ source:
$ (cd _build/default/src_ext/mccs/src && /opt/local/bin/gcc-mp-13 -arch ppc -O2 -fno-strict-aliasing -fwrapv -pthread -pipe -Os -arch ppc -I . -DUSEGLPK -g -I /opt/local/lib/ocaml -I ../../cudf/lib -I ../../extlib/src -I glpk -I ../../stdlib-shims/src -o changed_criteria.o -c changed_criteria.cpp)
$ (cd _build/default/src_ext/mccs/src && /opt/local/bin/gcc-mp-13 -arch ppc -O2 -fno-strict-aliasing -fwrapv -pthread -pipe -Os -arch ppc -I . -DUSEGLPK -g -I /opt/local/lib/ocaml -I ../../cudf/lib -I ../../extlib/src -I glpk -I ../../stdlib-shims/src -o count_criteria.o -c count_criteria.cpp)
$ (cd _build/default/src_ext/mccs/src && /opt/local/bin/gcc-mp-13 -arch ppc -O2 -fno-strict-aliasing -fwrapv -pthread -pipe -Os -arch ppc -I . -DUSEGLPK -g -I /opt/local/lib/ocaml -I ../../cudf/lib -I ../../extlib/src -I glpk -I ../../stdlib-shims/src -o cudf_reductions.o -c cudf_reductions.cpp)
$ (cd _build/default/src_ext/mccs/src && /opt/local/bin/gcc-mp-13 -arch ppc -O2 -fno-strict-aliasing -fwrapv -pthread -pipe -Os -arch ppc -I . -DUSEGLPK -g -I /opt/local/lib/ocaml -I ../../cudf/lib -I ../../extlib/src -I glpk -I ../../stdlib-shims/src -o constraint_generation.o -c constraint_generation.cpp)
$ (cd _build/default/src_ext/mccs/src && /opt/local/bin/gcc-mp-13 -arch ppc -O2 -fno-strict-aliasing -fwrapv -pthread -pipe -Os -arch ppc -I . -DUSEGLPK -g -I /opt/local/lib/ocaml -I ../../cudf/lib -I ../../extlib/src -I glpk -I ../../stdlib-shims/src -o lexagregate_combiner.o -c lexagregate_combiner.cpp)
$ (cd _build/default/src_ext/mccs/src && /opt/local/bin/gcc-mp-13 -arch ppc -O2 -fno-strict-aliasing -fwrapv -pthread -pipe -Os -arch ppc -I . -DUSEGLPK -g -I /opt/local/lib/ocaml -I ../../cudf/lib -I ../../extlib/src -I glpk -I ../../stdlib-shims/src -o cudf_tools.o -c cudf_tools.cpp)
$ (cd _build/default/src_ext/mccs/src && /opt/local/bin/gcc-mp-13 -arch ppc -O2 -fno-strict-aliasing -fwrapv -pthread -pipe -Os -arch ppc -I . -DUSEGLPK -g -I /opt/local/lib/ocaml -I ../../cudf/lib -I ../../extlib/src -I glpk -I ../../stdlib-shims/src -o glpk_solver.o -c glpk_solver.cpp)
$ (cd _build/default/src_ext/mccs/src && /opt/local/bin/gcc-mp-13 -arch ppc -O2 -fno-strict-aliasing -fwrapv -pthread -pipe -Os -arch ppc -I . -DUSEGLPK -g -I /opt/local/lib/ocaml -I ../../cudf/lib -I ../../extlib/src -I glpk -I ../../stdlib-shims/src -o lp_solver.o -c lp_solver.cpp)
$ (cd _build/default/src_ext/mccs/src && /opt/local/bin/gcc-mp-13 -arch ppc -O2 -fno-strict-aliasing -fwrapv -pthread -pipe -Os -arch ppc -I . -DUSEGLPK -g -I /opt/local/lib/ocaml -I ../../cudf/lib -I ../../extlib/src -I glpk -I ../../stdlib-shims/src -o new_criteria.o -c new_criteria.cpp)
$ (cd _build/default/src_ext/mccs/src && /opt/local/bin/gcc-mp-13 -arch ppc -O2 -fno-strict-aliasing -fwrapv -pthread -pipe -Os -arch ppc -I . -DUSEGLPK -g -I /opt/local/lib/ocaml -I ../../cudf/lib -I ../../extlib/src -I glpk -I ../../stdlib-shims/src -o mccscudf.o -c mccscudf.cpp)
Unsurprisingly, that fails:
File "src/client/dune", line 27, characters 15-23:
27 | (name opamMain)
^^^^^^^^
Undefined symbols:
"__Unwind_Resume", referenced from:
__Z19call_mccs_protected6SolverPciP11CUDFproblem in libmccs_stubs.a(mccs_stubs.o)
_call_solver in libmccs_stubs.a(mccs_stubs.o)
__Z9ml2c_vpkgP16Virtual_packagesl in libmccs_stubs.a(mccs_stubs.o)
__Z13ml2c_propertyP16Virtual_packagesPSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEP12CUDFPropertySt4lessIS7_ESaISt4pairIKS7_S9_EEEl in libmccs_stubs.a(mccs_stubs.o)
__Z16ml2c_propertydefP16Virtual_packagesl in libmccs_stubs.a(mccs_stubs.o)
__Z12ml2c_packageP16Virtual_packagesPSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEP12CUDFPropertySt4lessIS7_ESaISt4pairIKS7_S9_EEERil in libmccs_stubs.a(mccs_stubs.o)
__Z20ml2c_propertydeflistB5cxx11P16Virtual_packagesl in libmccs_stubs.a(mccs_stubs.o)
_gen_problem in libmccs_stubs.a(mccs_stubs.o)
__ZN16Virtual_packages3getEPKc in libmccs_stubs.a(mccs_stubs.o)
__ZN20CUDFVersionedPackageC4EPKci in libmccs_stubs.a(cudf_tools.o)
__ZN18CUDFVirtualPackageC4EPKci in libmccs_stubs.a(cudf_tools.o)
__Z19get_criteria_lambdaPcRjc in libmccs_stubs.a(mccscudf.o)
__Z26get_criteria_property_namePcRj in libmccs_stubs.a(mccscudf.o)
__Z36get_criteria_property_name_and_scopePcRjR11Count_scope in libmccs_stubs.a(mccscudf.o)
__Z16process_criteriaPcRjbPSt6vectorIP17abstract_criteriaSaIS3_EE in libmccs_stubs.a(mccscudf.o)
__Z9call_mccs6SolverPciP11CUDFproblemPP15abstract_solver in libmccs_stubs.a(mccscudf.o)
__ZN9lp_solver13add_objectiveEv in libmccs_stubs.a(lp_solver.o)
__Z20compute_reduced_CUDFP11CUDFproblem in libmccs_stubs.a(cudf_reductions.o)
__ZNSt8_Rb_treeIySt4pairIKySt6vectorIP20CUDFVersionedPackageSaIS4_EEESt10_Select1stIS7_ESt4lessIyESaIS7_EE17_M_construct_nodeIJRKS7_EEEvPSt13_Rb_tree_nodeIS7_EDpOT_.isra.0 in libmccs_stubs.a(constraint_generation.o)
__ZNSt8_Rb_treeIySt4pairIKySt6vectorIP20CUDFVersionedPackageSaIS4_EEESt10_Select1stIS7_ESt4lessIyESaIS7_EE7_M_copyILb0ENSD_11_Alloc_nodeEEEPSt13_Rb_tree_nodeIS7_ESI_PSt18_Rb_tree_node_baseRT0_.isra.0 in libmccs_stubs.a(constraint_generation.o)
__ZNSt8_Rb_treeIySt4pairIKySt6vectorIP20CUDFVersionedPackageSaIS4_EEESt10_Select1stIS7_ESt4lessIyESaIS7_EE7_M_copyILb0ENSD_20_Reuse_or_alloc_nodeEEEPSt13_Rb_tree_nodeIS7_ESI_PSt18_Rb_tree_node_baseRT0_.isra.0 in libmccs_stubs.a(constraint_generation.o)
__Z18preprocess_upgradeP11CUDFproblemRiRSt6vectorI14an_upgrade_setSaIS3_EE in libmccs_stubs.a(constraint_generation.o)
__Z20generate_constraintsP11CUDFproblemR15abstract_solverR17abstract_combiner in libmccs_stubs.a(constraint_generation.o)
__ZN11glpk_solver5solveEi in libmccs_stubs.a(glpk_solver.o)
__ZN11glpk_solver13add_objectiveEv in libmccs_stubs.a(glpk_solver.o)
ld: symbol(s) not found
collect2: error: ld returned 1 exit status
File "_none_", line 1:
Error: Error while building custom runtime system
make: *** [build-opam] Error 1
@rgrinberg Any chance of addressing this one?
Chances are good only in the long term. I’m a bit swamped with package management work so it’s unlikely I’ll get around to it anytime soon. If you’d like to see this addressed sooner, sending a PR yourself is your main option.
On Feb 20, 2024, at 11:19 PM, Sergey Fedorov @.***> wrote:
@rgrinberg https://github.com/rgrinberg Any chance of addressing this one?
— Reply to this email directly, view it on GitHub https://github.com/ocaml/dune/issues/949#issuecomment-1956031992, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABB56YZ6KXXAG2KAKEWUYTYUWNY5AVCNFSM4FIE7WRKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJVGYYDGMJZHEZA. You are receiving this because you were mentioned.