Skip to content

Commit

Permalink
Merge pull request #37356 from sayke/fix-LTO-on-OSX
Browse files Browse the repository at this point in the history
Update Makefile so LTO works on OSX
  • Loading branch information
ZhilkinSerg authored Jan 25, 2020
2 parents 0756e42 + a7dd190 commit bb2b11c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ ifeq ($(RUNTESTS), 1)
TESTS = tests
endif

# tiles object directories are because gcc gets confused # Appears that the default value of $LD is unsuitable on most systems
# tiles object directories are because gcc gets confused
# Appears that the default value of $LD is unsuitable on most systems

# when preprocessor defines change, but the source doesn't
ODIR = $(BUILD_PREFIX)obj
Expand Down Expand Up @@ -284,6 +285,7 @@ ifdef RELEASE
OPTLEVEL = -Os
endif
endif

ifdef LTO
ifdef CLANG
# LLVM's LTO will complain if the optimization level isn't between O0 and
Expand All @@ -294,7 +296,14 @@ ifdef RELEASE
CXXFLAGS += $(OPTLEVEL)

ifdef LTO
LDFLAGS += -fuse-ld=gold
ifeq ($(NATIVE), osx)
ifdef CLANG
LTOFLAGS += -flto=full
endif
else
LDFLAGS += -fuse-ld=gold # This breaks in OS X because gold can only produce ELF binaries, not Mach
endif

ifdef CLANG
LTOFLAGS += -flto
else
Expand All @@ -304,6 +313,8 @@ ifdef RELEASE
CXXFLAGS += $(LTOFLAGS)

# OTHERS += -mmmx -m3dnow -msse -msse2 -msse3 -mfpmath=sse -mtune=native
# OTHERS += -march=native # Uncomment this to build an optimized binary for your machine only

# Strip symbols, generates smaller executable.
OTHERS += $(RELEASE_FLAGS)
DEBUG =
Expand Down

0 comments on commit bb2b11c

Please sign in to comment.