Bug 265684 - net/mpich: Fails to build when devel/uthash is installed
Summary: net/mpich: Fails to build when devel/uthash is installed
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:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-07 07:27 UTC by Ting-Wei Lan
Modified: 2024-03-31 02:35 UTC (History)
4 users (show)

See Also:


Attachments
[patch] fix mpich to avoid build breakage when the devel/uthash port is installed (842 bytes, patch)
2023-01-03 18:18 UTC, John Hein
no flags Details | Diff
[patch] fix mpich to avoid build breakage when the devel/uthash port is installed (v2) (785 bytes, patch)
2023-01-04 08:39 UTC, John Hein
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ting-Wei Lan 2022-08-07 07:27:02 UTC
It seems that the uthash bundled by mpich is not compatible with the one installed from ports.

/bin/sh ./libtool  --tag=CC   --mode=compile cc -DHAVE_CONFIG_H -I. -I./src/include -I./modules/hwloc/include/private/autogen -I./modules/hwloc/include/hwloc/autogen  -I./src/include  -I./src/mpi/coll/allreduce_group/  -I./src/mpi/coll/transports/gentran  -I./src/mpi/coll/transports/stubtran  -I./src/mpi/coll/transports/common  -I./src/mpi/coll/algorithms/treealgo  -I./src/mpi/coll/algorithms/recexchalgo  -I./src/mpi/coll/algorithms/stubalgo  -I./src/mpi/coll/algorithms/common  -I./src/mpi/coll/include/  -I./src/mpi/datatype/typerep/dataloop  -I./src/mpi/datatype -I./src/mpi/spawn  -I./src/util -I./src/binding/cxx -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/src/binding/fortran/mpif_h  -Isrc/binding/fortran/use_mpi   -I./src/mpid/include       -I./src/mpid/ch4/include  -I./src/mpid/ch4/include  -I./src/mpid/ch4/src  -I./src/mpid/ch4/generic/am  -I./src/mpid/ch4/netmod/include -I./src/mpid/ch4/shm/include  -I./src/mpid/ch4/shm/posix  -I./src/mpid/ch4/shm/src -I./src/mpid/ch4/shm/posix/release_gather  -I./src/mpid/ch4/shm/posix/eager/include  -I./src/mpid/ch4/shm/posix/eager/include  -I./src/mpid/ch4/shm/ipc/src -I./src/mpid/common/sched -I./src/mpid/common/thread  -I./src/mpid/common/timers -I./src/mpid/common/shm  -I./src/mpid/common/bc -I./src/mpid/common/genq   -I./src/pmi/simple  -I./src/pmi/include  -I/usr/local/include -DNETMOD_INLINE=__netmod_inline_ofi__ -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/src/mpl/include -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/src/mpl/include -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/modules/yaksa/src/frontend/include -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/modules/yaksa/src/frontend/include -I/usr/local/include -D_REENTRANT -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/src/mpi/romio/include -fvisibility=hidden -I/usr/local/include/json-c -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -MT src/mpi/attr/lib_libmpi_la-attr_delete.lo -MD -MP -MF src/mpi/attr/.deps/lib_libmpi_la-attr_delete.Tpo -c -o src/mpi/attr/lib_libmpi_la-attr_delete.lo `test -f 'src/mpi/attr/attr_delete.c' || echo './'`src/mpi/attr/attr_delete.c
libtool: compile:  cc -DHAVE_CONFIG_H -I. -I./src/include -I./modules/hwloc/include/private/autogen -I./modules/hwloc/include/hwloc/autogen -I./src/include -I./src/mpi/coll/allreduce_group/ -I./src/mpi/coll/transports/gentran -I./src/mpi/coll/transports/stubtran -I./src/mpi/coll/transports/common -I./src/mpi/coll/algorithms/treealgo -I./src/mpi/coll/algorithms/recexchalgo -I./src/mpi/coll/algorithms/stubalgo -I./src/mpi/coll/algorithms/common -I./src/mpi/coll/include/ -I./src/mpi/datatype/typerep/dataloop -I./src/mpi/datatype -I./src/mpi/spawn -I./src/util -I./src/binding/cxx -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/src/binding/fortran/mpif_h -Isrc/binding/fortran/use_mpi -I./src/mpid/include -I./src/mpid/ch4/include -I./src/mpid/ch4/include -I./src/mpid/ch4/src -I./src/mpid/ch4/generic/am -I./src/mpid/ch4/netmod/include -I./src/mpid/ch4/shm/include -I./src/mpid/ch4/shm/posix -I./src/mpid/ch4/shm/src -I./src/mpid/ch4/shm/posix/release_gather -I./src/mpid/ch4/shm/posix/eager/include -I./src/mpid/ch4/shm/posix/eager/include -I./src/mpid/ch4/shm/ipc/src -I./src/mpid/common/sched -I./src/mpid/common/thread -I./src/mpid/common/timers -I./src/mpid/common/shm -I./src/mpid/common/bc -I./src/mpid/common/genq -I./src/pmi/simple -I./src/pmi/include -I/usr/local/include -DNETMOD_INLINE=__netmod_inline_ofi__ -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/src/mpl/include -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/src/mpl/include -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/modules/yaksa/src/frontend/include -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/modules/yaksa/src/frontend/include -I/usr/local/include -D_REENTRANT -I/wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3/src/mpi/romio/include -fvisibility=hidden -I/usr/local/include/json-c -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -MT src/mpi/attr/lib_libmpi_la-attr_delete.lo -MD -MP -MF src/mpi/attr/.deps/lib_libmpi_la-attr_delete.Tpo -c src/mpi/attr/attr_delete.c  -fPIC -DPIC -o src/mpi/attr/.libs/lib_libmpi_la-attr_delete.o
In file included from src/mpi/attr/attr_delete.c:6:
In file included from ./src/include/mpiimpl.h:241:
In file included from ./src/mpid/ch4/include/mpidpost.h:10:
In file included from ./src/mpid/ch4/include/mpidch4.h:310:
In file included from ./src/mpid/ch4/src/ch4_request.h:9:
./src/mpid/ch4/src/ch4_impl.h:134:84: error: too many arguments provided to function-like macro invocation
    HASH_ADD(hash_handle, MPIDIG_WIN(win, targets), rank, sizeof(int), target_ptr, MPL_MEM_RMA);
                                                                                   ^
