Can I have a Debug compiled version (WM_COMPILE_OPTION=Debug) please?
OP-ACE opened this issue · 14 comments
Thanks for your great work!
Can I have a Debug compiled version (WM_COMPILE_OPTION=Debug) please?
Or, is it possible to switch between Opt(WM_COMPILE_OPTION=Opt) and Debug mode (WM_COMPILE_OPTION=Debug)?
You can get a Debug build by adding these two lines:
echo "export WM_COMPILE_OPTION=Debug" >> etc/prefs.sh
echo "setenv WM_COMPILE_OPTION Debug" >> etc/prefs.csh
to the configure.sh file, and then building the app following the build instructions.
Distributing a Debug build here is theoretically possible, but it'd add to the compile times and maintenance overhead (particularly for the Apple silicon variant, which I have to build locally as there are no Apple silicon runners available on GitHub Actions).
FWIW, are you running the Intel or the Apple silicon variant?
BTW, I'm trying this locally and the debug build easily fills the build volume. You'll probably have to increase the BUILD_DMG_SIZE
make variable; e.g.:
make BUILD_DMG_SIZE=20g
EDIT: this isn't needed anymore as of #61
Sir, thanks for your kind and helpful response. I am using Intel. I am just thinking it would be so convenient to use a debug-mode app :)
Thanks! For now, I think it's reasonable to ask users who require Debug builds to compile the app by themselves with the above instructions.
I'd be more willing to consider this if there's many requests for it and/or other circumstances change and make it so that the Debug builds are worth the extra work and CI time.
Please feel free reopen this issue if you have a different suggestion.
Hi gerlero:
I follow your instructions and succeed compile the openfoam-v2212-debug.
Making dependencies: icoFoam.C
clang++ -std=c++14 -m64 -pthread -ftrapping-math -DOPENFOAM=2212 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-undefined-var-template -Wno-unknown-warning-option -O0 -g -DFULLDEBUG -DNoRepository -ftemplate-depth-100 -I/Volumes/OpenFOAM-v2212-Debug/src/finiteVolume/lnInclude -I/Volumes/OpenFOAM-v2212-Debug/src/meshTools/lnInclude -iquote. -IlnInclude -I/Volumes/OpenFOAM-v2212-Debug/src/OpenFOAM/lnInclude -I/Volumes/OpenFOAM-v2212-Debug/src/OSspecific/POSIX/lnInclude -fPIC -c icoFoam.C -o Make/darwin64ClangDPInt32Debug/icoFoam.o
clang++ -std=c++14 -m64 -pthread -ftrapping-math -DOPENFOAM=2212 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-undefined-var-template -Wno-unknown-warning-option -O0 -g -DFULLDEBUG -DNoRepository -ftemplate-depth-100 -I/Volumes/OpenFOAM-v2212-Debug/src/finiteVolume/lnInclude -I/Volumes/OpenFOAM-v2212-Debug/src/meshTools/lnInclude -iquote. -IlnInclude -I/Volumes/OpenFOAM-v2212-Debug/src/OpenFOAM/lnInclude -I/Volumes/OpenFOAM-v2212-Debug/src/OSspecific/POSIX/lnInclude -fPIC -Wl,-execute,-undefined,dynamic_lookup Make/darwin64ClangDPInt32Debug/icoFoam.o -L/Volumes/OpenFOAM-v2212-Debug/platforms/darwin64ClangDPInt32Debug/lib
-lfiniteVolume -lmeshTools -lOpenFOAM -ldl
-g -DFULLDEBUG -lm -o /Users/wy/OpenFOAM/wy-v2212/platforms/darwin64ClangDPInt32Debug/bin/icoFoam
ld: warning: ignoring file /Volumes/OpenFOAM-v2212-Debug/platforms/darwin64ClangDPInt32Debug/lib/libmeshTools.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /Volumes/OpenFOAM-v2212-Debug/platforms/darwin64ClangDPInt32Debug/lib/libfiniteVolume.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /Volumes/OpenFOAM-v2212-Debug/platforms/darwin64ClangDPInt32Debug/lib/libOpenFOAM.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
and then
/Users/wy/OpenFOAM/wy-v2212/platforms/darwin64ClangDPInt32Debug/bin/icoFoam
dyld[39661]: symbol not found in flat namespace '__ZN4Foam10FatalErrorE'
[1] 39661 abort /Users/wy/OpenFOAM/wy-v2212/platforms/darwin64ClangDPInt32Debug/bin/icoFoam
I think some compilation instruction is wrong.
Can you give me some suggestion?
Thank you very much!
Yang Wang
/Users/wy/OpenFOAM/wy-v2212/platforms/darwin64ClangDPInt32Debug/bin/icoFoam
Are you using this project to build OpenFOAM from source (via make
)? Builds from this project live entirely in a disk image (mounted at /Volumes/OpenFOAM-XXXX
), so that path doesn't look like it belongs
/Users/wy/OpenFOAM/wy-v2212/platforms/darwin64ClangDPInt32Debug/bin/icoFoam
Are you using this project to build OpenFOAM from source (via
make
)? Builds from this project live entirely in a disk image (mounted at/Volumes/OpenFOAM-XXXX
), so that path doesn't look like it belongs
I use your OpenFOAM-v2212,
wmake
Making dependencies: icoFoam.C
clang++ -std=c++14 -m64 -pthread -ftrapping-math -DOPENFOAM=2212 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-undefined-var-template -Wno-unknown-warning-option -O3 -DNoRepository -ftemplate-depth-100 -I/Volumes/OpenFOAM-v2212/src/finiteVolume/lnInclude -I/Volumes/OpenFOAM-v2212/src/meshTools/lnInclude -iquote. -IlnInclude -I/Volumes/OpenFOAM-v2212/src/OpenFOAM/lnInclude -I/Volumes/OpenFOAM-v2212/src/OSspecific/POSIX/lnInclude -fPIC -c icoFoam.C -o Make/darwin64ClangDPInt32Opt/icoFoam.o
clang++ -std=c++14 -m64 -pthread -ftrapping-math -DOPENFOAM=2212 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-undefined-var-template -Wno-unknown-warning-option -O3 -DNoRepository -ftemplate-depth-100 -I/Volumes/OpenFOAM-v2212/src/finiteVolume/lnInclude -I/Volumes/OpenFOAM-v2212/src/meshTools/lnInclude -iquote. -IlnInclude -I/Volumes/OpenFOAM-v2212/src/OpenFOAM/lnInclude -I/Volumes/OpenFOAM-v2212/src/OSspecific/POSIX/lnInclude -fPIC -Wl,-execute,-undefined,dynamic_lookup Make/darwin64ClangDPInt32Opt/icoFoam.o -L/Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib
-lfiniteVolume -lmeshTools -lOpenFOAM -ldl
-lm -o /Users/wy/OpenFOAM/wy-v2212/platforms/darwin64ClangDPInt32Opt/bin/icoFoam
then
❯ $FOAM_USER_APPBIN/icoFoam
/---------------------------------------------------------------------------
| ========= | |
| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \ / O peration | Version: 2212 |
| \ / A nd | Website: www.openfoam.com |
| \/ M anipulation | |
*---------------------------------------------------------------------------*/
Build : _66908158ae-20221220 OPENFOAM=2212 version=v2212
Arch : "LSB;label=32;scalar=64"
Exec : /Users/wy/OpenFOAM/wy-v2212/platforms/darwin64ClangDPInt32Opt/bin/icoFoam
Date : Apr 14 2023
Time : 22:49:05
Host : Mac-mini.local
PID : 82655
I/O : uncollated
Case : /Users/wy/icoFoam
nProcs : 1
trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5, maxFileModificationPolls 20)
allowSystemOperations : Allowing user-supplied system call operations
it's fine.
I think the major problem is
ld: warning: ignoring file /Volumes/OpenFOAM-v2212-Debug/platforms/darwin64ClangDPInt32Debug/lib/libfiniteVolume.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /Volumes/OpenFOAM-v2212-Debug/platforms/darwin64ClangDPInt32Debug/lib/libfiniteVolume.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
maybe I need modify the makefile
or configure.sh
, that can correct macOS-arm64
and macOS-x86_64
problem!
Can you give me some instructions?
Thank you very much!
Yang Wang
Sorry, on first sight I didn't realize that that icoFoam in /Users/...
could be a custom solver with the same name.
Given that it's compiling for target arm64
, I have to assume you're on Apple silicon.
Can you run the command lipo -archs /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Debug/lib/libfiniteVolume.dylib
?
That should output arm64
.
Sorry, on first sight I didn't realize that that icoFoam in
/Users/...
could be a custom solver with the same name.Given that it's compiling for target
arm64
, I have to assume you're on Apple silicon.Can you run the command
lipo -archs /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Debug/lib/libfiniteVolume.dylib
?That should output
arm64
.
Sorry, output is x86_64
.
lipo -archs /Volumes/OpenFOAM-v2212-Debug/platforms/darwin64ClangDPInt32Debug/lib/libfiniteVolume.dylib x86_64
But I don't know how to change this!
Another Opt version is correct. this version is direct install through brew.
lipo -archs /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib/libfiniteVolume.dylib
output is arm64
Thank you.
Yang Wang
Looks like you've built your Debug OpenFOAM on an Intel Mac (or on an Apple silicon Mac while using Rosetta 2 emulation), yet are now compiling a custom solver on Apple silicon, which is not compatible with that OpenFOAM installation and won't work. You could build your custom solver too with Rosetta 2, but I'd recommend you throw away your OpenFOAM install and instead build the Debug-enabled OpenFOAM again this time for Apple silicon.
Prior to making the build, you can check that you're actually running on an Apple silicon console (i.e., without Rosetta 2) by running uname -m
and verifying that the output is arm64
.
There might be another issue that is causing the custom solver compile to ignore the WM_COMPILE_OPTION=Debug
flag (which should be set by prefs.sh
), but the major problem you mention is due to the previous incompatibility.
I am using a Mac M2(apple silicon), and I follow your instructions
You can get a Debug build by adding these two lines:
echo "export WM_COMPILE_OPTION=Debug" >> etc/prefs.sh
echo "setenv WM_COMPILE_OPTION Debug" >> etc/prefs.csh
to the configure.sh file, and then building the app following the build instructions.
git clone https://github.com/gerlero/openfoam-app.git
cd openfoam-app
make
and finished compiling
the shared library is x86_64
, so I can not use icoFoam
, it's link library error.
icoFoam
dyld[16724]: symbol not found in flat namespace '__ZN4Foam10FatalErrorE'
Abort trap: 6
I don't know how to modify the Makefile
or something else. Can you give an advice?
Thank you
Yang Wang
My guess is you've been (inadvertently) using a Rosetta-emulated terminal for the OpenFOAM build.
Prior to making the build, you can check that you're actually running on an Apple silicon console (i.e., without Rosetta 2) by running
uname -m
and verifying that the output isarm64
.
Are you able to confirm this?
I don't know of any other reason why it would compile to Intel (x86_64
) binaries on an Apple silicon (arm64
) machine, except if you're using Rosetta somehow.
My guess is you've been (inadvertently) using a Rosetta-emulated terminal for the OpenFOAM build.
Prior to making the build, you can check that you're actually running on an Apple silicon console (i.e., without Rosetta 2) by running
uname -m
and verifying that the output isarm64
.Are you able to confirm this?
I don't know of any other reason why it would compile to Intel (
x86_64
) binaries on an Apple silicon (arm64
) machine, except if you're using Rosetta somehow.
cmake_minimum_required(VERSION 3.24)
if (DEFINED ENV{WM_PROJECT})
message("Using $ENV{WM_PROJECT}-$ENV{WM_PROJECT_VERSION}")
set(WM_PATH, ${CMAKE_SOURCE_DIR})
else()
message(FATAL_ERROR "OpenFOAM environment not set. Aborting.")
endif ()project(icoFoam) // 1. 改个名字
#set(CMAKE_CXX_STANDARD 14)
#set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(OpenFOAM_VERSION $ENV{WM_PROJECT_VERSION})
set(OpenFOAM_DIR $ENV{WM_PROJECT_DIR})
set(OpenFOAM_LIB_DIR $ENV{FOAM_LIBBIN})
set(OpenFOAM_SRC $ENV{FOAM_SRC})
set(CMAKE_OSX_ARCHITECTURES x86_64)//set(PATH_LIB_OPENMPI "sys-openmpi")
set(DEFINITIONS_COMPILE "-std=c++14 -m64 -pthread -ftrapping-math -fno-elide-constructors -DOPENFOAM=2206
-DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor
-Wno-unused-parameter -Wno-invalid-offsetof -Wno-undefined-var-template
-Wno-unknown-warning-option -O0 -g -DFULLDEBUG -DNoRepository -ftemplate-depth-100
-fPIC")include_directories(.
${OpenFOAM_SRC}/OpenFOAM/lnInclude
${OpenFOAM_SRC}/OSspecific/POSIX/lnInclude
${OpenFOAM_SRC}/finiteVolume/lnInclude
${OpenFOAM_SRC}/meshTools/lnInclude
)
// -I,告诉在哪里找头文件,H文件link_directories(${OpenFOAM_LIB_DIR} ${OpenFOAM_LIB_DIR}/dummy ${OpenFOAM_LIB_DIR}/${PATH_LIB_OPENMPI})
// -L,在那个位置找你
add_definitions(${DEFINITIONS_COMPILE})add_executable(${PROJECT_NAME}
icoFoam.C)target_link_libraries(${PROJECT_NAME} OpenFOAM dl m Pstream finiteVolume fvOptions meshTools sampling dynamicFvMesh
)
I almost solve this problem, add an statement set(CMAKE_OSX_ARCHITECTURES x86_64)
I install from your app, brew
, that is arm64
I build the app from your instruction, that is x86_64
whatever, thank you very much. appreciate your work!
Yang Wang
Good to know that it's solved (note however that you might prefer the native arm64
build on an Apple silicon Mac for performance reasons).