@@ -112,14 +112,26 @@ $(error "C compiler is not specified. Please run tests through lldb-dotest or li
112
112
endif
113
113
114
114
#----------------------------------------------------------------------
115
- # Handle SDKROOT on Darwin
115
+ # Handle SDKROOT for the cross platform builds.
116
116
#----------------------------------------------------------------------
117
117
118
118
ifeq "$(OS)" "Darwin"
119
119
ifeq "$(SDKROOT)" ""
120
120
# We haven't otherwise set the SDKROOT, so set it now to macosx
121
121
SDKROOT := $(shell xcrun --sdk macosx --show-sdk-path)
122
122
endif
123
+ SYSROOT_FLAGS := -isysroot "$(SDKROOT)"
124
+ GCC_TOOLCHAIN_FLAGS :=
125
+ else
126
+ ifneq "$(SDKROOT)" ""
127
+ SYSROOT_FLAGS := --sysroot "$(SDKROOT)"
128
+ GCC_TOOLCHAIN_FLAGS := --gcc-toolchain="$(SDKROOT)/usr"
129
+ else
130
+ # Do not set up these options if SDKROOT was not specified.
131
+ # This is a regular build in that case (or Android).
132
+ SYSROOT_FLAGS :=
133
+ GCC_TOOLCHAIN_FLAGS :=
134
+ endif
123
135
endif
124
136
125
137
#----------------------------------------------------------------------
@@ -210,20 +222,15 @@ endif
210
222
DEBUG_INFO_FLAG ?= -g
211
223
212
224
CFLAGS ?= $(DEBUG_INFO_FLAG) -O0
213
-
214
- ifeq "$(OS)" "Darwin"
215
- ifneq "$(SDKROOT)" ""
216
- CFLAGS += -isysroot "$(SDKROOT)"
217
- endif
218
- endif
225
+ CFLAGS += $(SYSROOT_FLAGS)
219
226
220
227
ifeq "$(OS)" "Darwin"
221
228
CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES)
222
229
else
223
230
CFLAGS += $(ARCHFLAG)$(ARCH)
224
231
endif
225
- CFLAGS += -I$(LLDB_BASE_DIR)include -I$(LLDB_OBJ_ROOT)/include
226
232
233
+ CFLAGS += -I$(LLDB_BASE_DIR)/include -I$(LLDB_OBJ_ROOT)/include
227
234
CFLAGS += -I$(SRCDIR) -I$(THIS_FILE_DIR)
228
235
229
236
ifndef NO_TEST_COMMON_H
@@ -234,9 +241,9 @@ CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS)
234
241
235
242
# Use this one if you want to build one part of the result without debug information:
236
243
ifeq "$(OS)" "Darwin"
237
- CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) -isysroot "$(SDKROOT)"
244
+ CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) $(SYSROOT_FLAGS)
238
245
else
239
- CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)
246
+ CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) $(SYSROOT_FLAGS)
240
247
endif
241
248
242
249
ifeq "$(MAKE_DWO)" "YES"
@@ -267,7 +274,9 @@ endif
267
274
CFLAGS += $(CFLAGS_EXTRAS)
268
275
CXXFLAGS += -std=c++11 $(CFLAGS) $(ARCH_CXXFLAGS)
269
276
LD = $(CC)
270
- LDFLAGS ?= $(CFLAGS)
277
+ # Copy common options to the linker flags (dwarf, arch. & etc).
278
+ # Note: we get some 'garbage' options for linker here (such as -I, --isystem & etc).
279
+ LDFLAGS += $(CFLAGS)
271
280
LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS)
272
281
ifeq (,$(filter $(OS), Windows_NT Android Darwin))
273
282
ifneq (,$(filter YES,$(ENABLE_THREADS)))
@@ -378,11 +387,26 @@ ifeq (1, $(USE_SYSTEM_STDLIB))
378
387
endif
379
388
endif
380
389
390
+ ifeq (,$(filter 1, $(USE_LIBSTDCPP) $(USE_LIBCPP) $(USE_SYSTEM_STDLIB)))
391
+ # If no explicit C++ library request was made, but we have paths to a custom libcxx, use
392
+ # them. Otherwise, use the system library by default.
393
+ ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)
394
+ CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR)
395
+ ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" ""
396
+ CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR)
397
+ endif
398
+ LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
399
+ else
400
+ USE_SYSTEM_STDLIB := 1
401
+ endif
402
+ endif
403
+
381
404
ifeq (1,$(USE_LIBSTDCPP))
382
405
# Clang requires an extra flag: -stdlib=libstdc++
383
406
ifneq (,$(findstring clang,$(CC)))
384
- CXXFLAGS += -stdlib=libstdc++
385
- LDFLAGS += -stdlib=libstdc++
407
+ # Force clang looking for the gcc's headers at specific rootfs folder.
408
+ CXXFLAGS += -stdlib=libstdc++ $(GCC_TOOLCHAIN_FLAGS)
409
+ LDFLAGS += -stdlib=libstdc++ $(GCC_TOOLCHAIN_FLAGS)
386
410
endif
387
411
endif
388
412
@@ -416,21 +440,15 @@ ifeq (1, $(USE_SYSTEM_STDLIB))
416
440
endif
417
441
CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(SDKROOT)/usr/include/c++/v1
418
442
LDFLAGS += -L$(SDKROOT)/usr/lib -Wl,-rpath,$(SDKROOT)/usr/lib -lc++
443
+ else
444
+ ifneq (,$(findstring clang,$(CC)))
445
+ # Force clang looking for the gcc's headers at specific rootfs folder.
446
+ CXXFLAGS += $(GCC_TOOLCHAIN_FLAGS)
447
+ LDFLAGS += $(GCC_TOOLCHAIN_FLAGS)
448
+ endif
419
449
endif
420
450
endif
421
451
422
- # If no explicit request was made, but we have paths to a custom libcxx, use
423
- # them.
424
- ifeq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP), $(USE_SYSTEM_STDLIB)),)
425
- ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)
426
- CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR)
427
- ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" ""
428
- CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR)
429
- endif
430
- LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
431
- endif
432
- endif
433
-
434
452
#----------------------------------------------------------------------
435
453
# Additional system libraries
436
454
#----------------------------------------------------------------------
0 commit comments