/usr/local/include/uthash.h:428:9: note: macro 'HASH_ADD' defined here
#define HASH_ADD(hh,head,fieldname,keylen_in,add)                                \
        ^
In file included from src/mpi/attr/attr_delete.c:6:
In file included from ./src/include/mpiimpl.h:241:
In file included from ./src/mpid/ch4/include/mpidpost.h:10:
In file included from ./src/mpid/ch4/include/mpidch4.h:310:
In file included from ./src/mpid/ch4/src/ch4_request.h:9:
./src/mpid/ch4/src/ch4_impl.h:134:5: error: use of undeclared identifier 'HASH_ADD'
    HASH_ADD(hash_handle, MPIDIG_WIN(win, targets), rank, sizeof(int), target_ptr, MPL_MEM_RMA);
    ^
./src/mpid/ch4/src/ch4_impl.h:888:63: error: too many arguments provided to function-like macro invocation
    HASH_ADD(hh, map->head, key, sizeof(uint64_t), map_entry, class);
                                                              ^
/usr/local/include/uthash.h:428:9: note: macro 'HASH_ADD' defined here
#define HASH_ADD(hh,head,fieldname,keylen_in,add)                                \
        ^
In file included from src/mpi/attr/attr_delete.c:6:
In file included from ./src/include/mpiimpl.h:241:
In file included from ./src/mpid/ch4/include/mpidpost.h:10:
In file included from ./src/mpid/ch4/include/mpidch4.h:310:
In file included from ./src/mpid/ch4/src/ch4_request.h:9:
./src/mpid/ch4/src/ch4_impl.h:888:5: error: use of undeclared identifier 'HASH_ADD'
    HASH_ADD(hh, map->head, key, sizeof(uint64_t), map_entry, class);
    ^
