Skip to content

Commit fa6567a

Browse files
committed
Clean up logical flow for setting LDFLAGS to build for Linux and OSX
Add more specific comments describing what is going on.
1 parent 8afb9b3 commit fa6567a

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

unix/Makefile

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

32-
LDFLAGS = $(LDFLAGS_MOD) -lm -Wl$(LDFLAGS_MAP_EXTRA) $(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
3336
ifeq ($(UNAME_S),Darwin)
34-
# Force OSX to use clang even if gcc is present, value set in mkenv.mk
35-
# must be ovewritten here to avoid breaking stmhal build on OSX
3637
CC = clang
37-
# Use clang syntax for LDFLAGS
38-
LDFLAGS_MAP_EXTRA = ,-map,$@.map
38+
# Use clang syntax for map file and set osx specific flags
39+
LDFLAGS_ARCH = -Wl,-order_file,$(BUILD)/order.def -Wl,-map,$@.map
3940
else
40-
# Use gcc syntax
41-
LDFLAGS_MAP_EXTRA = ,-Map=$@.map,--cref
41+
# Use gcc syntax for map file
42+
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
4243
endif
44+
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
4345

4446
ifeq ($(MICROPY_FORCE_32BIT),1)
4547
CFLAGS += -m32
@@ -89,9 +91,6 @@ SRC_C = \
8991
$(SRC_MOD)
9092

9193
ifeq ($(UNAME_S),Darwin)
92-
93-
LDFLAGS += -Wl,-order_file,$(BUILD)/order.def
94-
9594
# Must be the last file in list of sources
9695
SRC_C += seg_helpers.c
9796

0 commit comments

Comments
 (0)