Skip to content

Commit

Permalink
Add configuration to set the debug symbol level
Browse files Browse the repository at this point in the history
Default to -g1 to strike a balance between symbol utility and
compilation speed.
  • Loading branch information
trflynn89 committed Aug 27, 2022
1 parent 8ebee19 commit fb74e73
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ The following options may be specified to configure the build:
| `mode` | `debug`, `release`, `profile` | `debug` | Compilation mode<sup>2</sup>. |
| `arch` | `x86`, `x64` | Defaults to host architecture | Compilation architecture, 32-bit or 64-bit. |
| `strict` | `0`, `1`, `2` | `2` | Compiler warning level<sup>3</sup>. |
| `symbols` | Any valid `-g` option | `1` | Debug symbol level, passed directly to `-g`. |
| `cstandard` | Any valid `-std` option | `c2x` | The language standard to use for C files, passed directly to `-std`. |
| `cxxstandard` | Any valid `-std` option | `c++2a` | The language standard to use for C++ files, passed directly to `-std`. |
| `linker` | Any valid `-fuse-ld` option | `lld` on Linux, `ld` on macOS | The linker to use for creating executables, passed directly to `-fuse-ld`. |
Expand Down
3 changes: 3 additions & 0 deletions src/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ arch ?= $(arch)
# Compiler warning level (0, 1, 2).
strict ?= 2

# Debug symbol level (0, 1, 2, 3).
symbols ?= 1

# C language standard.
cstandard ?= c2x

Expand Down
4 changes: 2 additions & 2 deletions src/flags.mk
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ JFLAGS += \

# Add debug symbols, optimize release builds, or add profiling symbols.
ifeq ($(mode), debug)
CF_ALL += -O0 -g
CF_ALL += -O0 -g$(symbols)
JFLAGS += -g:lines,vars,source
else ifeq ($(mode), release)
CF_ALL += -O2 -DNDEBUG
JFLAGS += -g:none
else ifeq ($(mode), profile)
ifeq ($(toolchain), gcc)
CF_ALL += -O2 -DNDEBUG -g -pg -DFLY_PROFILE
CF_ALL += -O2 -DNDEBUG -g$(symbols) -pg -DFLY_PROFILE
LDFLAGS += -pg
else
$(error Profiling not supported with toolchain $(toolchain), check flags.mk)
Expand Down

0 comments on commit fb74e73

Please sign in to comment.