Skip to content

Commit f92ae6f

Browse files
committed
fixed #14626 - execinfo.h detection in Makefile did not work
1 parent eb00a42 commit f92ae6f

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

.github/workflows/CI-unixish.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,12 @@ jobs:
679679
test -z "$(nm processexecutor.o)"
680680
# TODO: test NO_* defines
681681
682+
- name: Test execinfo.h detection
683+
run: |
684+
make clean
685+
make cli/stacktrace.o | grep HAVE_EXECINFO_H=1
686+
test -n "$(nm cli/stacktrace.o)"
687+
682688
- name: Test testrunner inclusion/exclusion
683689
run: |
684690
! ./testrunner -d TestUtils | grep -v TestUtils > /dev/null

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ else ifneq ($(HAVE_RULES),)
155155
$(error invalid HAVE_RULES value '$(HAVE_RULES)')
156156
endif
157157

158-
HAVE_EXECINFO_H=$(shell echo "\#include <execinfo.h>" | $(CXX) -c -xc - 2> /dev/null && echo "1" || echo "0")
158+
# older make versions do not support # in $(shell) and newer ones handle the escape sequence literally
159+
REQUIRE_ESCAPE=$(shell echo "\#define DEF" | $(CXX) -c -xc - 2> /dev/null && echo "1" || echo "0")
160+
ifeq ($(REQUIRE_ESCAPE),1)
161+
HAVE_EXECINFO_H=$(shell echo "\#include <execinfo.h>" | $(CXX) -c -xc - 2> /dev/null && echo "1" || echo "0")
162+
else
163+
HAVE_EXECINFO_H=$(shell echo "#include <execinfo.h>" | $(CXX) -c -xc - 2> /dev/null && echo "1" || echo "0")
164+
endif
159165
override CPPFLAGS += -DHAVE_EXECINFO_H=$(HAVE_EXECINFO_H)
160166

161167
override CXXFLAGS += $(CXXOPTS)

tools/dmake/dmake.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,13 @@ int main(int argc, char **argv)
771771
<< " $(error invalid HAVE_RULES value '$(HAVE_RULES)')\n"
772772
<< "endif\n\n";
773773

774-
// the # needs to be escaped on older make versions
775-
fout << "HAVE_EXECINFO_H=$(shell echo \"\\#include <execinfo.h>\" | $(CXX) -c -xc - 2> /dev/null && echo \"1\" || echo \"0\")\n"
774+
fout << "# older make versions do not support # in $(shell) and newer ones handle the escape sequence literally\n"
775+
<< "REQUIRE_ESCAPE=$(shell echo \"\\#define DEF\" | $(CXX) -c -xc - 2> /dev/null && echo \"1\" || echo \"0\")\n"
776+
<< "ifeq ($(REQUIRE_ESCAPE),1)\n"
777+
<< " HAVE_EXECINFO_H=$(shell echo \"\\#include <execinfo.h>\" | $(CXX) -c -xc - 2> /dev/null && echo \"1\" || echo \"0\")\n"
778+
<< "else\n"
779+
<< " HAVE_EXECINFO_H=$(shell echo \"#include <execinfo.h>\" | $(CXX) -c -xc - 2> /dev/null && echo \"1\" || echo \"0\")\n"
780+
<< "endif\n"
776781
<< "override CPPFLAGS += -DHAVE_EXECINFO_H=$(HAVE_EXECINFO_H)\n\n";
777782

778783
fout << "override CXXFLAGS += $(CXXOPTS)\n";

0 commit comments

Comments
 (0)