Skip to content

Commit f2892bd

Browse files
muellermartindpgeorge
authored andcommitted
unix: Fix Makefile to handle gc-sections linker flags on Mac OS.
The linker flag --gc-sections is not available on the linker used on Mac OS X which results in an error when linking micropython on Mac OS X. Therefore move this option to the LDFLAGS_ARCH variable on non Darwin systems. According to http://stackoverflow.com/a/17710056 the equivalent to --gc-sections is -dead_strip thus this option is used for the LDFLAGS_ARCH on Darwin systems.
1 parent ab8a5d5 commit f2892bd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

unix/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ endif
6363
ifeq ($(UNAME_S),Darwin)
6464
CC = clang
6565
# Use clang syntax for map file
66-
LDFLAGS_ARCH = -Wl,-map,$@.map
66+
LDFLAGS_ARCH = -Wl,-map,$@.map -Wl,-dead_strip
6767
else
6868
# Use gcc syntax for map file
69-
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
69+
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
7070
endif
71-
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) -Wl,--gc-sections
71+
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
7272

7373
ifeq ($(MICROPY_FORCE_32BIT),1)
7474
# Note: you may need to install i386 versions of dependency packages,

0 commit comments

Comments
 (0)