From 1fae7874931d07c4cfa08fa447b6d9c3805e40af Mon Sep 17 00:00:00 2001 From: blmorris Date: Mon, 22 Sep 2014 15:16:14 -0400 Subject: [PATCH 1/3] Fix unix/Makefile to build on OSX Force OSX to compile with clang even if gcc is available Change LDFLAGS syntax to be compatible with clang Fix questionable syntax on line 90 Remove extraneous tab character --- unix/Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/unix/Makefile b/unix/Makefile index fff6fe0944..8bbe5554d5 100644 --- a/unix/Makefile +++ b/unix/Makefile @@ -30,6 +30,13 @@ COPT = -Os #-DNDEBUG endif LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-Map=$@.map,--cref $(LDFLAGS_EXTRA) +ifeq ($(UNAME_S),Darwin) +# Force OSX to use clang even if gcc is present, value set in mkenv.mk +# must be ovewritten here to avoid breaking stmhal build on OSX +CC = clang +# Use clang syntax for LDFLAGS +LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-map,$@.map $(LDFLAGS_EXTRA) +endif ifeq ($(MICROPY_FORCE_32BIT),1) CFLAGS += -m32 @@ -80,7 +87,7 @@ SRC_C = \ ifeq ($(UNAME_S),Darwin) -LDFLAGS+ = -Wl,-order_file,$(BUILD)/order.def +LDFLAGS += -Wl,-order_file,$(BUILD)/order.def # Must be the last file in list of sources SRC_C += seg_helpers.c @@ -92,7 +99,7 @@ seg_helpers.c: $(BUILD)/order.def $(BUILD)/order.def: $(Q)echo "seg_helpers.o: ___bss_start" > $@ endif - + OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) include ../py/mkrules.mk From 8afb9b3863358c4a903aff67af6ccfc854bb65cb Mon Sep 17 00:00:00 2001 From: blmorris Date: Mon, 22 Sep 2014 23:00:42 -0400 Subject: [PATCH 2/3] Incorporate change in assignment logic suggested by dhylands --- unix/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/unix/Makefile b/unix/Makefile index 8bbe5554d5..3e74d7e2e6 100644 --- a/unix/Makefile +++ b/unix/Makefile @@ -29,13 +29,16 @@ else COPT = -Os #-DNDEBUG endif -LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-Map=$@.map,--cref $(LDFLAGS_EXTRA) +LDFLAGS = $(LDFLAGS_MOD) -lm -Wl$(LDFLAGS_MAP_EXTRA) $(LDFLAGS_EXTRA) ifeq ($(UNAME_S),Darwin) # Force OSX to use clang even if gcc is present, value set in mkenv.mk # must be ovewritten here to avoid breaking stmhal build on OSX CC = clang # Use clang syntax for LDFLAGS -LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-map,$@.map $(LDFLAGS_EXTRA) +LDFLAGS_MAP_EXTRA = ,-map,$@.map +else +# Use gcc syntax +LDFLAGS_MAP_EXTRA = ,-Map=$@.map,--cref endif ifeq ($(MICROPY_FORCE_32BIT),1) From fa6567a39f4d3350d90d6fa862ef1f84b76e2150 Mon Sep 17 00:00:00 2001 From: blmorris Date: Tue, 23 Sep 2014 09:42:18 -0400 Subject: [PATCH 3/3] Clean up logical flow for setting LDFLAGS to build for Linux and OSX Add more specific comments describing what is going on. --- unix/Makefile | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/unix/Makefile b/unix/Makefile index 3e74d7e2e6..a6b5026e21 100644 --- a/unix/Makefile +++ b/unix/Makefile @@ -29,17 +29,19 @@ else COPT = -Os #-DNDEBUG endif -LDFLAGS = $(LDFLAGS_MOD) -lm -Wl$(LDFLAGS_MAP_EXTRA) $(LDFLAGS_EXTRA) +# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed. +# The unix port of micropython on OSX must be compiled with clang, +# while cross-compile ports require gcc, so we test here for OSX and +# if necessary override the value of 'CC' set in py/mkenv.mk ifeq ($(UNAME_S),Darwin) -# Force OSX to use clang even if gcc is present, value set in mkenv.mk -# must be ovewritten here to avoid breaking stmhal build on OSX CC = clang -# Use clang syntax for LDFLAGS -LDFLAGS_MAP_EXTRA = ,-map,$@.map +# Use clang syntax for map file and set osx specific flags +LDFLAGS_ARCH = -Wl,-order_file,$(BUILD)/order.def -Wl,-map,$@.map else -# Use gcc syntax -LDFLAGS_MAP_EXTRA = ,-Map=$@.map,--cref +# Use gcc syntax for map file +LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref endif +LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) ifeq ($(MICROPY_FORCE_32BIT),1) CFLAGS += -m32 @@ -89,9 +91,6 @@ SRC_C = \ $(SRC_MOD) ifeq ($(UNAME_S),Darwin) - -LDFLAGS += -Wl,-order_file,$(BUILD)/order.def - # Must be the last file in list of sources SRC_C += seg_helpers.c