Open Jamie790 opened 12 months ago
Hi,
It looks like architecture mix. By make rules were made for x86_64
(ex. wmake/rules/darwin64Clang/c++
):
CC = xcrun c++ -arch x86_64 -std=c++14
While Homebrew-installed openmpi
is compiled for arm64
. So, you need to either simply remove -arch x86_64
flag in wmake/rules/darwin64Clang/c++
and wmake/rules/darwin64Clang/c
, or put there arm64
instead of x86_64
. And then recompile the software.
Hi,
Thanks for you reply. I tired to put arm64 instead of x86_64 in wmake/rules/darwin64Clang/c++ and wmake/rules/darwin64Clang/c and then recomplied.
But i get some error message during ./Allwmake
``` /Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/word.HIn file included from :/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/string.H42::
error: In file included from /Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/string.H51:51:
reference to unresolved using declarationIn file included from :
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/string
In file included from :/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/string527::
527:
_VSTD::memcpy(&__r, __p, sizeof(__r));/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/hash.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/hash.h::37 ^37:
:1212:: error: error: reference to unresolved using declarationreference to unresolved using declaration
In file included from 99/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/wchar.h:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwd:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__mbstate_t.h:29:
:99/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/wchar.h:
:62In file included from :/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__mbstate_t.h4262:::29 42:
: /Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/wchar.herror: :error: no type named 'wstring' in namespace 'std'62:42:no type named 'wstring' in namespace 'std'
error: no type named 'wstring' in namespace 'std'
Ostream& operator<<(Ostream&, const std::wstring&);
Ostream& operator<<(Ostream&, const std::wstring&); ~~~~~^
Ostream& operator<<(Ostream&, const std::wstring&); ~~~~~^
~~~~~^
/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/string.HIn file included from :/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/int32.H51:error: :
43In file included from :
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stringIn file included from reference to unresolved using declaration:/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/word.H529:
:
42In file included from :
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__ios/fpos.hIn file included from :/Users/liqiaoqiao/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/string.H:typedef fpos<mbstate_t> streampos;51
14 ^:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwdIn file included from :230/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/string/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__mbstate_t.h:::4414:529:1:
:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__ios/fpos.h:error: 14note: :
using declaration annotated with 'using_if_exists' here/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwdreference to unresolved using declaration:
230:14: using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
typedef fpos<mbstate_t> streampos;error:
^
^reference to unresolved using declaration
In file included from UPstream.C:26/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__mbstate_t.h:
:typedef fpos<mbstate_t> streampos;44
:1 ^:
In file included from /Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/UPstream.H :/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__mbstate_t.hnote: 42:
In file included from :/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/labelList.H44using declaration annotated with 'using_if_exists' here
::471:
I am try to compile OpenFOAM-5.x-7f7d351b7.patch, i am not sure where i did wrong. Should i try other patches to see if there is same error? Many thanks.
Well, it seems, we need more information. Could you post output of:
uname -m
file /opt/homebrew/Cellar/open-mpi/*/lib/libmpi.dylib
Hi,
Many thank for your reply.
Regards, mz
Things are a bit complicated, cause I do not have access to Apple's ARM platform, and I have never tried to compile 5.x with current compiler. So, I would propose:
-arch
flag from compilation rules.brew doctor
command. If there is a problem with clang
installation, the command will shown them. Though, you have successfully compiled the code for x86_64
, I doubt, there is a problem with the installation.You should be able to fix this by installing Xcode and the Command line Tools before building OpenFOAM. Then wmake/rules/darwin64Clang/c++ and wmake/rules/darwin64Clang/c will reference -m64 and not x86-64
FYI, I also have this issue on my M3 Mac. I am not sure of the cause of the problem, but I suspect it is related to linking to libPstream or libmpi.
I will post here if I progress, but I am happy to hear about others' experiences.
The _ompi_mpi_byte
should be given in libmpi.dylib
, e.g. we can see this with nm
:
>> nm -g $(mpicc --showme:link | sed -e 's/.*-L\([^ ]*\).*/\1/')/libmpi.dylib | c++filt | grep "_ompi_mpi_byte"
3233:00000000001e4808 D _ompi_mpi_byte
I am not sure why this symbol is not found, if mpi is being linked correctly, which it seems to be...
Problem solved: your solution here works.
That is, in $WM_DIR/rules/darwin64Clang/c++
and $WM_DIR/rules/darwin64Clang/c
, replace x86_64
with arm64
. Then, clean (wcleanPlatform
) and re-build OpenFOAM.
However, this leads to an error when compiling $FOAM_SRC/OSspecific
related to #include <xmmintrin.h>
. A hack fix is to comment line 41 in $FOAM_SRC/OSspecific/POSIX/signals/sigFpe.C
:
//#include <xmmintrin.h>
and comment lines 215 and 216
// _mm_setcsr(_MM_MASK_MASK &~
// (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO));
Everything now works correctly, including in parallel.
Creating a dedicated darwinArm64Clang
seems like a reasonable solution for the rules. I am not sure about the implication of the sigFpe.C hack. I see that OpenFOAM.com has solved this issue, so maybe something can be copied from there. Let me know if you like me to test or propose an updated patch.
Thank you for the feedback. Yes, commented-out parts are Intel-specific.
OpenFOAM.com solved problem of sigFPE on ARM-based Macs. I will try to add the solution to OpenFOAM.org patches, though I won't be able to test them. As soon as I update the patches, I will create an issue for testing.
Hi,
I have successfully build Openfoam-5.x in M2, but when i try to run simplefoam or blockmesh i get this message:
%simpleFoam dyld[1343]: symbol not found in flat namespace '_ompi_mpi_byte' zsh: abort simpleFoam
%blockMesh dyld[1654]: symbol not found in flat namespace '_ompi_mpi_byte' zsh: abort blockMesh
Can you help me to solve this problem. Many thanks.