charm icon indicating copy to clipboard operation
charm copied to clipboard

Does the cmake build work with clang?

Open jbakosi opened this issue 2 years ago • 7 comments

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 avatar Sep 24 '22 13:09 jbakosi

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 avatar Sep 26 '22 17:09 matthiasdiener

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 https://github.com/UIUC-PPL/charm/pull/3646.)

jbakosi avatar Sep 26 '22 18:09 jbakosi

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

matthiasdiener avatar Sep 26 '22 18:09 matthiasdiener

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

It only errors with -DNETWORK=mpi.

jbakosi avatar Sep 27 '22 09:09 jbakosi

@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?

jdmaia avatar Feb 03 '23 17:02 jdmaia

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.

evan-charmworks avatar Apr 15 '23 00:04 evan-charmworks

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.

jbakosi avatar Apr 15 '23 08:04 jbakosi