From 7266cc9b92b14a4b46c51f30f64f61233c941632 Mon Sep 17 00:00:00 2001 From: Ashwin Kumar Karnad <46030335+iamashwin99@users.noreply.github.com> Date: Mon, 27 Mar 2023 20:13:28 +0200 Subject: 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 --- .../repos/builtin/packages/octopus/package.py | 37 ++++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/octopus/package.py b/var/spack/repos/builtin/packages/octopus/package.py index 01167d8a21..cb7e63c956 100644 --- a/var/spack/repos/builtin/packages/octopus/package.py +++ b/var/spack/repos/builtin/packages/octopus/package.py @@ -219,16 +219,33 @@ class Octopus(AutotoolsPackage, CudaPackage): # 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 - - 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) + # We can disable variable tracking at assignments introduced in GCC10 + # for debug variant to decrease compile time. + + # 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 -- cgit v1.2.3-60-g2f50