In file included from src/mpi/attr/attr_delete.c:6:
In file included from ./src/include/mpiimpl.h:241:
In file included from ./src/mpid/ch4/include/mpidpost.h:10:
In file included from ./src/mpid/ch4/include/mpidch4.h:322:
In file included from ./src/mpid/ch4/netmod/include/netmod_impl.h:1644:
In file included from ./src/mpid/ch4/netmod/include/../ofi/netmod_inline.h:9:
In file included from ./src/mpid/ch4/include/../netmod/ofi/ofi_am.h:9:
./src/mpid/ch4/include/../netmod/ofi/ofi_am_impl.h:169:62: error: too many arguments provided to function-like macro invocation
                  MPIDI_OFI_global.cq_buffered_dynamic_tail, list_entry);
                                                             ^
/usr/local/include/utlist.h:338:9: note: macro 'LL_APPEND' defined here
#define LL_APPEND(head,add)                                                                    \
        ^
In file included from src/mpi/attr/attr_delete.c:6:
In file included from ./src/include/mpiimpl.h:241:
In file included from ./src/mpid/ch4/include/mpidpost.h:10:
In file included from ./src/mpid/ch4/include/mpidch4.h:322:
In file included from ./src/mpid/ch4/netmod/include/netmod_impl.h:1644:
In file included from ./src/mpid/ch4/netmod/include/../ofi/netmod_inline.h:9:
In file included from ./src/mpid/ch4/include/../netmod/ofi/ofi_am.h:9:
./src/mpid/ch4/include/../netmod/ofi/ofi_am_impl.h:168:9: error: use of undeclared identifier 'LL_APPEND'
        LL_APPEND(MPIDI_OFI_global.cq_buffered_dynamic_head,
        ^
In file included from src/mpi/attr/attr_delete.c:6:
In file included from ./src/include/mpiimpl.h:241:
In file included from ./src/mpid/ch4/include/mpidpost.h:10:
In file included from ./src/mpid/ch4/include/mpidch4.h:324:
In file included from ./src/mpid/ch4/shm/src/shm_impl.h:18:
In file included from ./src/mpid/ch4/shm/src/shm_coll.h:10:
In file included from ./src/mpid/ch4/shm/src/../posix/shm_inline.h:16:
In file included from ./src/mpid/ch4/shm/posix/posix_coll.h:11:
In file included from ./src/mpid/ch4/shm/posix/posix_coll_release_gather.h:30:
./src/mpid/ch4/shm/posix/release_gather/release_gather.h:344:17: error: invalid operands to binary expression ('void' and 'int')
                MPIDI_POSIX_RELEASE_GATHER_GATHER_FLAG_ADDR(*utarray_eltptr(children, i));
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/mpid/ch4/shm/posix/release_gather/release_gather.h:35:12: note: expanded from macro 'MPIDI_POSIX_RELEASE_GATHER_GATHER_FLAG_ADDR'
    ((rank * MPIDI_POSIX_RELEASE_GATHER_FLAG_SPACE_PER_RANK + MPIDI_POSIX_RELEASE_GATHER_GATHER_FLAG_OFFSET)/(MPIDI_POSIX_RELEASE_GATHER_FLAG_SIZE)))
      ~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 errors generated.
*** Error code 1

Stop.
make[3]: stopped in /wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3
*** Error code 1

Stop.
make[2]: stopped in /wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3
*** Error code 1

Stop.
make[1]: stopped in /wrkdirs/usr/ports/net/mpich/work/mpich-3.4.3
*** Error code 1

Stop.
make: stopped in /usr/ports/net/mpich
Comment 1 Ryan Steinmetz freebsd_committer freebsd_triage 2022-08-07 11:05:08 UTC
devel/uthash is currently at the latest version available from upstream: https://github.com/troydhanson/uthash/tags
Comment 2 John Hein 2023-01-03 18:18:06 UTC
Created attachment 239236 [details]
[patch] fix mpich to avoid build breakage when the devel/uthash port is installed

