Bug 267320 - math/vtk9 9.2 breaks at plugins.qmltypes Undefined symbol "ompi_mpi_comm_world"
Summary: math/vtk9 9.2 breaks at plugins.qmltypes Undefined symbol "ompi_mpi_comm_world"
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Yuri Victorovich
URL: https://gitlab.kitware.com/vtk/vtk/-/...
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-25 03:03 UTC by alt2600
Modified: 2023-06-23 04:51 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (yuri)


Attachments
configure log (22.86 KB, text/plain)
2022-10-25 03:03 UTC, alt2600
no flags Details
patch (433 bytes, patch)
2022-10-26 04:50 UTC, Yuri Victorovich
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description alt2600 2022-10-25 03:03:17 UTC
Created attachment 237597 [details]
configure log

so I tried updating vtk9 with portupgrade, and then deleted and tried to install again. These are the errors I got. not sure how to resolve. I might have cut the message from the 9.1 installed case so I will only attach the fresh build case on a live system, which gave indication that it cannot find mpi symbols while building the qmltypes. I know it failed at the same point, just not sure about if I saw the symbol issue during the upgrade with 9.1 installed. had hoped it was a simple include /usr/local/include kind of issue, but it doesn't appear to be that.

as I look i see the port wants openmpi, but configure maybe is pulling in mpich instead. I thought these were mutually exclusive implementations. I've attached the configure log, I will dig a little more, suggestions appreciated. Not sure I will know the cmake magic for this one. not sure If I got lucky 9.1 worked with mpich, or if the find routines were different in 9.1 and cmake only looked for openmpi.

