LLNL / serac

Serac is a high order nonlinear thermomechanical simulation code
BSD 3-Clause "New" or "Revised" License
180 stars 33 forks source link

invalid compilation flags being passed to serac targets #1020

Closed samuelpmishLLNL closed 4 months ago

samuelpmishLLNL commented 11 months ago

Currently, building serac with g++ + codevelop produces a flood of warning messages. Practically every single translation unit emits at least two warnings about Fortran-specific flags inappropriately leaking into the C++ project:

[build] cc1plus: warning: command-line option ‘-fallow-invalid-boz’ is valid for Fortran but not for C++
[build] cc1plus: warning: command-line option ‘-fallow-argument-mismatch’ is valid for Fortran but not for C++

This is even more problematic when using clang, as it doesn't allow (invalid) Fortran flags to be passed to a C++ compiler, so they turn into errors, rather than warnings. Additionally, some other gcc specific flags are leaking into the build, like

clang: warning: optimization flag '-ffat-lto-objects' is not supported

which isn't a deal breaker, but does make the build logs harder to understand. When codevelop isn't enabled, every sourcefile fails to compile with another unsupported compilation flag:

clang: error: unknown argument: '-fcompare-debug-second'

Near the tail end of the gcc builds, there is another large block (about ~2500) of warning messages relating to superLU source files:

[build] /tmp/sam/spack-stage/spack-stage-superlu-dist-8.1.2-6loxhdw3s5jibbdrb6ve6bnnkjgbboit/spack-src/SRC/dnrformat_loc3d.c:254:17: warning: ‘B1’ may be used uninitialized [-Wmaybe-uninitialized]
[build]   254 |         double *B1;
[build]       |                 ^
[build] /tmp/sam/spack-stage/spack-stage-superlu-dist-8.1.2-6loxhdw3s5jibbdrb6ve6bnnkjgbboit/spack-src/SRC/dmach_dist.c: In function ‘dmach_dist’:
[build] /tmp/sam/spack-stage/spack-stage-superlu-dist-8.1.2-6loxhdw3s5jibbdrb6ve6bnnkjgbboit/spack-src/SRC/dmach_dist.c:92:12: warning: ‘rmach’ may be used uninitialized [-Wmaybe-uninitialized]
[build]    92 |     return rmach;

It's not clear to me why our build is worrying about files that are not compiled by this project.

samuelpmishLLNL commented 11 months ago

Some insightful comments by Cyrus helped reveal that the Fortran-specific flags are being introduced to serac through BLT aggregating compiler flags from mpi compiler wrappers. As a workaround, users can manually modify the compiler wrappers (e.g. mpif90) to remove the -fallow-invalid-boz and -fallow-argument-mismatch flags so that our build system does not apply them to C++ files.

However, this still does not fix the last error message:

clang: error: unknown argument: '-fcompare-debug-second'

It's still unclear to me where that one is coming from.

white238 commented 4 months ago

Fixed in #1074