1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

More build system reworking

This commit is contained in:
Andy Wingo 2025-04-16 12:40:44 +02:00
parent 6e36c039e9
commit 75700ec3ed
5 changed files with 63 additions and 65 deletions

View file

@ -118,13 +118,14 @@ make_gc_var = $$($(1)$(subst -,_,$(2)))
gc_impl = $(call make_gc_var,GC_STEM_,$(1)).c
gc_attrs = $(call make_gc_var,GC_STEM_,$(1))-attrs.h
gc_cppflags = $(call make_gc_var,GC_CPPFLAGS_,$(1))
gc_cppflags += -DGC_ATTRS=\"../api/$(call gc_attrs,$(1))\"
gc_impl_cflags = $(call make_gc_var,GC_IMPL_CFLAGS_,$(1))
gc_libs = $(call make_gc_var,GC_LIBS_,$(1))
define benchmark_template
obj/$(1).$(2).gc.o: src/$(call gc_impl,$(2)) | .deps obj
$$(COMPILE) $(call gc_cppflags,$(2)) $(call gc_impl_cflags,$(2)) -DGC_EMBEDDER=\"../benchmarks/$(1)-embedder.h\" -c $$<
obj/$(1).$(2).o: benchmarks/$(1).c | .deps obj
$$(COMPILE) $(call gc_cppflags,$(2)) -include api/$(call gc_attrs,$(2)) -c $$<
$$(COMPILE) $(call gc_cppflags,$(2)) -c $$<
bin/$(1).$(2): obj/$(1).$(2).gc.o obj/$(1).$(2).o obj/gc-stack.o obj/gc-options.o obj/gc-platform.o obj/gc-tracepoint.o obj/$(1).gc-ephemeron.o obj/$(1).gc-finalizer.o | bin
$$(LINK) $$^ $(call gc_libs,$(2))
endef

View file

