Skip to content

Commit 97828e0

Browse files
authored
Conditionally compile GC source files. Test stock build in CI. (#73)
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.
1 parent 5cacfa4 commit 97828e0

15 files changed

+52
-45
lines changed

.github/workflows/StockBuild.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This workflow does not exist upstream. DO NOT TRY TO UPSTREAM IT.
2+
# It is just a simple check to ensure that we do not break the stock build.
3+
4+
name: Test stock Julia build
5+
6+
on:
7+
pull_request:
8+
9+
concurrency:
10+
# Cancels pending runs when a PR gets updated.
11+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Build
20+
run: |
21+
make

src/Makefile

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,34 @@ ifeq ($(OS),FreeBSD)
4444
FLAGS += -I$(LOCALBASE)/include
4545
endif
4646

47+
# GC source code. It depends on which GC implementation to use.
48+
GC_SRCS := gc-common gc-stacks gc-alloc-profiler gc-heap-snapshot
49+
ifeq ($(WITH_MMTK), 1)
50+
GC_SRCS += gc-mmtk
51+
else
52+
GC_SRCS += gc-stock gc-debug gc-pages gc-page-profiler
53+
endif
54+
4755
SRCS := \
4856
jltypes gf typemap smallintset ast builtins module interpreter symbol \
4957
dlload sys init task array genericmemory staticdata toplevel jl_uv datatype \
5058
simplevector runtime_intrinsics precompile jloptions mtarraylist \
51-
threading scheduler stackwalk gc-common gc-stock gc-mmtk gc-debug gc-pages gc-stacks gc-alloc-profiler gc-page-profiler \
52-
method jlapi signal-handling safepoint timing subtype rtutils gc-heap-snapshot \
53-
crc32c APInt-C processor ircode opaque_closure codegen-stubs coverage runtime_ccall engine
59+
threading scheduler stackwalk \
60+
method jlapi signal-handling safepoint timing subtype rtutils \
61+
crc32c APInt-C processor ircode opaque_closure codegen-stubs coverage runtime_ccall engine \
62+
$(GC_SRCS)
5463

5564
RT_LLVMLINK :=
5665
CG_LLVMLINK :=
5766

5867
ifeq ($(JULIACODEGEN),LLVM)
68+
GC_CODEGEN_SRCS := llvm-final-gc-lowering llvm-late-gc-lowering llvm-gc-invariant-verifier
5969
CODEGEN_SRCS := codegen jitlayers aotcompile debuginfo disasm llvm-simdloop \
60-
llvm-final-gc-lowering llvm-pass-helpers llvm-late-gc-lowering llvm-ptls \
61-
llvm-lower-handlers llvm-gc-invariant-verifier llvm-propagate-addrspaces \
70+
llvm-pass-helpers llvm-ptls \
71+
llvm-lower-handlers llvm-propagate-addrspaces \
6272
llvm-multiversioning llvm-alloc-opt llvm-alloc-helpers cgmemmgr llvm-remove-addrspaces \
63-
llvm-remove-ni llvm-julia-licm llvm-demote-float16 llvm-cpufeatures pipeline llvm_api
73+
llvm-remove-ni llvm-julia-licm llvm-demote-float16 llvm-cpufeatures pipeline llvm_api \
74+
$(GC_CODEGEN_SRCS)
6475
FLAGS += -I$(shell $(LLVM_CONFIG_HOST) --includedir)
6576
CG_LLVM_LIBS := all
6677
ifeq ($(USE_POLLY),1)
@@ -107,7 +118,12 @@ ifeq ($(USE_SYSTEM_LIBUV),0)
107118
UV_HEADERS += uv.h
108119
UV_HEADERS += uv/*.h
109120
endif
110-
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)
121+
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)
122+
ifeq ($(WITH_MMTK), 1)
123+
PUBLIC_HEADERS += $(addprefix $(SRCDIR)/,gc-tls-mmtk.h)
124+
else
125+
PUBLIC_HEADERS += $(addprefix $(SRCDIR)/,gc-tls-stock.h)
126+
endif
111127
ifeq ($(OS),WINNT)
112128
PUBLIC_HEADERS += $(addprefix $(SRCDIR)/,win32_ucontext.h)
113129
endif

src/gc-debug.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
#ifndef MMTK_GC
43
#include "gc-common.h"
54
#include "gc-stock.h"
65
#include "julia.h"
@@ -1130,5 +1129,3 @@ void _report_gc_finished(uint64_t pause, uint64_t freed, int full, int recollect
11301129
#ifdef __cplusplus
11311130
}
11321131
#endif
1133-
1134-
#endif // !MMTK_GC

src/gc-interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void jl_gc_notify_image_load(const char* img_data, size_t len);
206206
// This function notifies the GC about memory addresses that are set when allocating the boot image.
207207
// The GC may use that information to, for instance, determine that all objects in that chunk of memory should
208208
// be treated as marked and belonged to the old generation in nursery collections.
209-
void jl_gc_notify_image_alloc(char* img_data, size_t len);
209+
void jl_gc_notify_image_alloc(const char* img_data, size_t len);
210210

211211
// ========================================================================= //
212212
// Runtime Write-Barriers

src/gc-mmtk.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#ifdef MMTK_GC
2-
31
#include "gc-common.h"
42
#include "mmtkMutator.h"
53
#include "gc-mmtk.h"
@@ -1109,7 +1107,7 @@ void jl_gc_notify_image_load(const char* img_data, size_t len)
11091107
mmtk_set_vm_space((void*)img_data, len);
11101108
}
11111109

1112-
void jl_gc_notify_image_alloc(char* img_data, size_t len)
1110+
void jl_gc_notify_image_alloc(const char* img_data, size_t len)
11131111
{
11141112
mmtk_immortal_region_post_alloc((void*)img_data, len);
11151113
}
@@ -1245,5 +1243,3 @@ JL_DLLEXPORT jl_value_t *jl_gc_internal_obj_base_ptr(void *p)
12451243
#ifdef __cplusplus
12461244
}
12471245
#endif
1248-
1249-
#endif // MMTK_GC

src/gc-mmtk.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#ifdef MMTK_GC
2-
31
#include <stdbool.h>
42
#include <stddef.h>
53
#include <stdint.h>
@@ -30,5 +28,3 @@ JL_EXTENSION typedef struct _bigval_t {
3028
#ifdef __cplusplus
3129
}
3230
#endif
33-
34-
#endif // MMTK_GC

src/gc-page-profiler.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
#ifndef MMTK_GC
43
#include "gc-page-profiler.h"
54
#include "julia.h"
65

@@ -179,5 +178,3 @@ JL_DLLEXPORT void jl_gc_take_page_profile(ios_t *stream)
179178
#ifdef __cplusplus
180179
}
181180
#endif
182-
183-
#endif // !MMTK_GC

src/gc-pages.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
#ifndef MMTK_GC
43
#include "gc-common.h"
54
#include "gc-stock.h"
65
#ifndef _OS_WINDOWS_
@@ -206,5 +205,3 @@ void jl_gc_free_page(jl_gc_pagemeta_t *pg) JL_NOTSAFEPOINT
206205
#ifdef __cplusplus
207206
}
208207
#endif
209-
210-
#endif // !MMTK_GC

src/gc-stacks.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// This file is a part of Julia. License is MIT: https://julialang.org/license
22

33
#include "gc-common.h"
4-
#include "gc-stock.h"
54
#include "threading.h"
65
#ifndef _OS_WINDOWS_
76
# include <sys/resource.h>

src/gc-stock.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
#ifndef MMTK_GC
43
#include "gc-common.h"
54
#include "gc-stock.h"
65
#include "gc-alloc-profiler.h"
@@ -4007,5 +4006,3 @@ JL_DLLEXPORT const char* jl_active_gc_impl(void) {
40074006
#ifdef __cplusplus
40084007
}
40094008
#endif
4010-
4011-
#endif // !MMTK_GC

0 commit comments

Comments
 (0)