[ 95% 9226/9642] : && /usr/bin/c++ -fPIC -O2 -pipe -march=westmere -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include  -O2 -pipe -march=westmere -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include  -fstack-protector-strong -shared  -o lib/qml/VTK.9.2/libqmlvtkplugin.so GUISupport/QtQuick/qml/CMakeFiles/qmlvtkplugin.dir/qmlvtkplugin_autogen/mocs_compilation.cpp.o GUISupport/QtQuick/qml/CMakeFiles/qmlvtkplugin.dir/QQmlVTKPlugin.cxx.o  -Wl,-rpath,/usr/ports/math/vtk9/work/.build/lib:/usr/local/lib/qt5:/usr/local/lib:  lib/libvtkGUISupportQtQuick-9.2.so.9.2.2  lib/libvtkGUISupportQt-9.2.so.9.2.2  /usr/local/lib/qt5/libQt5OpenGL.so.5.15.5  /usr/local/lib/qt5/libQt5Widgets.so.5.15.5  /usr/local/lib/qt5/libQt5Gui.so.5.15.5  /usr/local/lib/qt5/libQt5Core.so.5.15.5  /usr/local/lib/qt5/libQt5OpenGL.so.5.15.5  /usr/local/lib/qt5/libQt5Widgets.so.5.15.5  /usr/local/lib/qt5/libQt5Quick.so.5.15.5  /usr/local/lib/qt5/libQt5Gui.so.5.15.5  /usr/local/lib/qt5/libQt5QmlModels.so.5.15.5  /usr/local/lib/qt5/libQt5Qml.so.5.15.5  /usr/local/lib/qt5/libQt5Network.so.5.15.5  /usr/local/lib/qt5/libQt5Core.so.5.15.5  lib/libvtkRenderingOpenGL2-9.2.so.9.2.2  lib/libvtkRenderingHyperTreeGrid-9.2.so.9.2.2  lib/libvtkRenderingUI-9.2.so.9.2.2  /usr/local/lib/libX11.so  lib/libvtkglew-9.2.so.9.2.2  /usr/local/lib/libGLX.so  /usr/local/lib/libOpenGL.so  /usr/local/lib/libX11.so  lib/libvtkInteractionWidgets-9.2.so.9.2.2  lib/libvtkRenderingContext2D-9.2.so.9.2.2  lib/libvtkRenderingCore-9.2.so.9.2.2  lib/libvtkFiltersSources-9.2.so.9.2.2  lib/libvtkFiltersGeneral-9.2.so.9.2.2  lib/libvtkFiltersCore-9.2.so.9.2.2  lib/libvtkCommonExecutionModel-9.2.so.9.2.2  lib/libvtkCommonDataModel-9.2.so.9.2.2  lib/libvtkCommonTransforms-9.2.so.9.2.2  lib/libvtkCommonMisc-9.2.so.9.2.2  lib/libvtkCommonMath-9.2.so.9.2.2  lib/libvtkCommonCore-9.2.so.9.2.2  lib/libvtksys-9.2.so.9.2.2  /usr/lib/libexecinfo.so  -lpthread  lib/libvtkkissfft-9.2.so.9.2.2  -Wl,-rpath-link,/usr/local/lib:/usr/ports/math/vtk9/work/.build/lib && cd /usr/ports/math/vtk9/work/.build/GUISupport/QtQuick/qml && /usr/local/lib/qt5/bin/qmlplugindump -output /usr/ports/math/vtk9/work/.build/lib/qml/VTK.9.2/plugins.qmltypes VTK 9.2 /usr/ports/math/vtk9/work/.build/lib/qml
FAILED: lib/qml/VTK.9.2/libqmlvtkplugin.so lib/qml/VTK.9.2/plugins.qmltypes /usr/ports/math/vtk9/work/.build/lib/qml/VTK.9.2/plugins.qmltypes 
: && /usr/bin/c++ -fPIC -O2 -pipe -march=westmere -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include  -O2 -pipe -march=westmere -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -isystem /usr/local/include  -fstack-protector-strong -shared  -o lib/qml/VTK.9.2/libqmlvtkplugin.so GUISupport/QtQuick/qml/CMakeFiles/qmlvtkplugin.dir/qmlvtkplugin_autogen/mocs_compilation.cpp.o GUISupport/QtQuick/qml/CMakeFiles/qmlvtkplugin.dir/QQmlVTKPlugin.cxx.o  -Wl,-rpath,/usr/ports/math/vtk9/work/.build/lib:/usr/local/lib/qt5:/usr/local/lib:  lib/libvtkGUISupportQtQuick-9.2.so.9.2.2  lib/libvtkGUISupportQt-9.2.so.9.2.2  /usr/local/lib/qt5/libQt5OpenGL.so.5.15.5  /usr/local/lib/qt5/libQt5Widgets.so.5.15.5  /usr/local/lib/qt5/libQt5Gui.so.5.15.5  /usr/local/lib/qt5/libQt5Core.so.5.15.5  /usr/local/lib/qt5/libQt5OpenGL.so.5.15.5  /usr/local/lib/qt5/libQt5Widgets.so.5.15.5  /usr/local/lib/qt5/libQt5Quick.so.5.15.5  /usr/local/lib/qt5/libQt5Gui.so.5.15.5  /usr/local/lib/qt5/libQt5QmlModels.so.5.15.5  /usr/local/lib/qt5/libQt5Qml.so.5.15.5  /usr/local/lib/qt5/libQt5Network.so.5.15.5  /usr/local/lib/qt5/libQt5Core.so.5.15.5  lib/libvtkRenderingOpenGL2-9.2.so.9.2.2  lib/libvtkRenderingHyperTreeGrid-9.2.so.9.2.2  lib/libvtkRenderingUI-9.2.so.9.2.2  /usr/local/lib/libX11.so  lib/libvtkglew-9.2.so.9.2.2  /usr/local/lib/libGLX.so  /usr/local/lib/libOpenGL.so  /usr/local/lib/libX11.so  lib/libvtkInteractionWidgets-9.2.so.9.2.2  lib/libvtkRenderingContext2D-9.2.so.9.2.2  lib/libvtkRenderingCore-9.2.so.9.2.2  lib/libvtkFiltersSources-9.2.so.9.2.2  lib/libvtkFiltersGeneral-9.2.so.9.2.2  lib/libvtkFiltersCore-9.2.so.9.2.2  lib/libvtkCommonExecutionModel-9.2.so.9.2.2  lib/libvtkCommonDataModel-9.2.so.9.2.2  lib/libvtkCommonTransforms-9.2.so.9.2.2  lib/libvtkCommonMisc-9.2.so.9.2.2  lib/libvtkCommonMath-9.2.so.9.2.2  lib/libvtkCommonCore-9.2.so.9.2.2  lib/libvtksys-9.2.so.9.2.2  /usr/lib/libexecinfo.so  -lpthread  lib/libvtkkissfft-9.2.so.9.2.2  -Wl,-rpath-link,/usr/local/lib:/usr/ports/math/vtk9/work/.build/lib && cd /usr/ports/math/vtk9/work/.build/GUISupport/QtQuick/qml && /usr/local/lib/qt5/bin/qmlplugindump -output /usr/ports/math/vtk9/work/.build/lib/qml/VTK.9.2/plugins.qmltypes VTK 9.2 /usr/ports/math/vtk9/work/.build/lib/qml
QQmlComponent: Component is not ready
file:///usr/ports/math/vtk9/work/.build/lib/qml/typelist.qml:3:1: plugin cannot be loaded for module "VTK": Cannot load library /usr/ports/math/vtk9/work/.build/lib/qml/VTK.9.2/libqmlvtkplugin.so: (/usr/ports/math/vtk9/work/.build/lib/libvtkFiltersExtraction-9.2.so.1: Undefined symbol "ompi_mpi_comm_world")
Comment 1 Yuri Victorovich freebsd_committer freebsd_triage 2022-10-25 03:16:25 UTC
Did you try to build in Poudriere?

