2018-12-10 01:28:32 +08:00
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
ARCH ?= $(shell uname -m | sed \
|
2019-01-20 20:13:28 +08:00
|
|
|
-e s/arm.*/arm/ \
|
2019-05-07 14:54:28 +08:00
|
|
|
-e s/aarch64.*/arm64/ \
|
|
|
|
-e s/x86_64/x86/ )
|
2018-12-10 01:28:32 +08:00
|
|
|
CROSS_COMPILE ?=
|
|
|
|
CC = $(CROSS_COMPILE)gcc
|
|
|
|
LD = $(CROSS_COMPILE)ld
|
|
|
|
AR = $(CROSS_COMPILE)ar
|
|
|
|
UAPI ?= /usr/include
|
2019-03-10 23:25:02 +08:00
|
|
|
DESTDIR ?= /usr/evl
|
2018-12-10 01:28:32 +08:00
|
|
|
|
|
|
|
INSTALL ?= install
|
|
|
|
INSTALL_PROGRAM ?= $(INSTALL)
|
|
|
|
INSTALL_DATA ?= $(INSTALL) -m 644
|
|
|
|
|
|
|
|
CP := cp
|
|
|
|
CPIO := cpio
|
|
|
|
RM := rm
|
|
|
|
LN_S := ln -sf
|
|
|
|
MKDIR_P := mkdir -p
|
2019-06-04 01:19:31 +08:00
|
|
|
RMDIR_SAFE := rmdir --ignore-fail-on-non-empty
|
2018-12-10 01:28:32 +08:00
|
|
|
|
|
|
|
libdir ?= lib
|
|
|
|
includedir ?= include
|
|
|
|
bindir ?= bin
|
2019-02-07 16:47:47 +08:00
|
|
|
testdir ?= tests
|
2019-03-31 18:42:03 +08:00
|
|
|
libexecdir ?= libexec
|
2018-12-10 01:28:32 +08:00
|
|
|
|
2020-03-26 01:55:14 +08:00
|
|
|
export ARCH CROSS_COMPILE CC CXX LD AR UAPI CFLAGS LDFLAGS DESTDIR
|
2018-12-10 01:28:32 +08:00
|
|
|
|
|
|
|
MAKEFLAGS += -rR
|
|
|
|
|
|
|
|
ifneq ("$(origin O)", "command line")
|
|
|
|
O_DIR = $(CURDIR)
|
|
|
|
else
|
|
|
|
O_DIR := $(shell $(MKDIR_P) $(O) && cd $(O) && /bin/pwd)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ("$(origin V)", "command line")
|
|
|
|
V = 0
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(V),1)
|
|
|
|
Q =
|
|
|
|
else
|
|
|
|
Q = @
|
|
|
|
MAKEFLAGS += --no-print-directory
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(D),1)
|
|
|
|
DEBUG_CPPFLAGS=
|
|
|
|
DEBUG_CFLAGS=-g -O0
|
|
|
|
else
|
|
|
|
DEBUG_CPPFLAGS=-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
|
|
|
|
DEBUG_CFLAGS=-O2
|
|
|
|
endif
|
|
|
|
|
|
|
|
BASE_CPPFLAGS := -D_GNU_SOURCE -D_REENTRANT $(DEBUG_CPPFLAGS)
|
|
|
|
|
build: do not default to -fasynchronous-unwind-tables
Crashes related to enabling precise unwind tables have been observed
in the implementation of the arm* unwinder upon receipt of SIGCANCEL,
triggered by a call to pthread_cancel(). Typically, the latmus program
might randomly crash or enter a runaway loop at exit on cancelling the
timer responder thread for no obvious reason, including anything
related to stack sanity (size or corruption).
This switch was originally turned on to help backtrace() in collecting
more accurate information when called from a SIGDEBUG
handler. Unfortunately, support for stack unwinding is tricky in
essence, and may be broken in specific toolchain releases, causing
segmentation violation on exit, e.g.:
With libevl built using
gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf:
warming up on CPU0 (not isolated)...
RTT| 00:00:01 (user, 1000 us period, priority 90, CPU0-noisol)
RTH|----lat min|----lat avg|----lat max|-overrun|---msw|---lat best|--lat worst
RTD| 6.333| 6.874| 13.000| 0| 0| 6.333| 13.000
RTD| 6.333| 6.904| 19.666| 0| 0| 6.333| 19.666
^C
---|-----------|-----------|-----------|--------|------|-------------------------
RTS| 6.333| 6.889| 19.666| 0| 0| 00:00:02/00:00:02
Segmentation fault (core dumped)
(gdb) bt
regclass=regclass@entry=_UVRSC_CORE,
discriminator=discriminator@entry=16624,
representation=representation@entry=_UVRSD_UINT32)
at /home/tcwg-buildslave/workspace/tcwg-make-release_1/snapshots/gcc.git~linaro-7.5-2019.12/libgcc/config/arm/unwind-arm.c:240
uws=uws@entry=0xb6e35e64)
at /home/tcwg-buildslave/workspace/tcwg-make-release_1/snapshots/gcc.git~linaro-7.5-2019.12/libgcc/config/arm/pr-support.c:179
ucbp=0xb6e372a8, context=0xb6e36080, id=0)
at /home/tcwg-buildslave/workspace/tcwg-make-release_1/snapshots/gcc.git~linaro-7.5-2019.12/libgcc/unwind-arm-common.inc:842
entry_vrs=<optimized out>, resuming=0)
at /home/tcwg-buildslave/workspace/tcwg-make-release_1/snapshots/gcc.git~linaro-7.5-2019.12/libgcc/unwind-arm-common.inc:349
at /home/tcwg-buildslave/workspace/tcwg-make-release_1/snapshots/gcc.git~linaro-7.5-2019.12/libgcc/config/arm/libunwind.S:359
---Type <return> to continue, or q <return> to quit---
ctx=<optimized out>) at nptl-init.c:216
from /lib/libc.so.6
Which in this particular case pointed at:
(gdb) x/20i $pc
=> 0xb6f4ca2c <_Unwind_VRS_Pop+244>: ldr r1, [r4, #0]
0xb6f4ca2e <_Unwind_VRS_Pop+246>: adds r4, #4
0xb6f4ca30 <_Unwind_VRS_Pop+248>: str.w r1, [r0, #-4]
0xb6f4ca34 <_Unwind_VRS_Pop+252>: cmp r3, #16
0xb6f4ca36 <_Unwind_VRS_Pop+254>:
(gdb) info reg
r0 0xb6e36098 3068354712
r1 0x10 16
r2 0x40f0 16624
r3 0x5 5
r4 0xf009e 983198
r5 0xb6e36080 3068354688
r6 0x1 1
r7 0x40f0 16624
r8 0x0 0
r9 0xb6e35e24 3068354084
r10 0x0 0
r11 0x1 1
r12 0xb6f5e0ac 3069567148
sp 0xb6e35cf0 0xb6e35cf0
lr 0xb6f4cf23 -1225470173
pc 0xb6f4ca2c 0xb6f4ca2c <_Unwind_VRS_Pop+244>
cpsr 0x40d1c30 67968048
Something definitely bad happened in the unwinder. Disable this option
by default, which works around the toolchain issue for the most common
use case.
2020-02-16 19:31:54 +08:00
|
|
|
BASE_CFLAGS := -pipe -fstrict-aliasing \
|
2018-12-10 01:28:32 +08:00
|
|
|
-Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long \
|
2019-11-18 01:56:58 +08:00
|
|
|
-Wno-unused-parameter -Wshadow=local -Werror $(DEBUG_CFLAGS)
|
2018-12-10 01:28:32 +08:00
|
|
|
|
|
|
|
# Easy way to hide commas in args from $(call ...) invocations
|
|
|
|
comma := ,
|
|
|
|
|
|
|
|
ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
|
|
|
|
quiet=y
|
|
|
|
endif
|
|
|
|
|
|
|
|
terse-echo = @$(if $(Q),echo " $(1) $(2)";)
|
|
|
|
define run-cmd
|
|
|
|
$(if $(quiet),,$(call terse-echo,$(1),$(2)))
|
|
|
|
$(Q)$(3)
|
|
|
|
endef
|
|
|
|
define run-cc
|
|
|
|
@$(MKDIR_P) $(dir $(2))
|
|
|
|
$(call run-cmd,$(1),$(notdir $(2)),$(3))
|
|
|
|
endef
|
|
|
|
cc-pic-cmd = $(call run-cc,CC-PIC,$(1),$(2))
|
|
|
|
cc-cmd = $(call run-cc,CC,$(1),$(2))
|
|
|
|
dep-cmd = $(call run-cc,DEP,$(1),$(2))
|
|
|
|
ccld-cmd = $(call run-cc,CCLD,$(1),$(2))
|
|
|
|
ld-cmd = $(call run-cmd,LD,$(notdir $(1)),$(2))
|
|
|
|
ar-cmd = $(call run-cmd,AR,$(notdir $(1)),$(2) $(if $(Q),2>/dev/null))
|
2019-02-23 23:12:21 +08:00
|
|
|
inst-cmd = $(call run-cmd,INST,$(notdir $(1)),$(2))
|
2018-12-10 01:28:32 +08:00
|
|
|
|
2019-01-20 20:13:28 +08:00
|
|
|
MAIN_GOALS := all clean clobber mrproper install
|
|
|
|
|
2019-06-02 22:36:56 +08:00
|
|
|
_all:
|
|
|
|
|
|
|
|
# Default target when no goal was given on the command line
|
|
|
|
_all: all
|
|
|
|
|
2019-01-20 20:13:28 +08:00
|
|
|
$(TARGETS):
|
|
|
|
$(Q)$(MAKE) -C $@ O=$(O_DIR)/$@ V=$(V)
|
|
|
|
|
2018-12-10 01:28:32 +08:00
|
|
|
$(O_DIR)/%.d: %.c
|
|
|
|
$(call dep-cmd,$@,@$(CC) -MM $(CFLAGS) $< | sed 's$(comma)\($*\)\.o[ :]*$(comma)$(O_DIR)/\1.o $@: $(comma)g' > $@ || rm -f $@)
|
2019-01-20 20:13:28 +08:00
|
|
|
|
2020-03-26 01:55:14 +08:00
|
|
|
$(O_DIR)/%.d: %.cc
|
|
|
|
$(call dep-cmd,$@,@$(CXX) -MM $(CXXFLAGS) $< | sed 's$(comma)\($*\)\.o[ :]*$(comma)$(O_DIR)/\1.o $@: $(comma)g' > $@ || rm -f $@)
|
|
|
|
|
2019-06-02 22:36:56 +08:00
|
|
|
define MAKEFLY =
|
|
|
|
# Automatically generated: do not edit
|
|
|
|
|
|
|
|
MAKEARGS := O=$(O_DIR) -C $(CURDIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) UAPI=$(UAPI) DESTDIR=$(DESTDIR)
|
|
|
|
|
|
|
|
$$(filter-out sub-make, $$(MAKECMDGOALS)): sub-make
|
|
|
|
@:
|
|
|
|
|
|
|
|
sub-make:
|
|
|
|
$$(MAKE) $$(MAKEARGS) $$(MAKECMDGOALS)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# CURDIR is the source directory
|
|
|
|
export MAKEFLY
|
|
|
|
output-Makefile:
|
|
|
|
ifneq ($(O_DIR), $(CURDIR))
|
|
|
|
@if test \! -e $(O_DIR)/Makefile || grep -q Automatically $(O_DIR)/Makefile; then \
|
|
|
|
echo "$$MAKEFLY" > $(O_DIR)/Makefile; \
|
|
|
|
fi
|
|
|
|
endif
|
|
|
|
|
2019-06-09 01:41:45 +08:00
|
|
|
FORCE:
|
|
|
|
|
|
|
|
.PHONY: _all $(MAIN_GOALS) output-Makefile FORCE
|