@@ -22,13 +22,22 @@ HOSTNAME := $(shell hostname)
22
22
# To build with clang, set the following in your environment:
23
23
# CC = clang
24
24
# CXX = clang++
25
+ ifneq (,$(findstring clang,$(CXX ) ) )
26
+ CLANG_BUILD = 1
27
+ endif
25
28
26
29
ifeq ($(CFG ) , release)
27
30
# With gcc 4.6.3, engine.so went from 7,383,765 to 8,429,109 when building with -O3.
28
31
# There also was no speed difference running at 1280x1024. May 2012, mikesart.
29
32
# tonyp: The size increase was likely caused by -finline-functions and -fipa-cp-clone getting switched on with -O3.
30
33
# -fno-omit-frame-pointer: need this for stack traces with perf.
31
- OptimizerLevel_CompilerSpecific = -O2 -fno-strict-aliasing -ffast-math -fno-omit-frame-pointer -ftree-vectorize -fpredictive-commoning -funswitch-loops
34
+ OptimizerLevel_CompilerSpecific = -O2 -fno-strict-aliasing -ffast-math -fno-omit-frame-pointer -ftree-vectorize
35
+ ifeq ($(CLANG_BUILD),1)
36
+ # These aren't supported wit Clang 3.5. Need to remove when we update that.
37
+ OptimizerLevel_CompilerSpecific += -fpredictive-commoning -funswitch-loops
38
+ else
39
+ OptimizerLevel_CompilerSpecific += -fpredictive-commoning -funswitch-loops
40
+ endif
32
41
else
33
42
OptimizerLevel_CompilerSpecific = -O0
34
43
# -O1 -finline-functions
@@ -41,14 +50,14 @@ CPPFLAGS = $(DEFINES) $(addprefix -I, $(abspath $(INCLUDEDIRS) ))
41
50
CFLAGS = $(ARCH_FLAGS ) $(CPPFLAGS ) $(WARN_FLAGS ) -fvisibility=$(SymbolVisibility ) $(OptimizerLevel ) -pipe $(GCC_ExtraCompilerFlags ) -Usprintf -Ustrncpy -UPROTECTED_THINGS_ENABLE
42
51
# In -std=gnu++0x mode we get lots of errors about "error: narrowing conversion". -fpermissive
43
52
# turns these into warnings in gcc, and -Wno-c++11-narrowing suppresses them entirely in clang 3.1+.
44
- ifeq ($(CXX ) ,clang++ )
45
- CXXFLAGS = $(CFLAGS) -Wno-c++11-narrowing
53
+ ifeq ($(CLANG_BUILD ) ,1 )
54
+ CXXFLAGS = $(CFLAGS) -std=gnu++0x - Wno-c++11-narrowing -Wno-dangling-else
46
55
else
47
- CXXFLAGS = $(CFLAGS) -fpermissive
56
+ CXXFLAGS = $(CFLAGS) -std=gnu++0x - fpermissive
48
57
endif
49
58
DEFINES += -DVPROF_LEVEL=1 -DGNUC -DNO_HOOK_MALLOC -DNO_MALLOC_OVERRIDE
50
59
LDFLAGS = $(CFLAGS ) $(GCC_ExtraLinkerFlags ) $(OptimizerLevel )
51
- GENDEP_CXXFLAGS = -MD -MP -MF $(@:.o=.P )
60
+ GENDEP_CXXFLAGS = -MMD -MP -MF $(@:.o=.P )
52
61
MAP_FLAGS =
53
62
Srv_GAMEOUTPUTFILE =
54
63
COPY_DLL_TO_SRV = 0
@@ -57,11 +66,30 @@ COPY_DLL_TO_SRV = 0
57
66
ifeq ($(STEAM_BRANCH ) ,1)
58
67
WARN_FLAGS = -Wall -Wextra -Wshadow -Wno-invalid-offsetof
59
68
else
60
- WARN_FLAGS = -Wno-write-strings -Wno-multichar
69
+ WARN_FLAGS = -Wall -Wno-invalid-offsetof -Wno-multichar -Wno-overloaded-virtual
70
+ WARN_FLAGS += -Wno-write-strings
71
+ WARN_FLAGS += -Wno-unused-variable
72
+ WARN_FLAGS += -Wno-unused-but-set-variable
73
+ WARN_FLAGS += -Wno-unused-function
74
+
75
+ ifeq ($(CLANG_BUILD),1)
76
+ # Clang specific flags
77
+ else
78
+ # Gcc specific flags. Need this for gcc 4.8.
79
+ # WARN_FLAGS += -Wno-unused-local-typedefs
80
+ # WARN_FLAGS += -Wno-unused-function
81
+ # WARN_FLAGS += -Wno-unused-result
82
+ # WARN_FLAGS += -Wno-narrowing
83
+ endif
61
84
endif
62
85
63
- WARN_FLAGS += -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-sign-compare -Wno-reorder -Wno-invalid-offsetof -Wno-float-equal -Werror=return-type -fdiagnostics-show-option -Wformat -Wformat-security
86
+ WARN_FLAGS += -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers
87
+ WARN_FLAGS += -Wno-sign-compare -Wno-reorder -Wno-invalid-offsetof -Wno-float-equal -Werror=return-type
88
+ WARN_FLAGS += -fdiagnostics-show-option -Wformat -Wformat-security
64
89
90
+ ifeq ($(OS ) ,Darwin)
91
+ $(error This file should never be used for Mac - use base.xconfig)
92
+ endif
65
93
66
94
ifeq ($(OS ) ,Linux)
67
95
# We should always specify -Wl,--build-id, as documented at:
@@ -85,20 +113,20 @@ ifeq ($(OS),Linux)
85
113
# If the steam-runtime is available, use it. We should just default to using it when
86
114
# buildbot and everyone has a bit of time to get it installed.
87
115
ifneq "$(wildcard /valve/steam-runtime/bin/)" ""
88
- # The steam-runtime is incompatible with clang at this point, so disable it
89
- # if clang is enabled.
90
- ifneq ($(CXX),clang++)
91
- VALVE_BINDIR = /valve/steam-runtime/bin/
92
- endif
116
+ VALVE_BINDIR = /valve/steam-runtime/bin/
93
117
endif
118
+
94
119
GCC_VER =
95
120
MARCH_TARGET = pentium4
96
121
# On dedicated servers, some plugins depend on global variable symbols in addition to functions.
97
122
# So symbols like _Z16ClearMultiDamagev should show up when you do "nm server_srv.so" in TF2.
98
123
STRIP_FLAGS = -x
99
124
endif
100
125
101
- ifeq ($(CXX),clang++)
126
+ ifeq ($(CLANG_BUILD),1)
127
+ # The steam-runtime is incompatible with clang at this point, so disable it
128
+ VALVE_BINDIR =
129
+
102
130
# Clang does not support -mfpmath=sse because it uses whatever
103
131
# instruction set extensions are available by default.
104
132
SSE_GEN_FLAGS = -msse2
@@ -114,19 +142,18 @@ ifeq ($(OS),Linux)
114
142
ifeq ($(origin AR), default)
115
143
AR = $(VALVE_BINDIR)ar crs
116
144
endif
117
- ifeq ($(origin CC),default)
145
+ ifeq ($(origin CC), default)
118
146
CC = $(CCACHE) $(VALVE_BINDIR)gcc$(GCC_VER)
119
147
endif
120
148
ifeq ($(origin CXX), default)
121
149
CXX = $(CCACHE) $(VALVE_BINDIR)g++$(GCC_VER)
122
150
endif
151
+
123
152
# Support ccache with clang. Add -Qunused-arguments to avoid excessive warnings due to
124
153
# a ccache quirk. Could also upgrade ccache.
125
154
# http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html
126
- ifeq ($(CC),clang )
155
+ ifeq ($(CLANG_BUILD),1 )
127
156
CC = $(CCACHE) $(VALVE_BINDIR)clang -Qunused-arguments
128
- endif
129
- ifeq ($(CXX),clang++)
130
157
CXX = $(CCACHE) $(VALVE_BINDIR)clang++ -Qunused-arguments
131
158
endif
132
159
LINK ?= $(CC)
@@ -180,84 +207,6 @@ ifeq ($(OS),Linux)
180
207
181
208
endif
182
209
183
- ifeq ($(OS ) ,Darwin)
184
- CCACHE := $(SRCROOT)/devtools/bin/osx32/ccache
185
- MAC_SDK_VER ?= 10.6
186
- MAC_SDK := macosx$(MAC_SDK_VER)
187
- SYSROOT := $(shell xcodebuild -sdk $(MAC_SDK) -version Path)
188
-
189
- ifneq ($(origin MAC_SDK_VER), file)
190
- $(warning Attempting build with SDK version $(MAC_SDK_VER), only 10.6 is supported and recommended!)
191
- endif
192
-
193
- ifeq ($(SYSROOT),)
194
- FIRSTSDK := $(firstword $(sort $(shell xcodebuild -showsdks | grep macosx | sed 's/.*macosx//')))
195
- $(error Could not find SDK version $(MAC_SDK_VER ) . Install and configure Xcode 4.3, or build with : make MAC_SDK_VER=$(FIRSTSDK ) )
196
- endif
197
-
198
- ifeq ($(origin CC), default)
199
- # Test to see if you have a compiler in the right place, if you
200
- # don't abort with an error
201
- CLANG := $(shell xcrun -sdk $(MAC_SDK) -find clang)
202
- ifeq ($(wildcard $(CLANG)),)
203
- $(error Unable to find C compiler, install and configure Xcode 4.3)
204
- endif
205
-
206
- CC := $(CCACHE) $(CLANG) -Qunused-arguments
207
- endif
208
-
209
- ifeq ($(origin CXX), default)
210
- CXXLANG := $(shell xcrun -sdk $(MAC_SDK) -find clang++)
211
- ifeq ($(wildcard $(CXXLANG)),)
212
- $(error Unable to find C++ compiler, install and configure Xcode 4.3)
213
- endif
214
-
215
- CXX := $(CCACHE) $(CXXLANG) -Qunused-arguments
216
- endif
217
- LINK ?= $(CXX)
218
-
219
- ifeq ($(origin AR), default)
220
- AR := $(shell xcrun -sdk $(MAC_SDK) -find libtool) -static -o
221
- endif
222
-
223
- ifeq ($(TARGET_PLATFORM),osx64)
224
- ARCH_FLAGS += -arch x86_64 -m64 -march=core2
225
- else ifeq (,$(findstring -arch x86_64,$(GCC_ExtraCompilerFlags)))
226
- ARCH_FLAGS += -arch i386 -m32 -march=prescott -momit-leaf-frame-pointer -mtune=core2
227
- else
228
- # dirty hack to build a universal binary - don't specify the architecture
229
- ARCH_FLAGS += -arch i386 -Xarch_i386 -march=prescott -Xarch_i386 -mtune=core2 -Xarch_i386 -momit-leaf-frame-pointer -Xarch_x86_64 -march=core2
230
- endif
231
-
232
- GEN_SYM ?= $(shell xcrun -sdk $(MAC_SDK) -find dsymutil)
233
- ifeq ($(CFG),release)
234
- STRIP ?= strip -S
235
- else
236
- STRIP ?= true
237
- endif
238
- ifeq ($(SOURCE_SDK), 1)
239
- VSIGN ?= true
240
- else
241
- VSIGN ?= $(SRCROOT)/devtools/bin/vsign
242
- endif
243
-
244
- CPPFLAGS += -I$(SYSROOT)/usr/include/malloc
245
- CFLAGS += -isysroot $(SYSROOT) -mmacosx-version-min=10.5 -fasm-blocks
246
-
247
- LIB_START_EXE = -lm -ldl -lpthread
248
- LIB_END_EXE =
249
-
250
- LIB_START_SHLIB =
251
- LIB_END_SHLIB =
252
-
253
- SHLIBLDFLAGS = $(LDFLAGS) -bundle -flat_namespace -undefined suppress -Wl,-dead_strip -Wl,-no_dead_strip_inits_and_terms
254
-
255
- ifeq (lib,$(findstring lib,$(GAMEOUTPUTFILE)))
256
- SHLIBLDFLAGS = $(LDFLAGS) -dynamiclib -current_version 1.0 -compatibility_version 1.0 -install_name @rpath/$(basename $(notdir $(GAMEOUTPUTFILE))).dylib $(SystemLibraries) -Wl,-dead_strip -Wl,-no_dead_strip_inits_and_terms
257
- endif
258
-
259
- endif
260
-
261
210
#
262
211
# Profile-directed optimizations.
263
212
# Note: Last time these were tested 3/5/08, it actually slowed down the server benchmark by 5%!
0 commit comments