8000 Merge pull request #871 from blmorris/osx_build_fix · comfuture/micropython@9f53275 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f53275

Browse files
committed
Merge pull request micropython#871 from blmorris/osx_build_fix
Fix unix/Makefile to build on OSX
2 parents eaaebf3 + fa6567a commit 9f53275

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

unix/Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,19 @@ else
2929
COPT = -Os #-DNDEBUG
3030
endif
3131

32-
LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-Map=$@.map,--cref $(LDFLAGS_EXTRA)
32+
# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed.
33+
# The unix port of micropython on OSX must be compiled with clang,
34+
# while cross-compile ports require gcc, so we test here for OSX and
35+
# if necessary override the value of 'CC' set in py/mkenv.mk
36+
ifeq ($(UNAME_S),Darwin)
37+
CC = clang
38+
# Use clang syntax for map file and set osx specific flags
39+
LDFLAGS_ARCH = -Wl,-order_file,$(BUILD)/order.def -Wl,-map,$@.map
40+
else
41+
# Use gcc syntax for map file
42+
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
43+
endif
44+
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
3345

3446
ifeq ($(MICROPY_FORCE_32BIT),1)
3547
CFLAGS += -m32
@@ -79,9 +91,6 @@ SRC_C = \
7991
$(SRC_MOD)
8092

8193
ifeq ($(UNAME_S),Darwin)
82-
83-
LDFLAGS+ = -Wl,-order_file,$(BUILD)/order.def
84-
8594
# Must be the last file in list of sources
8695
SRC_C += seg_helpers.c
8796

@@ -92,7 +101,7 @@ seg_helpers.c: $(BUILD)/order.def
92101
$(BUILD)/order.def:
93102
$(Q)echo "seg_helpers.o: ___bss_start" > $@
94103
endif
95-
104+
96105
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
97106

98107
include ../py/mkrules.mk

0 commit comments

Comments
 (0)
0