Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
7a1a3fc
esmpy: make esmf.mk discovery wheel-aware and relocatable
xylar Jul 16, 2026
9d8eee1
esmpy: preload libmpi for real-MPI wheels before loading libesmf
xylar Jul 18, 2026
b22fdd5
esmpy: resolve the distribution name for metadata lookup
xylar Jul 18, 2026
40f52d3
esmpy: preload Open MPI libmpi.so.40 for real-MPI wheels
xylar Jul 19, 2026
7b4176f
MinGW: accept ESMF_MACHINE=x86_64 (64-bit MSYS2/MinGW)
xylar Jul 17, 2026
8e3a8c8
Util: prefix diff Operation enumerators to avoid Windows DELETE macro
xylar Jul 17, 2026
9c1c4b2
MinGW: use the GNU dialect so CRT POSIX names stay visible
xylar Jul 17, 2026
ee79ece
VM: use dup() instead of fcntl(F_DUPFD) in setRedirects for MinGW
xylar Jul 17, 2026
c3b0548
mpiuni: cast arguments through intptr_t, not long (Win64 LLP64)
xylar Jul 17, 2026
7b276ad
VM: include <io.h> and define STD*_FILENO on MinGW
xylar Jul 17, 2026
60e5bcd
Info: use C_LONG_LONG for address args to match C long long int (Win64)
xylar Jul 17, 2026
ec79584
Info: stage the I8 default in ESMF_KIND_I8, not C_LONG (Win64)
xylar Jul 17, 2026
a678745
VM: #undef the windows.h `interface` macro (collides with MOAB)
xylar Jul 17, 2026
19e2f13
MinGW: define NO_TIMES for C compiles too (vendored Zoltan)
xylar Jul 17, 2026
a52cf70
MOAB: don't force -DLINUX on MinGW (selects missing Unix headers)
xylar Jul 17, 2026
649c9da
MOAB: prefer ESMF-internal LAPACK names over the WIN32 branch (MinGW …
xylar Jul 17, 2026
b1a43e7
MinGW: --export-all-symbols so the ESMC C API is in the DLL export table
xylar Jul 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions build_config/MinGW.gfortran.default/build_rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ ESMF_F90DEFAULT = gfortran
ESMF_CXXDEFAULT = g++
ESMF_CDEFAULT = gcc

############################################################
# Use the GNU dialect (gnu++/gnu) instead of strict ISO (c++/c). On MinGW the
# strict -std=c++NN / -std=cNN flags define __STRICT_ANSI__, which makes the CRT
# headers (<io.h>, <unistd.h>) hide their POSIX-named entry points (dup, dup2,
# close, open, read, write, ...). ESMF's VM code uses those names, so the strict
# dialect breaks the build. The GNU dialect keeps them visible.
#
ifneq ($(ESMF_CXXSTD),sysdefault)
ESMF_CXXSTDFLAG = -std=gnu++$(ESMF_CXXSTD)
endif
ifneq ($(ESMF_CSTD),sysdefault)
ESMF_CSTDFLAG = -std=gnu$(ESMF_CSTD)
endif

############################################################
# Default MPI setting.
#
Expand Down Expand Up @@ -96,7 +110,20 @@ endif
ifeq ($(ESMF_ABI),64)
ESMF_ABISTRING := x86_64_small
endif
else
endif
# 64-bit MSYS2/MinGW reports `uname -m` as x86_64; accept it alongside the legacy
# i686 label (mirrors the Linux.gfortran ABISTRING handling). ESMF_ABI still selects
# the 32- vs 64-bit memory model.
ifeq ($(ESMF_MACHINE),x86_64)
ESMF_ABISTRING := x86_64_small
ifeq ($(ESMF_ABI),32)
ESMF_ABISTRING := x86_64_32
endif
ifeq ($(ESMF_ABI),64)
ESMF_ABISTRING := x86_64_small
endif
endif
ifeq ($(ESMF_ABISTRING),)
$(error "ESMF_MACHINE = $(ESMF_MACHINE)" not recognized)
endif

Expand Down Expand Up @@ -149,8 +176,10 @@ ESMF_CXXCOMPILECPPFLAGS += -DESMF_NO_SYSTEMCALL

############################################################
# Windows does not have support for the times system call
# (also define it for C: vendored Zoltan timer.c is C and includes sys/times.h)
#
ESMF_CXXCOMPILECPPFLAGS += -DNO_TIMES
ESMF_CCOMPILECPPFLAGS += -DNO_TIMES

############################################################
# Windows does not have support for Pthreads
Expand Down Expand Up @@ -212,7 +241,14 @@ ESMF_CXXLINKLIBS += -lgfortran -lWs2_32
############################################################
# Shared library options
#
ESMF_SL_LIBOPTS += -shared
# --export-all-symbols is required: parts of the tree (yaml-cpp, MOAB/mesquite,
# MOAB Factory.cpp, verdict, ESMCI_Trace, nlohmann/json) decorate symbols with
# __declspec(dllexport). As soon as ANY symbol is explicitly exported, MinGW ld
# stops auto-exporting the rest, so the undecorated extern "C" ESMC_* / ESMF C API
# (e.g. ESMC_Initialize) is absent from the DLL export table and ctypes can't find
# it. Forcing all globals to be exported restores the Unix-.so-like behavior ESMPy
# expects.
ESMF_SL_LIBOPTS += -shared -Wl,--export-all-symbols
ESMF_SL_LIBLIBS += $(ESMF_CXXLINKPATHS) $(ESMF_CXXLINKLIBS) -lgfortran

############################################################
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/Base/interface/ESMF_Info.F90
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ subroutine ESMF_InfoGetI8(info, key, value, keywordEnforcer, default, idx, attne
integer, intent(out), optional :: rc

integer :: localrc
integer(C_LONG), target :: local_default
integer(ESMF_KIND_I8), target :: local_default
integer(C_INT), target :: local_idx
type(C_PTR) :: local_default_ptr, local_idx_ptr
integer(C_INT) :: recursive, strlen_only
Expand Down
8 changes: 4 additions & 4 deletions src/Infrastructure/Base/interface/ESMF_InfoCDef.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function c_info_base_get(base_address) bind(C, name="ESMC_BaseGetInfo")
use iso_c_binding
implicit none
integer(C_LONG), intent(in) :: base_address
integer(C_LONG_LONG), intent(in) :: base_address
type(C_PTR) :: c_info_base_get
end function c_info_base_get

Expand Down Expand Up @@ -66,8 +66,8 @@ subroutine c_info_copyforattribute(isrc, idst, rc) bind(C, name="ESMC_InfoCopyFo
subroutine c_info_copyforattribute_reference(src_base_address, dst_base_address, rc) bind(C, name="ESMC_InfoCopyForAttributeReference")
use iso_c_binding
implicit none
integer(C_LONG) :: src_base_address
integer(C_LONG) :: dst_base_address
integer(C_LONG_LONG) :: src_base_address
integer(C_LONG_LONG) :: dst_base_address
integer(C_INT), intent(out) :: rc
end subroutine

Expand Down Expand Up @@ -205,7 +205,7 @@ subroutine c_info_base_sync(inqstate, rootPet, vmAddress, markClean, rc) bind(C,
implicit none
type(C_PTR), value :: inqstate
integer(C_INT), intent(in) :: rootPet
integer(C_LONG), intent(in) :: vmAddress
integer(C_LONG_LONG), intent(in) :: vmAddress
integer(C_INT), intent(in) :: markClean
integer(C_INT), intent(out) :: rc
end subroutine
Expand Down
8 changes: 7 additions & 1 deletion src/Infrastructure/Mesh/src/Moab/DiscreteGeometry/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
# leave alone.
ALL: build_here

ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DLINUX -DUSE_MPI
ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DUSE_MPI
# -DLINUX selects MOAB's Unix code paths (dlfcn.h, dirent.h in Core.cpp).
# Those headers do not exist on MinGW; leave LINUX undefined there so MOAB
# uses its POSIX/Windows-safe fallbacks. Kept for Linux and Darwin.
ifneq ($(ESMF_OS),MinGW)
ESMF_CXXCOMPILECPPFLAGS += -DLINUX
endif

SOURCEC = \
DGMSolver.cpp HiReconstruction.cpp
Expand Down
8 changes: 7 additions & 1 deletion src/Infrastructure/Mesh/src/Moab/IntxMesh/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
# leave alone.
ALL: build_here

ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DLINUX -DUSE_MPI
ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DUSE_MPI
# -DLINUX selects MOAB's Unix code paths (dlfcn.h, dirent.h in Core.cpp).
# Those headers do not exist on MinGW; leave LINUX undefined there so MOAB
# uses its POSIX/Windows-safe fallbacks. Kept for Linux and Darwin.
ifneq ($(ESMF_OS),MinGW)
ESMF_CXXCOMPILECPPFLAGS += -DLINUX
endif

SOURCEC = \
Intx2Mesh.cpp Intx2MeshInPlane.cpp Intx2MeshOnSphere.cpp \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
# leave alone.
ALL: build_here

ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DLINUX -DUSE_MPI
ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DUSE_MPI
# -DLINUX selects MOAB's Unix code paths (dlfcn.h, dirent.h in Core.cpp).
# Those headers do not exist on MinGW; leave LINUX undefined there so MOAB
# uses its POSIX/Windows-safe fallbacks. Kept for Linux and Darwin.
ifneq ($(ESMF_OS),MinGW)
ESMF_CXXCOMPILECPPFLAGS += -DLINUX
endif

SOURCEC = ElemEvaluator.cpp LinearHex.cpp LinearQuad.cpp \
LinearTet.cpp LinearTri.cpp QuadraticHex.cpp
Expand Down
8 changes: 7 additions & 1 deletion src/Infrastructure/Mesh/src/Moab/io/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
# leave alone.
ALL: build_here

ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DLINUX -DUSE_MPI
ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DUSE_MPI
# -DLINUX selects MOAB's Unix code paths (dlfcn.h, dirent.h in Core.cpp).
# Those headers do not exist on MinGW; leave LINUX undefined there so MOAB
# uses its POSIX/Windows-safe fallbacks. Kept for Linux and Darwin.
ifneq ($(ESMF_OS),MinGW)
ESMF_CXXCOMPILECPPFLAGS += -DLINUX
endif

SOURCEC = \
ExoIIUtil.cpp FileTokenizer.cpp GmshUtil.cpp \
Expand Down
8 changes: 7 additions & 1 deletion src/Infrastructure/Mesh/src/Moab/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
# leave alone.
ALL: build_here

ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DLINUX -DUSE_MPI
ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DUSE_MPI
# -DLINUX selects MOAB's Unix code paths (dlfcn.h, dirent.h in Core.cpp).
# Those headers do not exist on MinGW; leave LINUX undefined there so MOAB
# uses its POSIX/Windows-safe fallbacks. Kept for Linux and Darwin.
ifneq ($(ESMF_OS),MinGW)
ESMF_CXXCOMPILECPPFLAGS += -DLINUX
endif

SOURCEC = \
AdaptiveKDTree.cpp AEntityFactory.cpp AffineXform.cpp AxisBox.cpp \
Expand Down
33 changes: 12 additions & 21 deletions src/Infrastructure/Mesh/src/Moab/moab/Matrix3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,18 @@

// We will rely on LAPACK directly

#ifdef WIN32
// RLO: Only use ESMF-internal LAPACK subroutines with ESMF internal LAPACK.
// It seems like only dgeev and dsyevd are currently in use with MOAB.
// ESMF-internal LAPACK does not currently support dsyevr, dgetrf, dgetri.
// NOTE: this must be checked before the WIN32 case below. MinGW predefines
// WIN32, but the ESMF-internal LAPACK still exposes only the esmf_-prefixed
// names, so they must be used on Windows too -- otherwise the link fails
// with undefined references to dgeev_/dsyevd_.
#if defined ESMF_LAPACK_INTERNAL
#define MOAB_dgeev MOAB_FC_WRAPPER(esmf_dgeev, ESMF_DGEEV)
#define MOAB_dsyevd MOAB_FC_WRAPPER(esmf_dsyevd, ESMF_DSYEVD)

#elif defined( WIN32 )

// Should use second form below for windows but
// needed to do this to make it work.
Expand All @@ -82,31 +93,11 @@
#define MOAB_dgetrf MOAB_FC_FUNC( dgetrf, DGETRF )
#define MOAB_dgetri MOAB_FC_FUNC( dgetri, DGETRI )

#else

// RLO: Only use ESMF-internal LAPACK subroutines with ESMF internal LAPACK.
// It seems like only dgeev and dsyevd are currently in use with MOAB.
// ESMF-internal LAPACK does not currently support dsyevr, dgetrf, dgetri.
#if defined ESMF_LAPACK_INTERNAL
#define MOAB_dgeev MOAB_FC_WRAPPER(esmf_dgeev, ESMF_DGEEV)
#define MOAB_dsyevd MOAB_FC_WRAPPER(esmf_dsyevd, ESMF_DSYEVD)
#elif defined ESMF_LAPACK
#define MOAB_dgeev MOAB_FC_WRAPPER(dgeev, DGEEV)
#define MOAB_dsyevd MOAB_FC_WRAPPER(dsyevd, DSYEVD)
#endif

// #define MOAB_dsyevr MOAB_FC_FUNC(dsyevr, DSYEVR)
// #define MOAB_dgetrf MOAB_FC_FUNC(dgetrf, DGETRF)
// #define MOAB_dgetri MOAB_FC_FUNC(dgetri, DGETRI)

// #define MOAB_dsyevd MOAB_FC_WRAPPER( dsyevd, DSYEVD )
// #define MOAB_dsyevr MOAB_FC_WRAPPER( dsyevr, DSYEVR )
// #define MOAB_dgeev MOAB_FC_WRAPPER( dgeev, DGEEV )
// #define MOAB_dgetrf MOAB_FC_WRAPPER( dgetrf, DGETRF )
// #define MOAB_dgetri MOAB_FC_WRAPPER( dgetri, DGETRI )

#endif

extern "C" {

// Computes all eigenvalues and, optionally, eigenvectors of a
Expand Down
8 changes: 7 additions & 1 deletion src/Infrastructure/Mesh/src/Moab/parallel/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
# leave alone.
ALL: build_here

ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DLINUX -DUSE_MPI
ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DUSE_MPI
# -DLINUX selects MOAB's Unix code paths (dlfcn.h, dirent.h in Core.cpp).
# Those headers do not exist on MinGW; leave LINUX undefined there so MOAB
# uses its POSIX/Windows-safe fallbacks. Kept for Linux and Darwin.
ifneq ($(ESMF_OS),MinGW)
ESMF_CXXCOMPILECPPFLAGS += -DLINUX
endif

SOURCEC = \
gs.cpp ParallelComm.cpp ParallelData.cpp ParallelMergeMesh.cpp \
Expand Down
8 changes: 7 additions & 1 deletion src/Infrastructure/Mesh/src/Moab/verdict/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
# leave alone.
ALL: build_here

ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DLINUX -DUSE_MPI
ESMF_CXXCOMPILECPPFLAGS += -DIS_BUILDING_MB -DHAVE_VSNPRINTF -DUSE_MPI
# -DLINUX selects MOAB's Unix code paths (dlfcn.h, dirent.h in Core.cpp).
# Those headers do not exist on MinGW; leave LINUX undefined there so MOAB
# uses its POSIX/Windows-safe fallbacks. Kept for Linux and Darwin.
ifneq ($(ESMF_OS),MinGW)
ESMF_CXXCOMPILECPPFLAGS += -DLINUX
endif

SOURCEC = V_EdgeMetric.cpp VerdictVector.cpp VerdictWrapper.cpp \
V_GaussIntegration.cpp V_HexMetric.cpp V_KnifeMetric.cpp \
Expand Down
Loading
Loading