aports/main/scudo-malloc/0001-Add-makefile.patch
Kevin Daudt 774ad35540 main/scudo-malloc: don't build test objects if checks are disabled
On riscv64, checks are globally disabled, resulting in checkdepends not
being installed. This causes the build to fail because `gtest/gtest.h`
cannot be found.

Improve the patched Makefile by testing a TESTS variable, and if it's
set to `no`, skip building the test objects.
2023-10-31 17:06:19 +00:00

68 lines
1.7 KiB
Diff

From 64853e3c0a51103ffef34bb899ca92a3ea0cde1e Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 30 Oct 2023 21:59:49 +0100
Subject: [PATCH] Add makefile
---
compiler-rt/lib/scudo/standalone/Makefile | 42 +++++++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 compiler-rt/lib/scudo/standalone/Makefile
diff --git a/compiler-rt/lib/scudo/standalone/Makefile b/compiler-rt/lib/scudo/standalone/Makefile
new file mode 100644
index 00000000000..e9e5b95dd42
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,49 @@
+CXX = c++
+AR = ar
+
+override CXXFLAGS+= -Wall -Wextra -Wno-mismatched-new-delete -std=c++17 -fvisibility=hidden -fno-exceptions -fno-rtti -pthread -fPIC -O3 -Iinclude -I. -DNDEBUG -DSCUDO_CAN_USE_PRIMARY64=0
+
+sources = $(wildcard *.cpp)
+objects = $(sources:%.cpp=%.o)
+
+test_skip = $(wildcard tests/wrappers_*_test.cpp)
+test_sources = $(filter-out $(test_skip), $(wildcard tests/*_test.cpp)) tests/scudo_unit_test_main.cpp
+test_objects = $(test_sources:%.cpp=%.o)
+
+gtest_libs = -lgtest
+
+CXXFLAGS_crc32 = -mcrc32
+
+TESTS ?= yes
+
+SCUDO_TEST=
+ifneq ($(TESTS),no)
+SCUDO_TEST=scudo_test
+endif
+
+.PHONY: all
+all: libscudo.so libscudo.a $(SCUDO_TEST)
+
+libscudo.so: $(objects)
+ $(CXX) $(objects) $(CXXFLAGS) $(LDFLAGS) -shared -o $@
+
+libscudo.a: $(objects)
+ $(AR) rcs $@ $(objects)
+
+scudo_test: $(objects) $(test_objects) libscudo.a
+ $(CXX) $(test_objects) -o $@ $(CXXFLAGS) -g $(LDFLAGS) -L. libscudo.a $(gtest_libs)
+
+.PHONY: test
+test: scudo_test
+ ./scudo_test
+
+crc32_hw.o: CXXFLAGS += $(CXXFLAGS_crc32)
+$(objects): CXXFLAGS += -ffreestanding -nostdinc++
+
+%.o: %.cpp
+ $(CXX) $< $(CXXFLAGS) -c -o $@
+
+clean:
+ -rm -f $(test_objects) $(objects) libscudo.a libscudo.so scudo_test
+
+
--
2.42.0