-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FORTLINK: Guess if Unknown #1126
Conversation
else () | ||
set(FORTLINK "UNDERSCORE") | ||
endif() | ||
message(AUTHOR_WARNING "Fortran to C mangling not compatible with AMReX code, assuming '${FORTLINK}'") | ||
endif () | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JBlaschke can you add this line to your code to find out what FortranCInterface_GLOBAL_SUFFIX
is in your case please?
message(WARNING "+++++++++ FortranCInterface_GLOBAL_PREFIX='${FortranCInterface_GLOBAL_PREFIX}' ++++++++++++++++") | |
message(WARNING "+++++++++ FortranCInterface_GLOBAL_SUFFIX='${FortranCInterface_GLOBAL_SUFFIX}' ++++++++++++++++") | |
message(WARNING "+++++++++ FortranCInterface_GLOBAL_CASE='${FortranCInterface_GLOBAL_CASE}' ++++++++++++++++") |
What's the full cmake output (including compiler identifications) if you add this? I fear the picked up C compiler and Fortran compiler might truly be incompatible. If that is the case, we might better error out with a meaningful message here instead of guessing and causing a hard to debug runtime error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Axel -- I don't think your thesis matches reality :( another beautiful theory slain by and ugly fact. Here is the full cmake output:
blaschke@NERSCs-MBP ◰³ py3 ~/S/amrex ➦ 52909b777 dist cmake -DENABLE_PARTICLES=ON -DENABLE_AMRDATA=ON -DENABLE_EB=ON -DENABLE_OMP=ON -DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX="." \
-DCMAKE_C_COMPILER=(which gcc-8) -DCMAKE_CXX_COMPILER=(which g++-8) -DCMAKE_Fortran_COMPILER=(which gfortran-8) ..
- The C compiler identification is GNU 8.4.0
- The CXX compiler identification is GNU 8.4.0
- Checking whether C compiler has -isysroot
- Checking whether C compiler has -isysroot - yes
- Checking whether C compiler supports OSX deployment target flag
- Checking whether C compiler supports OSX deployment target flag - yes
- Check for working C compiler: /usr/local/bin/gcc-8
- Check for working C compiler: /usr/local/bin/gcc-8 - works
- Detecting C compiler ABI info
- Detecting C compiler ABI info - done
- Detecting C compile features
- Detecting C compile features - done
- Checking whether CXX compiler has -isysroot
- Checking whether CXX compiler has -isysroot - yes
- Checking whether CXX compiler supports OSX deployment target flag
- Checking whether CXX compiler supports OSX deployment target flag - yes
- Check for working CXX compiler: /usr/local/bin/g++-8
- Check for working CXX compiler: /usr/local/bin/g++-8 - works
- Detecting CXX compiler ABI info
- Detecting CXX compiler ABI info - done
- Detecting CXX compile features
- Detecting CXX compile features - done
- CMake version: 3.17.3
- AMReX installation directory: /Users/blaschke/Science/amrex/dist
- Building AMReX with DIM = 3
- Configuring AMReX with the following options enabled:
- BUILD_SHARED_LIBS
- ENABLE_FORTRAN
- ENABLE_DP
- ENABLE_MPI
- ENABLE_OMP
- ENABLE_EB
- ENABLE_LINEAR_SOLVERS
- ENABLE_AMRDATA
- ENABLE_PARTICLES
- ENABLE_DP_PARTICLES
- The Fortran compiler identification is GNU 8.4.0
- Checking whether Fortran compiler has -isysroot
- Checking whether Fortran compiler has -isysroot - yes
- Checking whether Fortran compiler supports OSX deployment target flag
- Checking whether Fortran compiler supports OSX deployment target flag - yes
- Check for working Fortran compiler: /usr/local/bin/gfortran-8
- Check for working Fortran compiler: /usr/local/bin/gfortran-8 - works
- Detecting Fortran compiler ABI info
- Detecting Fortran compiler ABI info - done
- Checking whether /usr/local/bin/gfortran-8 supports Fortran 90
- Checking whether /usr/local/bin/gfortran-8 supports Fortran 90 - yes
- Detecting Fortran/C Interface
ailed to compile
- Fortran name mangling scheme: CASE (no append underscore)
- Found OpenMP_C: -fopenmp (found version "4.5")
- Found OpenMP_CXX: -fopenmp (found version "4.5")
- Found OpenMP_Fortran: -fopenmp (found version "4.5")
- Found OpenMP: TRUE (found version "4.5")
- Found MPI_C: /usr/local/Cellar/mpich/3.3.2_1/lib/libmpi.dylib (found version "3.1")
- Found MPI_CXX: /usr/local/Cellar/mpich/3.3.2_1/lib/libmpicxx.dylib (found version "3.1")
- Found MPI: TRUE (found version "3.1") found components: C CXX
- Looking for pthread.h
- Looking for pthread.h - found
- Performing Test CMAKE_HAVE_LIBC_PTHREAD
- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
- Found Threads: TRUE
- AMReX configuration summary:
- Build type = Release
- Install directory = /Users/blaschke/Science/amrex/dist
- C++ compiler = /usr/local/bin/g++-8
- Fortran compiler = /usr/local/bin/gfortran-8
- C++ defines = -DAMREX_GIT_VERSION="20.07-37-g52909b777b70" -DAMREX_USE_MPI -DBL_USE_MPI -DAMREX_USE_OMP -DBL_USE_OMP -DAMREX_SPACEDIM=3 -DBL_SPACEDIM=3 -DAMREX_Da
win -DBL_Darwin -DBL_FORT_USE_CASE -DAMREX_USE_EB -DAMREX_PARTICLES
- Fortran defines = -DAMREX_GIT_VERSION="20.07-37-g52909b777b70" -DAMREX_USE_MPI -DBL_USE_MPI -DAMREX_USE_OMP -DBL_USE_OMP -DAMREX_SPACEDIM=3 -DBL_SPACEDIM=3 -DAMREX_Da
win -DBL_Darwin -DBL_LANG_FORT -DAMREX_LANG_FORT -DBL_FORT_USE_CASE -DAMREX_USE_EB -DAMREX_PARTICLES
- C++ flags = -O3 -DNDEBUG -fopenmp -Werror=return-type
- Fortran flags = -O3 -DNDEBUG -O3 -fimplicit-none -ffixed-line-length-none -ffree-line-length-none
- C++ include paths = -I/usr/local/Cellar/mpich/3.3.2_1/include -I/Users/blaschke/Science/amrex/dist/mod_files -I/Users/blaschke/Science/amrex/Src/Base -I/Users/blaschke/
cience/amrex/Src/Boundary -I/Users/blaschke/Science/amrex/Src/AmrCore -I/Users/blaschke/Science/amrex/Src/Amr -I/Users/blaschke/Science/amrex/Src/EB -I/Users/blaschke/Science/amrex
Src/LinearSolvers/MLMG -I/Users/blaschke/Science/amrex/Src/LinearSolvers/Projections -I/Users/blaschke/Science/amrex/Src/Particle -I/Users/blaschke/Science/amrex/Src/Extern/amrdata
- Fortran include paths = -I/usr/local/Cellar/mpich/3.3.2_1/include -I/Users/blaschke/Science/amrex/dist/mod_files -I/Users/blaschke/Science/amrex/Src/Base -I/Users/blaschke/
cience/amrex/Src/Boundary -I/Users/blaschke/Science/amrex/Src/AmrCore -I/Users/blaschke/Science/amrex/Src/Amr -I/Users/blaschke/Science/amrex/Src/EB -I/Users/blaschke/Science/amrex
Src/LinearSolvers/MLMG -I/Users/blaschke/Science/amrex/Src/LinearSolvers/Projections -I/Users/blaschke/Science/amrex/Src/Particle -I/Users/blaschke/Science/amrex/Src/Extern/amrdata
- Link line = gfortran gcc_ext.10.5 gcc quadmath m /usr/local/Cellar/gcc@8/8.4.0_1/lib/gcc/8/libgomp.dylib ::@(0x7ffbad80b800) /usr/local/Cellar/mpich/3.3.2_1/lib
libmpi.dylib /usr/local/Cellar/mpich/3.3.2_1/lib/libpmpi.dylib /usr/local/Cellar/mpich/3.3.2_1/lib/libmpicxx.dylib ::@
- Configuring done
- Generating done
- Build files have been written to: /Users/blaschke/Science/amrex/dist
(note: I'm using fish -- so -DCMAKE_C_COMPILER=(which gcc-8)
is equivalent to -DCMAKE_C_COMPILER=$(which gcc-8)
)
I think the problem is that cmake -- for reasons that are above my pay grade -- can't figure out the Fortran/C interface:
-- Detecting Fortran/C Interface
Failed to compile
But I also don't know how to coax any information out of cmake RE what it actually tried to do there, and why it failed to compile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added your warnings, and I get:
CMake Warning at Tools/CMake/AMReX_Defines.cmake:117 (message):
+++++++++ FortranCInterface_GLOBAL_PREFIX='' ++++++++++++++++
Call Stack (most recent call first):
Tools/CMake/AMReX_Config.cmake:41 (set_amrex_defines)
Src/CMakeLists.txt:62 (configure_amrex)
CMake Warning at Tools/CMake/AMReX_Defines.cmake:118 (message):
+++++++++ FortranCInterface_GLOBAL_SUFFIX='' ++++++++++++++++
Call Stack (most recent call first):
Tools/CMake/AMReX_Config.cmake:41 (set_amrex_defines)
Src/CMakeLists.txt:62 (configure_amrex)
CMake Warning at Tools/CMake/AMReX_Defines.cmake:119 (message):
+++++++++ FortranCInterface_GLOBAL_CASE='' ++++++++++++++++
Call Stack (most recent call first):
Tools/CMake/AMReX_Config.cmake:41 (set_amrex_defines)
Src/CMakeLists.txt:62 (configure_amrex)
This means that the FortranCInterface_GLOBAL_PREFIX
is empty -- probably not being set because the C/Fortran interface determination fails 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for those details. That explains a lot... very empty action there is.
Probably one can spot it here:
- https://gitlab.kitware.com/cmake/cmake/-/blob/v3.17.3/Modules/FortranCInterface.cmake
- https://gitlab.kitware.com/cmake/cmake/-/blob/v3.17.3/Modules/FortranCInterface/Detect.cmake
There is a try_compile
being called which fails:
https://gitlab.kitware.com/cmake/cmake/-/blob/v3.17.3/Modules/FortranCInterface/Detect.cmake#L31-41
According to the docs we can pass --debug-trycompile
to the cmake ..
call to get more verbose output about this.
cmake \
-DENABLE_PARTICLES=ON \
-DENABLE_AMRDATA=ON \
-DENABLE_EB=ON \
-DENABLE_OMP=ON \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX="." \
-DCMAKE_C_COMPILER=(which gcc-8) \
-DCMAKE_CXX_COMPILER=(which g++-8) \
-DCMAKE_Fortran_COMPILER=(which gfortran-8) \
--debug-trycompile ..
(Note: -DCMAKE_INSTALL_PREFIX="."
looks dangerous, this will at some point interleave temporary build files with install files on make install
.)
Maybe we already see more CMake output, but otherwise we should get files in <bindir>/CMakeFiles/CMakeTmp
. We should potentially do a
message(FATAL_ERROR "I am outta here")
between the two include()
lines https://github.com/AMReX-Codes/amrex/blob/development/Tools/CMake/AMReX_Defines.cmake#L96 to get the latest try_compile
files in that temporary directory.
I would be curious why this compile failed for you...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I do this, I get (in the CMakeError.log
) this:
ld: warning: ignoring file libmyfort.a, file was built for archive which is not the architecture being linked (x86_64): libmyfort.a
The problem was that my macOS install has howebrew's binutils
in the PATH
(which comes with the wrong sort of ar
util) -- removing this from PATH
fixes the problem.
Cheers!
Guess the FORTLINK API convention is `UNDERSCORE` for unknown values, unless it's the classic (non-clang) IBM Fortran compiler, where it's `LOWERCASE`.
Offline discussed: Let's please keep this open until @JBlaschke had a chance to test this. |
@ax3l Now getting around to this -- answering your questions in order: macOS: 10.14.6 (good old default NERSC laptop); compilers: GNU 8.4.0 (hombrew -- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version doesn't trigger the edge case that I'm running into -- cf. ax3l#1 for a suggested fix
add edge case where FORTLINK couldn't be determined by CMake
@JBlaschke thank you for testing this - your PR looks absolutely correct, we cannot build a string from half of another (empty) variable and want to jump in that |
Founds something random about IBM XL today with respect to this. Just to document here:
|
* FORTLINK: Guess of Unknown Guess the FORTLINK API convention is `UNDERSCORE` for unknown values, unless it's the classic (non-clang) IBM Fortran compiler, where it's `LOWERCASE`. * add edge case where FORTLINK couldn't be determined by CMake Co-authored-by: Johannes Blaschke <jpblaschke@lbl.gov>
Guess the FORTLINK API convention is
UNDERSCORE
for unknown values, unless it's the classic (non-clang) IBM Fortran compiler, where it'sLOWERCASE
.@JBlaschke encountered this on macOS 10.14.6 with GNU 8.4.0 (from homebrew).