Skip to content

Commit

Permalink
Only add -stdlib=xxxxx flags if they are not already defined
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfloat committed Dec 1, 2018
1 parent bf18904 commit de1ed32
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ OBJCONV = objconv

CPPFLAGS_add = -I$(LIBOSXUNWIND_HOME)/src -I$(LIBOSXUNWIND_HOME)/include -DNDEBUG
CFLAGS_add = -std=c99 -Wall -O3
CXXFLAGS_add = -std=c++11 -Wall -O3
LDFLAGS_add = -nodefaultlibs -Wl,-upward-lSystem -Wl,-umbrella,System
SFLAGS_add = -x assembler-with-cpp

# If `-stdlib=` is specified within our environment variables, then don't add another command line argument asking to link against it..
ifneq (,$(findstring -stdlib=,$(CC) $(CPPFLAGS) $(CXXFLAGS)))
# If our clang is new enough, then we need to add in `-stdlib=libstdc++`.
CLANG_MAJOR_VER := $(shell clang -v 2>&1 | grep LLVM | cut -d' ' -f 4 | cut -d'.' -f 1)
ifeq ($(shell [ $(CLANG_MAJOR_VER) -ge 8 ] && echo true),true)
CXXFLAGS_add = -std=c++11 -stdlib=libstdc++ -Wall -O3
LDFLAGS_add = -nodefaultlibs -stdlib=libstdc++ -Wl,-upward-lSystem -Wl,-umbrella,System
CXXFLAGS_add += -stdlib=libstdc++
LDFLAGS_add += -stdlib=libstdc++
else
CXXFLAGS_add = -std=c++11 -Wall -O3
LDFLAGS_add = -nodefaultlibs -Wl,-upward-lSystem -Wl,-umbrella,System -lstdc++
LDFLAGS_add += -lstdc++
endif
endif

# Files (in src/)
Expand Down

0 comments on commit de1ed32

Please sign in to comment.