Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --keep-debug-symbols configuration option to set default value of 'debug' toolchain option, and enable it by default so -g is included in $CXXFLAGS & co #4688

Merged
merged 10 commits into from
Dec 11, 2024
1 change: 1 addition & 0 deletions easybuild/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
'cleanup_tmpdir',
'extended_dry_run_ignore_errors',
'fixed_installdir_naming_scheme',
'keep_debug_symbols',
'lib_lib64_symlink',
'lib64_fallback_sanity_check',
'lib64_lib_symlink',
Expand Down
1 change: 1 addition & 0 deletions easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ def override_options(self):
'insecure-download': ("Don't check the server certificate against the available certificate authorities.",
None, 'store_true', False),
'install-latest-eb-release': ("Install latest known version of easybuild", None, 'store_true', False),
'keep-debug-symbols': ("Sets default value of debug toolchain option", None, 'store_true', True),
'lib-lib64-symlink': ("Automatically create symlinks for lib/ pointing to lib64/ if the former is missing",
None, 'store_true', True),
'lib64-fallback-sanity-check': ("Fallback in sanity check to lib64/ equivalent for missing libraries",
Expand Down
7 changes: 6 additions & 1 deletion easybuild/tools/toolchain/compiler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# #
# Copyright 2012-2024 Ghent University

#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
Expand Down Expand Up @@ -82,7 +83,7 @@ class Compiler(Toolchain):
'loose': (False, "Loose precision"),
'veryloose': (False, "Very loose precision"),
'verbose': (False, "Verbose output"),
'debug': (False, "Enable debug"),
'debug': (None, "Keep debug symbols"), # default value set by build option keep-debug-symbols
'i8': (False, "Integers are 8 byte integers"), # fortran only -> no: MKL and icc give -DMKL_ILP64
'r8': (False, "Real is 8 byte real"), # fortran only
'unroll': (False, "Unroll loops"),
Expand Down Expand Up @@ -175,6 +176,10 @@ def set_variables(self):

def _set_compiler_toolchainoptions(self):
"""Set the compiler related toolchain options"""
# Initialize default value of debug symbols based on global build option
Micket marked this conversation as resolved.
Show resolved Hide resolved
if self.COMPILER_SHARED_OPTS:
_, desc = self.COMPILER_SHARED_OPTS['debug']
self.COMPILER_SHARED_OPTS['debug'] = (build_option('keep_debug_symbols'), desc)
self.options.add_options(self.COMPILER_SHARED_OPTS, self.COMPILER_SHARED_OPTION_MAP)

# always include empty infix first for non-prefixed compilers (e.g., GCC, Intel, ...)
Expand Down
2 changes: 1 addition & 1 deletion test/framework/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -5435,7 +5435,7 @@ def test_dump_env_script(self):
"module load hwloc/1.11.8-GCC-4.6.4", # loading of dependency module
# defining build env
"export FC='gfortran'",
"export CFLAGS='-O2 -ftree-vectorize -m(arch|cpu)=native -fno-math-errno'",
"export CFLAGS='-O2 -ftree-vectorize -m(arch|cpu)=native -fno-math-errno -g'",
]
for pattern in patterns:
regex = re.compile("^%s$" % pattern, re.M)
Expand Down
20 changes: 10 additions & 10 deletions test/framework/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def test_toolchain_compiler_env_vars(self):
self.assertEqual(os.getenv('OMPI_F77'), 'gfortran')
self.assertEqual(os.getenv('OMPI_FC'), 'gfortran')

flags_regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native -fno-math-errno")
flags_regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native -fno-math-errno -g")
for key in ['CFLAGS', 'CXXFLAGS', 'F90FLAGS', 'FCFLAGS', 'FFLAGS']:
val = os.getenv(key)
self.assertTrue(flags_regex.match(val), "'%s' should match pattern '%s'" % (val, flags_regex.pattern))
Expand Down Expand Up @@ -928,7 +928,7 @@ def test_precision_flags(self):
tc.set_options({})
with self.mocked_stdout_stderr():
tc.prepare()
flags_regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native -fno-math-errno")
flags_regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native -fno-math-errno -g")
for var in flag_vars:
val = os.getenv(var)
self.assertTrue(flags_regex.match(val), "'%s' should match pattern '%s'" % (val, flags_regex.pattern))
Expand All @@ -947,7 +947,7 @@ def test_precision_flags(self):
tc.prepare()
for var in flag_vars:
if enable:
regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native %s" % prec_flags[prec])
regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native %s -g" % prec_flags[prec])
else:
regex = flags_regex
val = os.getenv(var)
Expand Down Expand Up @@ -1278,7 +1278,7 @@ def test_fosscuda(self):
tc.prepare()

archflags = tc.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[(tc.arch, tc.cpu_family)]
optflags = "-O2 -ftree-vectorize -%s -fno-math-errno -fopenmp" % archflags
optflags = "-O2 -ftree-vectorize -%s -fno-math-errno -g -fopenmp" % archflags
nvcc_flags = r' '.join([
r'-Xcompiler="%s"' % optflags,
# the use of -lcudart in -Xlinker is a bit silly but hard to avoid
Expand Down Expand Up @@ -2193,12 +2193,12 @@ def test_independence(self):
init_config(build_options={'optarch': 'test', 'silent': True})

tc_cflags = {
'CrayCCE': "-O2 -homp -craype-verbose",
'CrayGNU': "-O2 -fno-math-errno -fopenmp -craype-verbose",
'CrayIntel': "-O2 -ftz -fp-speculation=safe -fp-model source -fopenmp -craype-verbose",
'GCC': "-O2 -ftree-vectorize -test -fno-math-errno -fopenmp",
'iccifort': "-O2 -test -ftz -fp-speculation=safe -fp-model source -fopenmp",
'intel-compilers': "-O2 -test -ftz -fp-speculation=safe -fp-model precise -qopenmp",
'CrayCCE': "-O2 -g -homp -craype-verbose",
'CrayGNU': "-O2 -fno-math-errno -g -fopenmp -craype-verbose",
'CrayIntel': "-O2 -ftz -fp-speculation=safe -fp-model source -g -fopenmp -craype-verbose",
'GCC': "-O2 -ftree-vectorize -test -fno-math-errno -g -fopenmp",
'iccifort': "-O2 -test -ftz -fp-speculation=safe -fp-model source -g -fopenmp",
'intel-compilers': "-O2 -test -ftz -fp-speculation=safe -fp-model precise -g -qopenmp",
}

toolchains = [
Expand Down
Loading