Summary
The current recipe for parmetis allows conflicting optimization levels to appear on the compile line in a way that isn't expected. For example: spack -d install parmetis%gcc cflags="-O3 -march=native" doesn't compile with the expected CFLAGS. I expect to see compile lines similar to this:
/usr/bin/gcc -O3 -march=native <include directives and defines> -o file.o -c file.c
Actual Result
/usr/bin/gcc -O3 -march=native <include directives and defines> -O2 -g -DNDEBUG -o file.o -c file.c
Because -O2 is listed after -O3 the optimization is not what I expect. I believe the -O2 -g -DNDEBUG flags are inserted by CMake as they are the default CMAKE_C_FLAGS_RELWITHDEBINFO values for gcc.
Possible solution
If SPACK_CFLAGS is set in the build environment, then zero-out the cmake defaulted CMAKE_C_FLAGS_XXX variables. #6839 demonstrates this model for metis and #6860 demonstrates this for parmetis, but I think it should be included in CMakePackage (possibly via the flag_handler function).
Related Issues
#6640
#6749
#6839
#6860
Summary
The current recipe for parmetis allows conflicting optimization levels to appear on the compile line in a way that isn't expected. For example:
spack -d install parmetis%gcc cflags="-O3 -march=native"doesn't compile with the expected CFLAGS. I expect to see compile lines similar to this:Actual Result
Because
-O2is listed after-O3the optimization is not what I expect. I believe the-O2 -g -DNDEBUGflags are inserted by CMake as they are the defaultCMAKE_C_FLAGS_RELWITHDEBINFOvalues for gcc.Possible solution
If
SPACK_CFLAGSis set in the build environment, then zero-out the cmake defaultedCMAKE_C_FLAGS_XXXvariables. #6839 demonstrates this model for metis and #6860 demonstrates this for parmetis, but I think it should be included inCMakePackage(possibly via theflag_handlerfunction).Related Issues
#6640
#6749
#6839
#6860