Add CXXFLAGS to the linker step

The GCC manual states for different parameters that the options for compilation
must also be used when linking. The options for compilation are stored in
CXXFLAGS and added to LINK.o to fix the behavior.

Option which need this are for example -fPIC/-fPIE or -flto.
This commit is contained in:
Sven Eckelmann 2013-05-09 22:22:52 +02:00
parent dfa22c9899
commit d49a2b857f

View file

@ -139,10 +139,10 @@ ifeq ($(OS), OSX)
ifeq ($(CPU), X86)
ifeq ($(ARCH_DETECTED), 64BITS)
CFLAGS += -arch x86_64 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
LDFLAGS += -bundle -framework OpenGL -arch x86_64 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
LDFLAGS += -bundle -framework OpenGL
else
CFLAGS += -arch i686 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
LDFLAGS += -bundle -framework OpenGL -arch i686 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
LDFLAGS += -bundle -framework OpenGL
endif
endif
else
@ -177,10 +177,8 @@ endif
# On 32-bit x86 systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch
ifeq ($(PIC), 1)
CFLAGS += -fPIC
LDFLAGS += -fPIC
else
CFLAGS += -fno-PIC
LDFLAGS += -fno-PIC
endif
ifeq ($(BIG_ENDIAN), 1)
@ -217,7 +215,7 @@ ifneq ($(OS), FREEBSD)
# tweak flags for 32-bit build on 64-bit system
ifeq ($(ARCH_DETECTED), 64BITS_32)
CFLAGS += -m32
LDFLAGS += -m32 -Wl,-m,elf_i386
LDFLAGS += -Wl,-m,elf_i386
endif
endif
else
@ -243,7 +241,7 @@ INSTALL ?= install
MKDIR ?= mkdir -p
COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
COMPILE.cc = $(Q_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
LINK.o = $(Q_LD)$(CXX) $(LDFLAGS) $(TARGET_ARCH)
LINK.o = $(Q_LD)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# set special flags for given Makefile parameters
ifeq ($(DEBUG),1)
@ -386,7 +384,7 @@ CXXFLAGS += $(CFLAGS)
ifeq ($(LTO), 1)
CFLAGS += -flto
CXXFLAGS += -flto
LDFLAGS += -fuse-linker-plugin $(CXXFLAGS)
LDFLAGS += -fuse-linker-plugin
endif
# standard build rules