diff --git a/ports/unix/Makefile b/ports/unix/Makefile index eae02bf257..52ae8314eb 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -59,8 +59,8 @@ endif # Remove unused sections. COPT += -fdata-sections -ffunction-sections -# Always enable symbols -- They're occasionally useful, and don't make it into the -# final .bin/.hex/.dfu so the extra size doesn't matter. +# Note: Symbols and debug information will still be stripped from the final binary +# unless "DEBUG=1" or "STRIP=" is passed to make, see README.md for details. CFLAGS += -g ifndef DEBUG diff --git a/ports/unix/README.md b/ports/unix/README.md index a1af289968..e15fd93b23 100644 --- a/ports/unix/README.md +++ b/ports/unix/README.md @@ -72,3 +72,17 @@ deplibs`. To actually enable/disable use of dependencies, edit the `ports/unix/mpconfigport.mk` file, which has inline descriptions of the options. For example, to build the SSL module, `MICROPY_PY_SSL` should be set to 1. + +Debug Symbols +------------- + +By default, builds are stripped of symbols and debug information to save size. + +To build a debuggable version of the Unix port, there are two options + +1. Run `make [other arguments] DEBUG=1`. Note setting `DEBUG` also reduces the + optimisation level, so it's not a good option for builds that also want the + best performance. +2. Run `make [other arguments] STRIP=`. Note that the value of `STRIP` is + empty. This will skip the build step that strips symbols and debug + information, but changes nothing else in the build configuration. diff --git a/py/mkrules.mk b/py/mkrules.mk index a3ff85ef82..ec36346b8a 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -212,7 +212,9 @@ $(BUILD)/$(PROG): $(OBJ) # we may want to compile using Thumb, but link with non-Thumb libc. $(Q)$(CC) -o $@ $^ $(LIB) $(LDFLAGS) ifndef DEBUG +ifdef STRIP $(Q)$(STRIP) $(STRIPFLAGS_EXTRA) $@ +endif endif $(Q)$(SIZE) $$(find $(BUILD) -path "$(BUILD)/build/frozen*.o") $@