This is still a problem with the latest ports versions of mpich (3.4.3) and uthash (2.3.0).

Attached is a patch to help the mpich build avoid pollution from installed packages in ${LOCALBASE}.

The underlying issue:
Using 'configure --with-libfabric=${LOCALBASE}' causes CPPFLAGS variables in the generated Makefiles to have -I${LOCALBASE}/include very early - specifically before -I flags that point to the mpich directories in ${WRKSRC}.

If the ports version of devel/uthash is installed, this will cause the build to use the devel/uthash version of uthash.h - recall that corresponds to uthash 2.3.0.  That uthash.h is not compatible with the mpich code that uses uthash - the mpich bundled version of uthash is 2.0.2, and there are some API incompatibilities between 2.0.2 and 2.3.0 (specifically different parameters expected for the HASH_ADD macro).

This patch creates a sym link in ${WRKDIR} to point to the libfabric include files (in ${LOCALBASE}/include/rdma) uses --with-libfabric-include to point to that ${WRKDIR}/include directory.  This avoids the early addition of -I${LOCALBASE}/include to CPPFLAGS.

Other possible fixes:

 - change mpich configure scripts to move -I${LOCALBASE}/include (from --with-libfabric) later in CPPFLAGS.

 - update mpich source code to work with the newer version of uthash

 - build mpich with the bundled version of libfabric instead of the ports version (net/libfabric)


The first option (change configure scripts) is more work than the simple "sym link isolation" workaround used in the patch.  I tried implementing that - it wasn't easy to find a fix.  Maybe there is a clean / simple way to move the libfabric configuration later in the configure process.

The second option (update mpich code for newer uthash) might be something that upstream could be convinced to do or fed and accepted to upstream.  Or the mpich code could be made to work with either the older or newer uthash - that's even more complicated and would involve more 'configure' time work.  But any of that work to update mpich for a newer uthash is fragile - the next time the freebsd devel/uthash port is updated, that could break mpich again.  Note that the HASH_ADD invocation is header-only, so I believe there's no dependency on the uthash library.  I did not do an exhaustive analysis, however.  ldd says there is no dependency on  libuthash in the installed mpich programs / libraries.

The last option above (use the bundled libfabric) seems like a reasonable alternative if the attached patch is not desirable for some reason.  Yes, it will bloat the mpich installation somewhat (I did not calculate how much), but it does isolate mpich from changes to the net/libfabric port (with all the related pros / cons of that isolation).

QA:
 - portlint (no new warnings)
 - portclippy (no new suggested format fixes)
 - poudriere (ok - builds/installs with patch even if devel/uthash is installed first)

Ting-Wei Lan, please try the patch, and report if it solves your build failure.
Comment 3 John Hein 2023-01-04 08:39:17 UTC
Created attachment 239249 [details]
[patch] fix mpich to avoid build breakage when the devel/uthash port is installed (v2)

fix patch - fully specify sym link target directory
Comment 4 Ting-Wei Lan 2023-01-09 01:11:14 UTC
(In reply to John Hein from comment #3)
The patch fixes the issue.
Comment 5 Oleg Sidorkin 2023-04-25 14:33:45 UTC
(In reply to John Hein from comment #3)
Works for me. Can it be commited please?
Comment 6 Yuri Victorovich freebsd_committer freebsd_triage 2024-03-31 02:34:48 UTC
Committed, thanks!
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-03-31 02:35:38 UTC
A commit in branch main references this bug:

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

commit e0a8cc0d3378269c5e7681ae4177a85e1b8baaf8
Author:     John Hein <jcfyecrayz@liamekaens.com>
AuthorDate: 2024-03-31 01:52:59 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-03-31 02:34:54 +0000

    net/mpich: Fix failure to build when devel/uthash is installed

    PR:             265684

 net/mpich/Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)