AOCC link errors for utilities depending on CGAL in OpenFOAM 2306/2312
Summary
When compiling OpenFOAM 2306 or 2312 with the AMD AOCC 4.1 compiler, there are link errors with a few OpenFOAM utilities that depend on CGAL. Specifically, paths to the dependent gmp and mpfr libraries are somehow not properly injected into the build system resulting in failure at link time.
Steps to reproduce
We are seeing this from a Spack build:
spack install -v openfoam@2306%aocc@4.1.0
I am undecided if this is an OpenFOAM issue or if this is an issue with its Spack recipe (so forgive me if this turns out to be the wrong place to file an issue). However, what I can say for sure is this problem did not exist in v2212 and earlier, and it was likely to be introduced by code changes in 74d65ed0. I'd like to have the developers' opinions on this.
Relevant logs and/or images
ld.lld: error: undefined symbol: __gmpq_clear
>>> referenced by surfaceBooleanFeatures.C
>>> /tmp/root/spack-stage/spack-stage-openfoam-2306-temgrqjteus5nqfko72pqyrpz7hu5nre/spack-src/build/li
nux64AmdDPInt32-spack/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.o:(CGAL::Cartesian
KernelFunctors::Construct_point_3>::operator()(CGAL::Return_base_tag, CGAL::Gmpq c
onst&, CGAL::Gmpq const&, CGAL::Gmpq const&) const)
>>> referenced by surfaceBooleanFeatures.C
>>> /tmp/root/spack-stage/spack-stage-openfoam-2306-temgrqjteus5nqfko72pqyrpz7hu5nre/spack-src/build/li
nux64AmdDPInt32-spack/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.o:(CGAL::Cartesian
KernelFunctors::Construct_point_3>::operator()(CGAL::Return_base_tag, CGAL::Gmpq c
onst&, CGAL::Gmpq const&, CGAL::Gmpq const&) const)
>>> referenced by surfaceBooleanFeatures.C
>>> /tmp/root/spack-stage/spack-stage-openfoam-2306-temgrqjteus5nqfko72pqyrpz7hu5nre/spack-src/build/li
nux64AmdDPInt32-spack/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.o:(CGAL::PointC3>::~PointC3())
>>> referenced 549 more times
and repeated many times for other gmp/mpfr symbols
Environment information
- OpenFOAM version : v2312|v2306
- Operating system : tested on rocky 8 linux but should apply to other OS
- Hardware info : not relevant
- Compiler : AOCC 4.1 (based on clang 16.0)
Possible fixes
I don't have a proper fix yet. My workaround is to patch the affected OpenFOAM utilities' Make/options
files and replacing the $(CGAL_LIBS)
there by an actual path containing the proper -L and -l options pointing to cgal/gmp/mpfr installations. Ideally the fix should be done at locations where the value of $(CGAL_LIBS)
gets populated but I don't know how.