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

Does the cmake build work with clang? #3645

Open
jbakosi opened this issue Sep 24, 2022 · 7 comments
Open

Does the cmake build work with clang? #3645

jbakosi opened this issue Sep 24, 2022 · 7 comments
Assignees
Labels
CMake The CMake build system Fortran

Comments

@jbakosi
Copy link
Collaborator

jbakosi commented Sep 24, 2022

On debian linux, I do

cmake -DTARGET=LIBS -DNETWORK=mpi -DSMP=off -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=gfortran <charm-src>

and I get

<...>/charmc: line 236: eval: -I: invalid option
eval: usage: eval [arg ...]
Fatal Error by charmc in directory <...>/b
Command -I<...>/b/include -DAMPI_ERRHANDLER_RETURN=0 -DNDEBUG -O3 -O3 -O2 -c <...>/b/pup_f.f90 -o CMakeFiles/conv-utilf.dir/pup_f.f90.o returned error code 2

Seems like a command is missing in charmc:236

DoNoErrCheck() {
	[ -n "$VERBOSE" ] && echo "charmc: Executing $@" 1>&2
	eval "$@"
}

Does someone have a workaround?

@jbakosi jbakosi added the CMake The CMake build system label Sep 24, 2022
@matthiasdiener
Copy link
Contributor

matthiasdiener commented Sep 26, 2022

In general, I would suggest specifying compilers via environment variables, not inside the cmake options, when using cmake directly:

$ CC=mpicc CXX=mpicxx FC=gfortran cmake -DTARGET=LIBS -DNETWORK=mpi -DSMP=off <charm-src>

Does this make a difference for your build?

Edit:
Also, you probably don't need to specify mpicc explicitly with the MPI network:

$ cmake -DTARGET=LIBS -DNETWORK=mpi -DSMP=off <charm-src>

@matthiasdiener matthiasdiener self-assigned this Sep 26, 2022
@jbakosi
Copy link
Collaborator Author

jbakosi commented Sep 26, 2022

As I have multiple mpi installs besides the system-wide one with gcc, e.g., with clang, I usually point cmake to non-system mpi wrappers via either env vars (as you suggest) or via cmake's args. Neither of the above helps though with the error if I have clang behind the mpi wrappers. (Though, I'm also happy with the workaround in #3646.)

@matthiasdiener
Copy link
Contributor

That is interesting. Could you please paste the complete cmake output in a gist and add a link here?

@jbakosi
Copy link
Collaborator Author

jbakosi commented Sep 27, 2022

https://gist.github.com/jbakosi/a827cbdcab0d3bcfdc4df5874703d4e9

It only errors with -DNETWORK=mpi.

@jdmaia
Copy link

jdmaia commented Feb 3, 2023

@matthiasdiener @ebohm I have a couple of colleagues here at AMD who are trying to get Charm++ built with our clang-based AOCC compiler and are snagging in the same error described here. Do you guys have an ETA for a fix on this issue?

@evan-charmworks
Copy link
Contributor

I'm guessing if gfortran is not installed, CMake will blank out CMAKE_Fortran_COMPILER, and that's why the shell sees -I as the first word in the command.

Side note, if you're using mpicc and mpicxx, I would set the Fortran compiler to mpif90 or similar.

@jbakosi
Copy link
Collaborator Author

jbakosi commented Apr 15, 2023

Side note, if you're using mpicc and mpicxx, I would set the Fortran compiler to mpif90 or similar.

I usually do, but for cmake projects that do not enable fortran, this remains an issue.

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

No branches or pull requests

4 participants