Skip to content

Commit

Permalink
Conditionally compile GC source files. Test stock build in CI. (#73)
Browse files Browse the repository at this point in the history
This PR changes the build script to only include source files for the GC implementation that is selected. The PR also removes unnecessary preprocessor `#ifdef` for related files.

This PR adds a CI job to build with the stock GC. This helps us to make sure that the stock GC can build.
  • Loading branch information
qinsoon authored and udesou committed Dec 9, 2024
1 parent 24fc531 commit 0d14735
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 42 deletions.
30 changes: 23 additions & 7 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,34 @@ ifeq ($(OS),FreeBSD)
FLAGS += -I$(LOCALBASE)/include
endif

# GC source code. It depends on which GC implementation to use.
GC_SRCS := gc-common gc-stacks gc-alloc-profiler gc-heap-snapshot
ifeq ($(WITH_MMTK), 1)
GC_SRCS += gc-mmtk
else
GC_SRCS += gc-stock gc-debug gc-pages gc-page-profiler
endif

SRCS := \
jltypes gf typemap smallintset ast builtins module interpreter symbol \
dlload sys init task array genericmemory staticdata toplevel jl_uv datatype \
simplevector runtime_intrinsics precompile jloptions mtarraylist \
threading scheduler stackwalk gc-common gc-stock gc-mmtk gc-debug gc-pages gc-stacks gc-alloc-profiler gc-page-profiler \
method jlapi signal-handling safepoint timing subtype rtutils gc-heap-snapshot \
crc32c APInt-C processor ircode opaque_closure codegen-stubs coverage runtime_ccall engine
threading scheduler stackwalk \
method jlapi signal-handling safepoint timing subtype rtutils \
crc32c APInt-C processor ircode opaque_closure codegen-stubs coverage runtime_ccall engine \
$(GC_SRCS)

RT_LLVMLINK :=
CG_LLVMLINK :=

ifeq ($(JULIACODEGEN),LLVM)
GC_CODEGEN_SRCS := llvm-final-gc-lowering llvm-late-gc-lowering llvm-gc-invariant-verifier
CODEGEN_SRCS := codegen jitlayers aotcompile debuginfo disasm llvm-simdloop \
llvm-final-gc-lowering llvm-pass-helpers llvm-late-gc-lowering llvm-ptls \
llvm-lower-handlers llvm-gc-invariant-verifier llvm-propagate-addrspaces \
llvm-pass-helpers llvm-ptls \
llvm-lower-handlers llvm-propagate-addrspaces \
llvm-multiversioning llvm-alloc-opt llvm-alloc-helpers cgmemmgr llvm-remove-addrspaces \
llvm-remove-ni llvm-julia-licm llvm-demote-float16 llvm-cpufeatures pipeline llvm_api
llvm-remove-ni llvm-julia-licm llvm-demote-float16 llvm-cpufeatures pipeline llvm_api \
$(GC_CODEGEN_SRCS)
FLAGS += -I$(shell $(LLVM_CONFIG_HOST) --includedir)
CG_LLVM_LIBS := all
ifeq ($(USE_POLLY),1)
Expand Down Expand Up @@ -103,7 +114,12 @@ ifeq ($(USE_SYSTEM_LIBUV),0)
UV_HEADERS += uv.h
UV_HEADERS += uv/*.h
endif
PUBLIC_HEADERS := $(BUILDDIR)/julia_version.h $(wildcard $(SRCDIR)/support/*.h) $(addprefix $(SRCDIR)/,work-stealing-queue.h gc-interface.h gc-tls.h gc-tls-common.h gc-tls-mmtk.h julia.h julia_assert.h julia_threads.h julia_fasttls.h julia_locks.h julia_atomics.h jloptions.h)
PUBLIC_HEADERS := $(BUILDDIR)/julia_version.h $(wildcard $(SRCDIR)/support/*.h) $(addprefix $(SRCDIR)/,work-stealing-queue.h gc-interface.h gc-tls-common.h julia.h julia_assert.h julia_threads.h julia_fasttls.h julia_locks.h julia_atomics.h jloptions.h)
ifeq ($(WITH_MMTK), 1)
PUBLIC_HEADERS += $(addprefix $(SRCDIR)/,gc-tls-mmtk.h)
else
PUBLIC_HEADERS += $(addprefix $(SRCDIR)/,gc-tls-stock.h)
endif
ifeq ($(OS),WINNT)
PUBLIC_HEADERS += $(addprefix $(SRCDIR)/,win32_ucontext.h)
endif
Expand Down
3 changes: 0 additions & 3 deletions src/gc-debug.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

#ifndef MMTK_GC
#include "gc-common.h"
#include "gc-stock.h"
#include "julia.h"
Expand Down Expand Up @@ -1130,5 +1129,3 @@ void _report_gc_finished(uint64_t pause, uint64_t freed, int full, int recollect
#ifdef __cplusplus
}
#endif

#endif // !MMTK_GC
4 changes: 0 additions & 4 deletions src/gc-mmtk.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef MMTK_GC

#include "gc-common.h"
#include "mmtkMutator.h"
#include "gc-mmtk.h"
Expand Down Expand Up @@ -1199,5 +1197,3 @@ JL_DLLEXPORT jl_value_t *jl_gc_internal_obj_base_ptr(void *p)
#ifdef __cplusplus
}
#endif

#endif // MMTK_GC
4 changes: 0 additions & 4 deletions src/gc-mmtk.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef MMTK_GC

#include <stddef.h>
#include <stdint.h>

Expand Down Expand Up @@ -29,5 +27,3 @@ JL_EXTENSION typedef struct _bigval_t {
#ifdef __cplusplus
}
#endif

#endif // MMTK_GC
3 changes: 0 additions & 3 deletions src/gc-page-profiler.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

#ifndef MMTK_GC
#include "gc-page-profiler.h"
#include "julia.h"

Expand Down Expand Up @@ -179,5 +178,3 @@ JL_DLLEXPORT void jl_gc_take_page_profile(ios_t *stream)
#ifdef __cplusplus
}
#endif

#endif // !MMTK_GC
3 changes: 0 additions & 3 deletions src/gc-pages.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

#ifndef MMTK_GC
#include "gc-common.h"
#include "gc-stock.h"
#ifndef _OS_WINDOWS_
Expand Down Expand Up @@ -206,5 +205,3 @@ void jl_gc_free_page(jl_gc_pagemeta_t *pg) JL_NOTSAFEPOINT
#ifdef __cplusplus
}
#endif

#endif // !MMTK_GC
1 change: 0 additions & 1 deletion src/gc-stacks.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

#include "gc-common.h"
#include "gc-stock.h"
#include "threading.h"
#ifndef _OS_WINDOWS_
# include <sys/resource.h>
Expand Down
3 changes: 0 additions & 3 deletions src/gc-stock.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

#ifndef MMTK_GC
#include "gc-common.h"
#include "gc-stock.h"
#include "gc-alloc-profiler.h"
Expand Down Expand Up @@ -4000,5 +3999,3 @@ JL_DLLEXPORT const char* jl_active_gc_impl(void) {
#ifdef __cplusplus
}
#endif

#endif // !MMTK_GC
5 changes: 0 additions & 5 deletions src/gc-stock.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
. non-moving, precise mark and sweep collector
. pool-allocates small objects, keeps big objects on a simple list
*/
#ifndef MMTK_GC

#ifndef JL_GC_H
#define JL_GC_H

Expand Down Expand Up @@ -727,6 +725,3 @@ void _report_gc_finished(uint64_t pause, uint64_t freed, int full, int recollect
#endif

#endif


#endif // !MMTK_GC
4 changes: 0 additions & 4 deletions src/gc-tls-mmtk.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

#ifdef MMTK_GC

#include <assert.h>
#include "mmtkMutator.h"

Expand All @@ -17,5 +15,3 @@ typedef struct {
#ifdef __cplusplus
}
#endif

#endif // MMTK_GC
4 changes: 0 additions & 4 deletions src/gc-tls.h → src/gc-tls-stock.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

#ifndef MMTK_GC

// Meant to be included in "julia_threads.h"
#ifndef JL_GC_TLS_H
#define JL_GC_TLS_H
Expand Down Expand Up @@ -68,5 +66,3 @@ typedef struct {
#endif

#endif // JL_GC_TLS_H

#endif // MMTK_GC
2 changes: 1 addition & 1 deletion src/julia_threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define JL_THREADS_H

#ifndef MMTK_GC
#include "gc-tls.h"
#include "gc-tls-stock.h"
#else
#include "gc-tls-mmtk.h"
#endif
Expand Down

0 comments on commit 0d14735

Please sign in to comment.