@@ -249,6 +249,73 @@ $$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS) $$(MKFILE_DEPS)
249
249
triple-runtime
250
250
$$(Q ) cp $$(COMPRT_BUILD_DIR_$(1 ) ) /triple/runtime/libcompiler_rt.a $$(COMPRT_LIB_$(1 ) )
251
251
252
+ # ###############################################################################
253
+ # libbacktrace
254
+ #
255
+ # We use libbacktrace on linux to get symbols in backtraces, but only on linux.
256
+ # Elsewhere we use other system utilities, so this library is only built on
257
+ # linux.
258
+ # ###############################################################################
259
+
260
+ BACKTRACE_NAME_$(1 ) := $$(call CFG_STATIC_LIB_NAME_$(1 ) ,backtrace)
261
+ BACKTRACE_LIB_$(1 ) := $$(RT_OUTPUT_DIR_$(1 ) ) /$$(BACKTRACE_NAME_$(1 ) )
262
+ BACKTRACE_BUILD_DIR_$(1 ) := $$(RT_OUTPUT_DIR_$(1 ) ) /libbacktrace
263
+
264
+ ifeq ($$(findstring darwin,$$(OSTYPE_$(1 ) ) ) ,darwin)
265
+
266
+ # We don't use this on platforms that aren't linux-based, so just make the file
267
+ # available, the compilation of libstd won't actually build it.
268
+ $$(BACKTRACE_LIB_$(1 ) ) :
269
+ touch $$@
270
+
271
+ else
272
+ ifeq ($$(CFG_WINDOWSY_$(1 ) ) ,1)
273
+ $$(BACKTRACE_LIB_$(1 ) ) :
274
+ touch $$@
275
+ else
276
+
277
+ ifdef CFG_ENABLE_FAST_MAKE
278
+ BACKTRACE_DEPS := $(S ) /.gitmodules
279
+ else
280
+ BACKTRACE_DEPS := $(wildcard $(S ) src/libbacktrace/* )
281
+ endif
282
+
283
+ # We need to export CFLAGS because otherwise it doesn't pick up cross compile
284
+ # builds. If libbacktrace doesn't realize this, it will attempt to read 64-bit
285
+ # elf headers when compiled for a 32-bit system, yielding blank backtraces.
286
+ #
287
+ # This also removes the -Werror flag specifically to prevent errors during
288
+ # configuration.
289
+ #
290
+ # Down below you'll also see echos into the config.h generated by the
291
+ # ./configure script. This is done to force libbacktrace to *not* use the
292
+ # atomic/sync functionality because it pulls in unnecessary dependencies and we
293
+ # never use it anyway.
294
+ $$(BACKTRACE_BUILD_DIR_$(1 ) ) /Makefile : \
295
+ export CFLAGS:=$$(CFG_GCCISH_CFLAGS_$(1 ) :-Werror= ) \
296
+ -fno-stack-protector
297
+ $$(BACKTRACE_BUILD_DIR_$(1 ) ) /Makefile : export CC:=$$(CC_$(1 ) )
298
+ $$(BACKTRACE_BUILD_DIR_$(1 ) ) /Makefile : export AR:=$$(AR_$(1 ) )
299
+ $$(BACKTRACE_BUILD_DIR_$(1 ) ) /Makefile : export RANLIB:=$$(AR_$(1 ) ) s
300
+ $$(BACKTRACE_BUILD_DIR_$(1 ) ) /Makefile : $$(BACKTRACE_DEPS ) $$(MKFILE_DEPS )
301
+ $$(Q ) rm -rf $$(BACKTRACE_BUILD_DIR_$(1 ) )
302
+ $$(Q ) mkdir -p $$(BACKTRACE_BUILD_DIR_$(1 ) )
303
+ $$(Q ) (cd $$ (BACKTRACE_BUILD_DIR_$( 1) ) && \
304
+ $(S ) src/libbacktrace/configure --target=$(1 ) --host=$(CFG_BUILD ) )
305
+ $$(Q ) echo ' #undef HAVE_ATOMIC_FUNCTIONS' >> \
306
+ $$(BACKTRACE_BUILD_DIR_$(1 ) ) /config.h
307
+ $$(Q ) echo ' #undef HAVE_SYNC_FUNCTIONS' >> \
308
+ $$(BACKTRACE_BUILD_DIR_$(1 ) ) /config.h
309
+
310
+ $$(BACKTRACE_LIB_$(1 ) ) : $$(BACKTRACE_BUILD_DIR_$(1 ) ) /Makefile $$(MKFILE_DEPS )
311
+ @$$(call E, make: libbacktrace)
312
+ $$(Q )$$(MAKE ) -C $$(BACKTRACE_BUILD_DIR_$(1 ) ) \
313
+ INCDIR=$(S ) src/libbacktrace
314
+ $$(Q ) cp $$(BACKTRACE_BUILD_DIR_$(1 ) ) /.libs/libbacktrace.a $$@
315
+
316
+ endif # endif for windowsy
317
+ endif # endif for darwin
318
+
252
319
endef
253
320
254
321
# Instantiate template for all stages/targets
0 commit comments