@ -66,4 +66,12 @@ static inline enum gc_cooperative_safepoint_kind gc_cooperative_safepoint_kind(v
static inline int gc_can_pin_objects(void) GC_ALWAYS_INLINE;
#ifndef GC_IMPL
#ifdef GC_ATTRS
#include GC_ATTRS
#else
#error Fix build system to pass -DGC_ATTRS="path/to/foo-attrs.h" for selected GC
#endif // GC_ATTRS
#endif // GC_IMPL
#endif // GC_ATTRS_H

112
embed.am
View file

@ -44,18 +44,34 @@
noinst_LTLIBRARIES += libwhippet-common.la libwhippet.la
libwhippet_common_la_SOURCES = \
%D%/src/gc-options-internal.h \
%D%/src/gc-options.c \
%D%/src/gc-stack.c \
%D%/src/gc-stack.h \
%D%/src/gc-tracepoint.c
if WHIPPET_PLATFORM_GNU_LINUX
libwhippet_common_la_SOURCES += %D%/src/gc-platform-gnu-linux.c
endif
libwhippet_la_SOURCES = \
%D%/api/bdw-attrs.h \
%D%/api/gc-allocation-kind.h \
%D%/api/gc-api.h \
%D%/api/gc-assert.h \
%D%/api/gc-attrs.h \
%D%/api/gc-basic-stats.h \
%D%/api/gc-collection-kind.h \
%D%/api/gc-config.h \
%D%/api/gc-conservative-ref.h \
%D%/api/gc-edge.h \
%D%/api/gc-embedder-api.h \
%D%/api/gc-ephemeron.h \
%D%/api/gc-event-listener-chain.h \
%D%/api/gc-event-listener.h \
%D%/api/gc-finalizer.h \
%D%/api/gc-forwarding.h \
%D%/api/gc-histogram.h \
%D%/api/gc-inline.h \
%D%/api/gc-lttng.h \
%D%/api/gc-null-event-listener.h \
%D%/api/gc-options.h \
%D%/api/gc-ref.h \
%D%/api/gc-tracepoint.h \
%D%/api/gc-visibility.h \
%D%/api/mmc-attrs.h \
%D%/api/pcc-attrs.h \
%D%/api/semi-attrs.h \
%D%/src/adaptive-heap-sizer.h \
%D%/src/address-hash.h \
%D%/src/address-map.h \
@ -74,16 +90,21 @@ libwhippet_la_SOURCES = \
%D%/src/gc-finalizer.c \
%D%/src/gc-internal.h \
%D%/src/gc-lock.h \
%D%/src/gc-options-internal.h \
%D%/src/gc-options.c \
%D%/src/gc-platform.h \
%D%/src/gc-stack.c \
%D%/src/gc-stack.h \
%D%/src/gc-trace.h \
%D%/src/gc-tracepoint.c \
%D%/src/growable-heap-sizer.h \
%D%/src/heap-sizer.h \
%D%/src/large-object-space.h \
%D%/src/local-worklist.h \
%D%/src/nofl-space.h \
%D%/src/parallel-tracer.h \
%D%/src/root.h \
%D%/src/root-worklist.h \
%D%/src/root.h \
%D%/src/serial-tracer.h \
%D%/src/shared-worklist.h \
%D%/src/simple-worklist.h \
@ -92,6 +113,10 @@ libwhippet_la_SOURCES = \
%D%/src/swar.h \
%D%/src/tracer.h
if WHIPPET_PLATFORM_GNU_LINUX
libwhippet_la_SOURCES += %D%/src/gc-platform-gnu-linux.c
endif
WHIPPET_CPPFLAGS_bdw = -DGC_CONSERVATIVE_ROOTS=1 -DGC_CONSERVATIVE_TRACE=1
WHIPPET_CPPFLAGS_semi = -DGC_PRECISE_ROOTS=1
WHIPPET_CPPFLAGS_pcc = -DGC_PRECISE_ROOTS=1 -DGC_PARALLEL=1
@ -132,75 +157,38 @@ endif
if WHIPPET_COLLECTOR_SEMI
libwhippet_la_SOURCES += %D%/src/semi.c
WHIPPET_CPPFLAGS += -DWHIPPET_ATTRS=\"$(srcdir)/%D%/api/semi-attrs.h\"
WHIPPET_CPPFLAGS += -DGC_ATTRS=\"$(srcdir)/%D%/api/semi-attrs.h\"
endif
if WHIPPET_COLLECTOR_PCC
libwhippet_la_SOURCES += %D%/src/pcc.c
WHIPPET_CPPFLAGS += -DWHIPPET_ATTRS=\"$(srcdir)/%D%/api/pcc-attrs.h\"
WHIPPET_CPPFLAGS += -DGC_ATTRS=\"$(srcdir)/%D%/api/pcc-attrs.h\"
endif
if WHIPPET_COLLECTOR_BDW
libwhippet_la_SOURCES += %D%/src/bdw.c
WHIPPET_IMPL_CFLAGS += $(WHIPPET_BDW_CFLAGS)
WHIPPET_LIBS += $(WHIPPET_BDW_LIBS)
WHIPPET_CPPFLAGS += -DWHIPPET_ATTRS=\"$(srcdir)/%D%/api/bdw-attrs.h\"
WHIPPET_CPPFLAGS += -DGC_ATTRS=\"$(srcdir)/%D%/api/bdw-attrs.h\"
endif
if WHIPPET_COLLECTOR_MMC
libwhippet_la_SOURCES += %D%/src/mmc.c
WHIPPET_CPPFLAGS += -DWHIPPET_ATTRS=\"$(srcdir)/%D%/api/mmc-attrs.h\"
WHIPPET_CPPFLAGS += -DGC_ATTRS=\"$(srcdir)/%D%/api/mmc-attrs.h\"
endif
# add to cflags: -flto -fvisibility=hidden -fno-strict-aliasing
libwhippet_common_la_CPPFLAGS = $(WHIPPET_CPPFLAGS)
libwhippet_common_la_CFLAGS = -Wall -Wno-unused $(CFLAGS)
libwhippet_common_la_LDFLAGS = -lpthread $(LDFLAGS)
libwhippet_common_la_LIBADD = $(LIBS)
if WHIPPET_USE_LTTNG
libwhippet_common_la_CPPFLAGS += $(WHIPPET_LTTNG_CFLAGS) -DGC_TRACEPOINT_LTTNG=1
WHIPPET_LIBS += $(WHIPPET_LTTNG_LIBS)
endif
libwhippet_la_CPPFLAGS = $(WHIPPET_CPPFLAGS)
libwhippet_la_CPPFLAGS += -DGC_EMBEDDER=\"../../$(srcdir)/$(WHIPPET_EMBEDDER_H)\"
libwhippet_la_CFLAGS = -Wall -Wno-unused $(CFLAGS) $(WHIPPET_IMPL_CFLAGS)
libwhippet_la_LDFLAGS = -lpthread $(LDFLAGS) $(WHIPPET_LIBS)
if !WHIPPET_ENABLE_DEBUG
libwhippet_common_la_CFLAGS += -DNDEBUG
libwhippet_la_CPPFLAGS += -DNDEBUG
endif
libwhippet_la_CPPFLAGS = $(libwhippet_common_la_CPPFLAGS)
libwhippet_la_CPPFLAGS += -DGC_EMBEDDER=\"$(WHIPPET_EMBEDDER_H)\"
libwhippet_la_CFLAGS = $(libwhippet_common_la_CFLAGS)
libwhippet_la_CFLAGS += $(WHIPPET_IMPL_CFLAGS)
libwhippet_la_LDFLAGS = $(libwhippet_common_la_LDFLAGS) $(WHIPPET_LIBS)
libwhippet_la_LIBADD = libwhippet-common.la
# Header files that are part of Whippet's API. Not installed, though.
libwhippet_la_SOURCES += \
%D%/api/bdw-attrs.h \
%D%/api/gc-allocation-kind.h \
%D%/api/gc-api.h \
%D%/api/gc-assert.h \
%D%/api/gc-attrs.h \
%D%/api/gc-basic-stats.h \
%D%/api/gc-collection-kind.h \
%D%/api/gc-config.h \
%D%/api/gc-conservative-ref.h \
%D%/api/gc-edge.h \
%D%/api/gc-embedder-api.h \
%D%/api/gc-ephemeron.h \
%D%/api/gc-event-listener-chain.h \
%D%/api/gc-event-listener.h \
%D%/api/gc-finalizer.h \
%D%/api/gc-forwarding.h \
%D%/api/gc-histogram.h \
%D%/api/gc-inline.h \
%D%/api/gc-lttng.h \
%D%/api/gc-null-event-listener.h \
%D%/api/gc-options.h \
%D%/api/gc-ref.h \
%D%/api/gc-tracepoint.h \
%D%/api/gc-visibility.h \
%D%/api/mmc-attrs.h \
%D%/api/pcc-attrs.h \
%D%/api/semi-attrs.h
if WHIPPET_USE_LTTNG
libwhippet_la_CPPFLAGS += $(WHIPPET_LTTNG_CFLAGS) -DGC_TRACEPOINT_LTTNG=1
WHIPPET_LIBS += $(WHIPPET_LTTNG_LIBS)
endif

View file

@ -103,7 +103,7 @@ gc_libs = $(call gc_var,GC_LIBS_,$(1))
GC_IMPL = $(call gc_impl,$(GC_COLLECTOR))
GC_CPPFLAGS += $(call gc_cppflags,$(GC_COLLECTOR))
GC_CPPFLAGS += -DWHIPPET_ATTRS=\"$(GC_BASE)api/$(GC_IMPL)-attrs.h\"
GC_CPPFLAGS += -DGC_ATTRS=\"$(GC_BASE)api/$(GC_IMPL)-attrs.h\"
GC_IMPL_CFLAGS = $(call gc_impl_cflags,$(GC_COLLECTOR))
GC_LIBS = $(call gc_libs,$(GC_COLLECTOR))

View file

@ -3,11 +3,12 @@
#include <stdlib.h>
#include <string.h>
#define GC_IMPL 1
#include "gc-api.h"
#include "gc-ephemeron.h"
#include "gc-tracepoint.h"
#define GC_IMPL 1
#include "gc-internal.h"
#include "bdw-attrs.h"