What system version are you running?

It builds for me in Poudriere 13.1 RELEASE and 13.1 STABLE
Comment 2 alt2600 2022-10-25 04:50:20 UTC
(In reply to Yuri Victorovich from comment #1)

amd64, 13.1p2, building from ports

of course it works in poudriere, in poudriere you don't have both mpich and openmpi installed, which or all intents and purposes conflict despite technically not due to prefixing and include/library search path defaults, with FindMPI.cmake ignoring MPI_HOME over /usr/local/lib where mpich is installed because even though if has a hook for Freebsd using /usr/local/mpi to check there, it explicitly checks /usr/local/lib before its hint list and finds mpich everytime all the time. if mpich was prefixed like openmpi this likely wouldn't even be a thing. but I cannot find a way of disabling the find routine to force openmpi, short of maybe setting every single cmake variable in FindMPI to point it to openmpi manually, and I'm too frustrated with cmake right now to keep trying, as pointing just MPI_C and MPI_EXEC are not enough to make it happy.

I don't mean to sound jerkish, I'm just very angry with cmake right now, I hate that it basically says I know how this arch is configured, no don't tell me, I know better, oops I'm broken your problem tame me, good luck. and that it seems to bury forcing it to behave in ways I can never find in its docs, just going in endless circles of how great it is as a build system, further infuriating me. whats the point of having MPI_HOME in FindMPI.cmake when it ignores it anyway and searches /usr/local/lib and sticks to it no matter what, or a Freebsd hook that is worthless. I also think we really aught consider prefixing mpich as this isn't the first time I've seen this issue on live systems because of default search paths. end rant, sorry but super frustrated
Comment 3 Yuri Victorovich freebsd_committer freebsd_triage 2022-10-25 06:31:09 UTC
MPI handling was touched by this update.

I am trying to reproduce the error.
Comment 4 Yuri Victorovich freebsd_committer freebsd_triage 2022-10-25 09:25:51 UTC
(In reply to alt2600 from comment #2)

FYI: VTK-9.2.2 supplies its own, custom FindMPI.cmake which overrides cmake's mechanism of finding MPI implementations. cmake's own implementation actually finds MPI correctly based on certain variables supplied by the caller.
Comment 5 Yuri Victorovich freebsd_committer freebsd_triage 2022-10-25 17:47:35 UTC
@alt2600@icloud.com,


I believe this is a regression in VTK that it now doesn't respect externally supplied MPI implementation.

In the meantime the workaround is to build it in poudriere.

Simple removal of custom FindMPI.cmake from the project IMO should fix this situation. But this is up to them to do.


Best,
Yuri
Comment 6 alt2600 2022-10-26 01:59:10 UTC
(In reply to Yuri Victorovich from comment #5)

thanks for reporting upstream, and checking this out, but deleting /usr/ports/math/vtk9/work/VTK-9.2.2/CMake/patches/3.22/FindMPI.cmake

still causes mpich to be chosen over openmpi

-- Found MPI_C: /usr/local/lib/libmpi.so (found version "3.1") 
-- Found MPI: TRUE (found version "3.1") found components: C 

and errors out this way

CMake Error: File /usr/ports/math/vtk9/work/VTK-9.2.2/CMake/patches/3.22/FindMPI.cmake does not exist.
CMake Error at CMake/vtkInstallCMakePackage.cmake:157 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  CMakeLists.txt:532 (include)


I'll play around some more because gstreamer1 seems more messed up, and this breaks more cool engineering apps I want working. I really think mpich not being prefixed in /usr/local/mpi is a serious problem, similar to blas libraries conflicting when they can just coexist if the were all prefixed IMHO
Comment 7 alt2600 2022-10-26 04:22:25 UTC
so I surrender, I deleted mpich, and configure fines openmpi, and installs. I did a diff and they def have a tweaked version of FindMPI from the one in cmake-core. so maybe it would be best to put a note in UPDATING that if you have mpich installed you will have to temporarily delete it for the port to configure/update if updating from ports manually or with portmaster like tools. I still think if mpich were in /usr/local/mpi/mpich MPI_HOME would work, as it wouldn't just be found like openmpi is found when mpich is not installed. Maybe I'll test that as my use of mpich is limited to only a couple of ports. but I imagine that would be no small undertaking to fix everything else that wants to use it.
Comment 8 Yuri Victorovich freebsd_committer freebsd_triage 2022-10-26 04:50:53 UTC
Created attachment 237635 [details]
patch

Try the attached patch.
It should resolve the problem.
Comment 9 Yuri Victorovich freebsd_committer freebsd_triage 2022-10-26 05:31:02 UTC
cmake also appears to malfunction in the VTK context: https://gitlab.kitware.com/cmake/cmake/-/issues/24088

Perhaps this is primarily a cmake (FindMPI.cmake) bug.
Comment 10 alt2600 2022-10-27 00:25:05 UTC
(In reply to Yuri Victorovich from comment #8)

with mpich installed it builds and stages, had already upgraded last night with mpich removed, so thinking this did the trick. I had been messing with MPI_HOME and every combination but the LDFLAGS. only oddities I see from configure I'll attach, but from ./build/CMakeCache.txt it is pointing to openmpi, and mpiCC just seems to wrap back to our cc anyway. So I think you cracked the code, thanks!

just for the heck of it, i removed the OMPI_CMAKE_ON and just left the OMPI_LDFLAGS and it seems vendors FindMPI.cmake respects MPI_HOME from the env via Uses/mpi.mk , but only if LDFLAGS is set for some inexplicable reason??? I've confirmed openmpi also is set in ./build/CMakeCache.txt when OMPI_LDFLAGS is set to something. And finally, for super thoroughness I reset --hard to main to get rid of the patch and confirm configure returns to the reported bug condition, just in case somehow my system became wonky. So maybe its just as silly as LDFLAGS for some reason being required for FindMPI to respect MPI_HOME??? can't hurt to re-assert as your patch does, but maybe that would be helpful info upstream, or maybe we just need to assert it in mpi.mk?

observations:

make configure ...

-- Found MPI_C: /usr/bin/cc (found version "3.1") 
-- Found MPI: TRUE (found version "3.1") found components: C 


computer@/usr/local/mpi/openmpi/bin|$ ./mpiCC -v
FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
Target: x86_64-unknown-freebsd13.1
Thread model: posix
InstalledDir: /usr/bin

./build/CMakeCache.txt

//No help, variable specified on the command line.
MPIEXEC_EXECUTABLE:FILEPATH=/usr/local/mpi/openmpi/bin/mpiexec

//Maximum number of processors available to run MPI applications.
MPIEXEC_MAX_NUMPROCS:STRING=12

//Flag used by MPI to specify the number of processes for mpiexec;
// the next option will be the number of processes.
MPIEXEC_NUMPROC_FLAG:STRING=-n

//These flags will be placed after all flags passed to mpiexec.
MPIEXEC_POSTFLAGS:STRING=

//These flags will be directly before the executable that is being
// run by mpiexec.
MPIEXEC_PREFLAGS:STRING=

//MPI C additional include directories
MPI_C_ADDITIONAL_INCLUDE_DIRS:STRING=

//MPI compiler for C
MPI_C_COMPILER:FILEPATH=/usr/bin/cc

//MPI C compiler wrapper include directories
MPI_C_COMPILER_INCLUDE_DIRS:STRING=

//MPI C compilation definitions
MPI_C_COMPILE_DEFINITIONS:STRING=

//MPI C compilation flags
MPI_C_COMPILE_OPTIONS:STRING=

//MPI C linker flags
MPI_C_LINK_FLAGS:STRING=

//No help, variable specified on the command line.
MPI_HOME:PATH=/usr/local/mpi/openmpi
Comment 11 Yuri Victorovich freebsd_committer freebsd_triage 2022-10-27 00:35:44 UTC
Let them fix cmake's discovery of MPI, and then MPI_HOME should just do it in the port.
Comment 12 alt2600 2022-10-27 01:16:22 UTC
(In reply to Yuri Victorovich from comment #11)

fair enough. I couldn't believe after so much fighting it would work beyond configure. so I applied the patch below and it stages just to confirm LDFLAGS is what is going on for my own sanity. again, thanks for the help. I would never have figured this out.



diff --git a/math/vtk9/Makefile b/math/vtk9/Makefile
index 6b6aa3281f70..6c561906943b 100644
--- a/math/vtk9/Makefile
+++ b/math/vtk9/Makefile
@@ -86,6 +86,7 @@ DESIGNER_IMPLIES=     QT5
 
 OMPI_CMAKE_BOOL=       VTK_USE_MPI
 OMPI_USES=             mpi:openmpi
+OMPI_LDFLAGS=          ${MPI_LIBS}
 
 OSMESA_CMAKE_ON=       -DVTK_OPENGL_HAS_OSMESA:BOOL=ON \
                        -DOSMESA_INCLUDE_DIR:PATH=${LOCALBASE}/include/Mesa \
Comment 13 George Mitchell 2023-03-28 22:54:17 UTC
The attached patch allows me to successfully compile vtk9 on 13.1-RELEASE-p7.
Comment 14 alt2600 2023-06-17 18:48:42 UTC
can the patch just get merged? this is still broken, the change is trivial.
Comment 15 Yuri Victorovich freebsd_committer freebsd_triage 2023-06-23 04:51:07 UTC
Patch committed.

Sorry for the delay.
Comment 16 commit-hook freebsd_committer freebsd_triage 2023-06-23 04:51:34 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c5a34d7210f1005facee35d97cbe325a888d9af8

commit c5a34d7210f1005facee35d97cbe325a888d9af8
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2023-06-23 04:49:29 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2023-06-23 04:51:09 +0000

    math/vtk9: Fix build breakage at plugins.qmltypes: Undefined symbol "ompi_mpi_comm_world"

    PR:             267320
    Reported by:    alt2600@icloud.com

 math/vtk9/Makefile | 2 ++
 1 file changed, 2 insertions(+)