diff options
| author | Angus Gratton <angus@redyak.com.au> | 2022-08-15 16:07:00 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-08-15 22:55:34 +1000 |
| commit | a16a330da54afd392252d7ea04139fd4702f48f8 (patch) | |
| tree | 2367d83d35347391eaea46eb8990d0599bde3f6b | |
| parent | 6f4d424f461bede1afb69637763f4fce5f27cd90 (diff) | |
nrf,stm32: Don't enable debug info by default if LTO is on.
It seems sometimes gcc with LTO will generate otherwise valid assembly
listings that cause 'as' to error out when generating DWARF debug info; see
https://sourceware.org/bugzilla/show_bug.cgi?id=29494
Therefore, don't enable -g by default if LTO is on.
Enabling LTO=1 DEBUG=1 is still possible but may result in random errors
at link time due to 'as' (the error in this case is "Error: unaligned
opcodes detected in executable segment", and the only other easy workaround
is CFLAGS+=-fno-jump-tables which may increase code size significantly).
Follows on from fdfe4eca745dce5f20fb65a3c197006b9053999a
| -rw-r--r-- | ports/nrf/Makefile | 6 | ||||
| -rw-r--r-- | ports/stm32/Makefile | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 23be4430f..bc295cac8 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -138,12 +138,14 @@ LDFLAGS += -Wl,'--defsym=_fs_size=$(FS_SIZE)' endif #Debugging/Optimization -CFLAGS += -g # always include debug info in the ELF ifeq ($(DEBUG), 1) #ASMFLAGS += -g -gtabs+ -CFLAGS += -O0 +CFLAGS += -g -O0 LDFLAGS += -O0 else +ifneq ($(LTO), 1) +CFLAGS += -g # always include debug info in the ELF, unless LTO is on +endif CFLAGS += -Os -DNDEBUG LDFLAGS += -Os endif diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile index 657524798..14a93a5aa 100644 --- a/ports/stm32/Makefile +++ b/ports/stm32/Makefile @@ -114,13 +114,15 @@ $(BUILD)/stm32_it.o $(BUILD)/pendsv.o: CFLAGS += -fno-lto endif # Debugging/Optimization -CFLAGS += -g # always include debug info in the ELF ifeq ($(DEBUG), 1) -CFLAGS += -DPENDSV_DEBUG +CFLAGS += -g -DPENDSV_DEBUG COPT ?= -Og # Disable text compression in debug builds MICROPY_ROM_TEXT_COMPRESSION = 0 else +ifneq ($(LTO), 1) +CFLAGS += -g # always include debug info in the ELF, unless LTO is on +endif COPT ?= -Os -DNDEBUG endif |
