From: Gabe Black Date: Fri, 23 Oct 2020 03:00:46 +0000 (-0700) Subject: util: Add a --debug-build option to the m5 util scons. X-Git-Tag: develop-gem5-snapshot~396 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a1a1adf3bd5d454b281a8747edde1648c23e869e;p=gem5.git 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 --- 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.