aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Mussared2020-04-03 12:55:14 +1100
committerDamien George2020-04-13 21:20:32 +1000
commit45cf76465c5fae8349aa65b78328d38ecab7308d (patch)
tree519129cb2bf0994b798ac27f6559f41a097752d2
parentf66c9895169090e05ba5d0d9fc9b191dc072c96f (diff)
unix: Fix behaviour of COPT/NDEBUG for unix variants.
Based on eg 1e6fd9f2b4072873f5d6846b19b2ef0ccc5e4e52, it's understood that the intention for unix builds is that regular builds disable assert, but the coverage build should set -O0 and enable asserts. It looks like this didn't work (even before variants were introduced, eg at v1.11) -- coverage always built with -Os and -DNDEBUG. This commit makes it possible for variants to have finer-grained control over COPT flags, and enables assert() and -O0 on coverage builds. Other variants already match the defaults so they have been updated.
-rw-r--r--ports/unix/Makefile14
-rw-r--r--ports/unix/variants/coverage/mpconfigvariant.mk3
-rw-r--r--ports/unix/variants/fast/mpconfigvariant.mk2
-rw-r--r--ports/unix/variants/minimal/mpconfigvariant.mk2
4 files changed, 14 insertions, 7 deletions
diff --git a/ports/unix/Makefile b/ports/unix/Makefile
index a0225b265..ac6763186 100644
--- a/ports/unix/Makefile
+++ b/ports/unix/Makefile
@@ -44,10 +44,18 @@ CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) -I$(VARIANT_DI
# Debugging/Optimization
ifdef DEBUG
-CFLAGS += -g
-COPT = -O0
+COPT ?= -O0
else
-COPT = -Os -fdata-sections -ffunction-sections -DNDEBUG
+COPT ?= -Os
+COPT += -fdata-sections -ffunction-sections
+COPT += -DNDEBUG
+endif
+
+# 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.
+CFLAGS += -g
+
+ifndef DEBUG
# _FORTIFY_SOURCE is a feature in gcc/glibc which is intended to provide extra
# security for detecting buffer overflows. Some distros (Ubuntu at the very least)
# have it enabled by default.
diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk
index 0bfc4f84c..d5c41a157 100644
--- a/ports/unix/variants/coverage/mpconfigvariant.mk
+++ b/ports/unix/variants/coverage/mpconfigvariant.mk
@@ -1,6 +1,7 @@
PROG ?= micropython-coverage
-COPT = -O0
+# Disable optimisations and enable assert() on coverage builds.
+DEBUG ?= 1
CFLAGS += \
-fprofile-arcs -ftest-coverage \
diff --git a/ports/unix/variants/fast/mpconfigvariant.mk b/ports/unix/variants/fast/mpconfigvariant.mk
index e6022291d..d67f7c8f3 100644
--- a/ports/unix/variants/fast/mpconfigvariant.mk
+++ b/ports/unix/variants/fast/mpconfigvariant.mk
@@ -1,6 +1,6 @@
# build synthetically fast interpreter for benchmarking
-COPT = "-O2 -DNDEBUG -fno-crossjumping"
+COPT += "-fno-crossjumping -O2"
PROG = micropython-fast
diff --git a/ports/unix/variants/minimal/mpconfigvariant.mk b/ports/unix/variants/minimal/mpconfigvariant.mk
index 3916c8c9a..ec3b21c0b 100644
--- a/ports/unix/variants/minimal/mpconfigvariant.mk
+++ b/ports/unix/variants/minimal/mpconfigvariant.mk
@@ -1,6 +1,4 @@
# build a minimal interpreter
-COPT = -Os -DNDEBUG
-
PROG = micropython-minimal
FROZEN_MANIFEST =