octopus: Update compiler flags (#36446)

* octopus: set the right compiler flags
  https://github.com/fangohr/octopus-in-spack/pull/70
* octopus: fix pep8 style issue
This commit is contained in:
Ashwin Kumar Karnad 2023-03-27 20:13:28 +02:00 committed by GitHub
parent cc4a528274
commit 7266cc9b92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -219,16 +219,33 @@ def configure_args(self):
# In case of GCC version 10, we will have errors because of
# argument mismatching. Need to provide a flag to turn this into a
# warning and build sucessfully
# We can disable variable tracking at assignments introduced in GCC10
# for debug variant to decrease compile time.
fcflags = "FCFLAGS=-O2 -ffree-line-length-none"
fflags = "FFLAGS=O2 -ffree-line-length-none"
if spec.satisfies("%gcc@10:"):
gcc10_extra = "-fallow-argument-mismatch -fallow-invalid-boz"
args.append(fcflags + " " + gcc10_extra)
args.append(fflags + " " + gcc10_extra)
else:
args.append(fcflags)
args.append(fflags)
# Set optimization level for all flags
opt_level = "-O2"
fcflags = f"FCFLAGS={opt_level} -ffree-line-length-none"
cxxflags = f"CXXFLAGS={opt_level}"
cflags = f"CFLAGS={opt_level}"
# Add extra flags for gcc 10 or higher
gcc10_extra = (
"-fallow-argument-mismatch -fallow-invalid-boz"
if spec.satisfies("%gcc@10:")
else ""
)
# Add debug flag if needed
if spec.satisfies("+debug"):
fcflags += " -g"
cxxflags += " -g"
cflags += " -g"
gcc10_extra += (
"-fno-var-tracking-assignments" if spec.satisfies("%gcc@10:") else ""
)
args.append(f"{fcflags} {gcc10_extra}")
args.append(f"{cxxflags} {gcc10_extra}")
args.append(f"{cflags} {gcc10_extra}")
return args