Skip to content
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

Cannot build ADIOS2 with clang/gfortran #3253

Open
eschnett opened this issue Jun 15, 2022 · 5 comments
Open

Cannot build ADIOS2 with clang/gfortran #3253

eschnett opened this issue Jun 15, 2022 · 5 comments

Comments

@eschnett
Copy link
Contributor

I am building ADIOS2 2.8.1 via Spack using clang @14.0.5 as C/C++ compiler and gfortran @11.1 as Fortran compiler. This fails when compiling the Fortran interface. The problem is that the flag -fallow-argument-mismatch is passed to clang++, which fails.

cd /tmp/eschnetter/spack-stage/spack-stage-adios2-2.8.1-bgwwyui542uytlc2b6eump6k2k3d6toj/spack-build-bgwwyui/bindings/Fortran && /home/eschnetter/src/spack/lib/spack/env/clang/clang++ -DADIOS2_USE_MPI -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX -Dadios2_fortran_mpi_EXPORTS -I/tmp/eschnetter/spack-stage/spack-stage-adios2-2.8.1-bgwwyui542uytlc2b6eump6k2k3d6toj/spack-build-bgwwyui/bindings/Fortran -I/tmp/eschnetter/spack-stage/spack-stage-adios2-2.8.1-bgwwyui542uytlc2b6eump6k2k3d6toj/spack-src/bindings/C -I/tmp/eschnetter/spack-stage/spack-stage-adios2-2.8.1-bgwwyui542uytlc2b6eump6k2k3d6toj/spack-src/source -I/tmp/eschnetter/spack-stage/spack-stage-adios2-2.8.1-bgwwyui542uytlc2b6eump6k2k3d6toj/spack-build-bgwwyui/source -isystem /home/eschnetter/src/spack/opt/spack/linux-ubuntu18.04-skylake_avx512/clang-14.0.5/mpitrampoline-4.0.2-qxq4cp72man4yt75u6qmanoja2oj2aiy/include -O3 -DNDEBUG -fPIC -fallow-argument-mismatch -fcray-pointer -std=gnu++11 -MD -MT bindings/Fortran/CMakeFiles/adios2_fortran_mpi.dir/f2c/adios2_f2c_io_mpi.cpp.o -MF CMakeFiles/adios2_fortran_mpi.dir/f2c/adios2_f2c_io_mpi.cpp.o.d -o CMakeFiles/adios2_fortran_mpi.dir/f2c/adios2_f2c_io_mpi.cpp.o -c /tmp/eschnetter/spack-stage/spack-stage-adios2-2.8.1-bgwwyui542uytlc2b6eump6k2k3d6toj/spack-src/bindings/Fortran/f2c/adios2_f2c_io_mpi.cpp
clang-14: error: unknown argument: '-fallow-argument-mismatch'
bindings/Fortran/CMakeFiles/adios2_fortran_mpi.dir/build.make:104: recipe for target 'bindings/Fortran/CMakeFiles/adios2_fortran_mpi.dir/f2c/adios2_f2c_adios_mpi.cpp.o' failed

Note that I have configured ADIOS2 with MPItrampoline as MPI implementation. This library adds the flags -fallow-argument-mismatch and -fcray-pointers to the Fortran flags. I do not think that this is relevant because many of ADIOS2 C/C++ source files have been successfully compiled at this time, without using these flags.

I notice that bindings/Fortran/CMakeLists.txt defines adios2_fortran as a list of Fortran source codes, although some of these files are instead C++ files.

@eisenhauer
Copy link
Member

Probably we need more information here. Maybe run "make VERBOSE=1" so we can see what is being compiled when this happens?

@eschnett
Copy link
Contributor Author

I attach the complete configure and build output from Spack:

@eisenhauer
Copy link
Member

@chuckatkins I don't see anything wrong in the cmake spec, but the build seems to be applying CMake_Fortran_FLAGS to C++ compilations when building the adios2_fortran bindings library (which is a mix of C++ and Fortran source). Possible cmake problem?

@eschnett
Copy link
Contributor Author

I have since encountered a very similar problem in superlu_dist. This also points to a cmake problem.

But what about this line in your CMakeLists.txt:

  target_compile_definitions(adios2_fortran PRIVATE "$<$<COMPILE_LANGUAGE:Fortran>:ADIOS2_HAVE_MPI_F>")

Doesn't this declare adios2_fortran to be Fortran code?

@eisenhauer
Copy link
Member

I can't speak as authoritatively as others might, but i think the answer is that that line just adds -DADIOS2_HAVE_MPI_F to the command line for fortran compiles done in building adios2_fortran dependencies. I don't think it declares all the dependencies of adios2_fortran to be fortran source. CMake should infer what is fortran and what is C++ from the filename, unless you override that with something like: "set_source_files_properties(hello-world.f PROPERTIES LANGUAGE Fortran)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants