From a1a1adf3bd5d454b281a8747edde1648c23e869e Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 22 Oct 2020 20:00:46 -0700 Subject: [PATCH] util: Add a --debug-build option to the m5 util scons. This enables debug info with -g, and disables optimization with -O0. Change-Id: I788585c379f048d373c54dc04e7c460914d6912e Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27753 Maintainer: Bobby R. Bruce Reviewed-by: Gabe Black Tested-by: kokoro --- util/m5/README.md | 6 ++++++ util/m5/SConstruct | 11 +++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/util/m5/README.md b/util/m5/README.md index 0e94c28de..f1d9bece3 100644 --- a/util/m5/README.md +++ b/util/m5/README.md @@ -143,6 +143,8 @@ build products. This includes: ## Build options +### SCons variables + There are some variables which set build options which need to be controlled on a per ABI level. Currently, these are: @@ -170,6 +172,10 @@ meaning that the native/host compiler will be used. If building on a non-x86 host, then you'll need to set an appopriate prefix and may be able to clear some other prefix corresponding to that host. +### SCons command line flags + +--debug-build: Compile with the -g option, and -O0. + ## External dependency detection In some cases, if an external dependency isn't detected, the build will diff --git a/util/m5/SConstruct b/util/m5/SConstruct index e1d7e1dfd..8462cab69 100644 --- a/util/m5/SConstruct +++ b/util/m5/SConstruct @@ -42,9 +42,16 @@ build_dir = Dir('build') def abspath(d): return os.path.abspath(str(d)) +AddOption('--debug-build', dest='debug_build', action='store_true', + help='Build with debug info, and disable optimizations.') + # Universal settings. -main.Append(CXXFLAGS=[ '-O2' ]) -main.Append(CCFLAGS=[ '-O2' ]) +if GetOption('debug_build'): + main.Append(CXXFLAGS=[ '-O0', '-g' ]) + main.Append(CCFLAGS=[ '-O0', '-g' ]) +else: + main.Append(CXXFLAGS=[ '-O2' ]) + main.Append(CCFLAGS=[ '-O2' ]) main.Append(CPPPATH=[ common_include ]) # Propogate the environment's PATH setting. -- 2.30.2