View Issue Details

IDProjectCategoryView StatusLast Update
0003931OpenFOAMBugpublic2025-08-23 08:13
Reporterningli Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
PlatformGNU/LinuxOSRHEL/CentOS/Rocky LinuxOS Version8.x 9.x
Summary0003931: OpenFOAM-10 undefined symbols while compiling with Clang/AOCC
DescriptionWe experienced link time errors while building OpenFOAM-10 with the Clang compiler or the AOCC compiler which is based upon Clang. This applies to both vanilla Clang (version 13/14 assessed) and AOCC 3.2/4.0.

A typical error looks like:
make[1]: Leaving directory '/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/applications/solvers/basic'
wmake combustion
make[1]: Entering directory '/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/applications/solvers/combustion'
wmake chemFoam
make[2]: Entering directory '/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/applications/solvers/combustion/chemFoam'
clang++ -std=c++14 -m64 -pthread -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=64 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-undefined-var-template -O3 -march=znver3 -DNoRepository -ftemplate-depth-100 -I/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/src/physicalProperties/lnInclude -I/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/src/thermophysicalModels/specie/lnInclude -I/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/src/thermophysicalModels/reactionThermo/lnInclude -I/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/src/thermophysicalModels/basic/lnInclude -I/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/src/ODE/lnInclude -I/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/src/thermophysicalModels/chemistryModel/lnInclude -I/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/src/finiteVolume/lnInclude -I/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/src/meshTools/lnInclude -IlnInclude -I. -I/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/src/OpenFOAM/lnInclude -I/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/src/OSspecific/POSIX/lnInclude -fPIC -L/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/platforms/linux64ClangDPInt64Opt/lib/dummy -lPstream /home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/platforms/linux64ClangDPInt64Opt/applications/solvers/combustion/chemFoam/chemFoam.o -L/home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/platforms/linux64ClangDPInt64Opt/lib \
    -lchemistryModel -lfiniteVolume -lmeshTools -lOpenFOAM -ldl \
     -lm -o /home/ningli12/apps/OpenFOAM/org-10/AOCC+OpenMPI/OpenFOAM-10/platforms/linux64ClangDPInt64Opt/bin/chemFoam
ld.lld: error: undefined symbol: Foam::fluidReactionThermo::New(Foam::fvMesh const&, Foam::word const&)
>>> referenced by chemFoam.C

The key problem here is that the LLVM 'lld' linker do not handle indirect shared library dependencies.

A workaround is to use the GNU system linker by specifying '-Xlinker --add-needed -fuse-ld=ld' in 'LINKEXE' as '--add-needed' (also the equivalent '--copy-dt-needed-entries' flag) has the effect of recursively searching those indirect referenced shared libraries. However, this only works if 'ld.bfd' is the system linker. 'ld.gold' and 'lld' do not support this function.

Alternatively I would have to patch the Make/options files of about 25 solvers/utilities with additional -l flags to get them linked properly with 'ld.gold' or 'lld'.

I am aware of the decade old discussions in https://bugs.openfoam.org/view.php?id=685 on a similar subject. Do you have new opinions on how this should be dealt with after all these years?
Steps To ReproduceFollowing the standard build procedure and using the rules defined in OpenFOAM-10/wmake/rules/linux64Clang/ is just fine. I had to add -L\$(FOAM_LIBBIN)\/dummy -lPstream to the LINKEXE flag too to avoid problems building some solvers.
TagsNo tags attached.

Activities

LiJixiao

2025-08-23 07:52

reporter   ~0013652

I've also worked around this problem with AOCC. If linker doesn't handle indirect shared library deps, we have to add required libs into `Make/options`. I've worked around v12 and v13, but it formed an ugly huge patch that almost every `Make/options` files are modified.

henry

2025-08-23 08:13

manager   ~0013653

We have not had any problems compiling with Clang and don't support ld.gold
If you are having problems with Clang/AOCC try using gcc.

Issue History

Date Modified Username Field Change
2022-11-11 22:05 ningli New Issue
2025-08-23 07:52 LiJixiao Note Added: 0013652
2025-08-23 08:13 henry Assigned To => henry
2025-08-23 08:13 henry Status new => closed
2025-08-23 08:13 henry Resolution open => no change required
2025-08-23 08:13 henry Note Added: 0013653