Skip to content

Commit f7b5faf

Browse files
authored
[GCChecker] support c++ code and improve makefile support (#34078)
Since this is a plugin, we also now build it with undefined symbols, rather than making multiple copies of them and expecting the linker to figure out something sensible at runtime.
1 parent e12b054 commit f7b5faf

File tree

10 files changed

+71
-71
lines changed

10 files changed

+71
-71
lines changed

Make.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ endif
475475
ifeq ($(USECLANG),1)
476476
CC := $(CROSS_COMPILE)clang
477477
CXX := $(CROSS_COMPILE)clang++
478-
JCFLAGS := -pipe $(fPIC) -fno-strict-aliasing -D_FILE_OFFSET_BITS=64
478+
JCFLAGS := -std=gnu99 -pipe $(fPIC) -fno-strict-aliasing -D_FILE_OFFSET_BITS=64
479479
# AArch64 needs this flag to generate the .eh_frame used by libunwind
480480
JCPPFLAGS := -fasynchronous-unwind-tables
481481
JCXXFLAGS := -pipe $(fPIC) -fno-rtti -pedantic

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ ifeq ($(OS),WINNT)
222222
ifeq ($(XC_HOST),)
223223
STD_LIB_PATH ?= $(PATH)
224224
else
225-
STD_LIB_PATH := $(shell LANG=C $(CC) -print-search-dirs | grep programs | sed -e "s/^programs: =//")
226-
STD_LIB_PATH += :$(shell LANG=C $(CC) -print-search-dirs | grep libraries | sed -e "s/^libraries: =//")
225+
STD_LIB_PATH := $(shell LANG=C $(CC) -print-search-dirs | grep '^programs: =' | sed -e "s/^programs: =//")
226+
STD_LIB_PATH += :$(shell LANG=C $(CC) -print-search-dirs | grep '^libraries: =' | sed -e "s/^libraries: =//")
227227
ifneq (,$(findstring CYGWIN,$(BUILD_OS))) # the cygwin-mingw32 compiler lies about it search directory paths
228228
STD_LIB_PATH := $(shell echo '$(STD_LIB_PATH)' | sed -e "s!/lib/!/bin/!g")
229229
endif

src/Makefile

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,20 @@ ifeq ($(OS),FreeBSD)
3939
FLAGS += -I$(LOCALBASE)/include
4040
endif
4141

42-
RUNTIME_C_SRCS := \
42+
RUNTIME_SRCS := \
4343
jltypes gf typemap ast builtins module interpreter symbol \
4444
dlload sys init task array dump staticdata toplevel jl_uv datatype \
4545
simplevector runtime_intrinsics precompile \
4646
threading partr stackwalk gc gc-debug gc-pages gc-stacks method \
4747
jlapi signal-handling safepoint timing subtype \
48-
crc32c
49-
RUNTIME_SRCS := APInt-C runtime_ccall processor rtutils jloptions $(RUNTIME_C_SRCS)
50-
SRCS := $(RUNTIME_SRCS)
51-
52-
ifeq ($(USEMSVC), 1)
53-
SRCS += getopt
54-
endif
48+
crc32c APInt-C processor
49+
SRCS := jloptions runtime_ccall rtutils
5550

5651
LLVMLINK :=
5752

5853
ifeq ($(JULIACODEGEN),LLVM)
59-
SRCS += codegen jitlayers disasm debuginfo llvm-simdloop llvm-ptls llvm-muladd \
54+
SRCS += codegen llvm-ptls
55+
RUNTIME_SRCS += jitlayers debuginfo disasm llvm-simdloop llvm-muladd \
6056
llvm-final-gc-lowering llvm-pass-helpers llvm-late-gc-lowering \
6157
llvm-lower-handlers llvm-gc-invariant-verifier llvm-propagate-addrspaces \
6258
llvm-multiversioning llvm-alloc-opt cgmemmgr llvm-api
@@ -77,10 +73,17 @@ FLAGS += -I$(shell $(LLVM_CONFIG_HOST) --src-root)/tools/polly/tools # Required
7773
endif
7874
endif
7975
else
80-
SRCS += anticodegen
76+
RUNTIME_SRCS += anticodegen
8177
LLVM_LIBS := support
8278
endif
8379

80+
ifeq ($(USEMSVC), 1)
81+
SRCS += getopt
82+
endif
83+
84+
SRCS += $(RUNTIME_SRCS)
85+
86+
8487
# headers are used for dependency tracking, while public headers will be part of the dist
8588
UV_HEADERS :=
8689
HEADERS := $(BUILDDIR)/julia_version.h $(wildcard $(SRCDIR)/support/*.h) $(addprefix $(SRCDIR)/,julia.h julia_assert.h julia_threads.h tls.h locks.h atomics.h julia_internal.h options.h timing.h)
@@ -91,26 +94,31 @@ UV_HEADERS += uv/*.h
9194
endif
9295
PUBLIC_HEADER_TARGETS := $(addprefix $(build_includedir)/julia/,$(notdir $(PUBLIC_HEADERS)) $(UV_HEADERS))
9396

97+
LLVM_LDFLAGS := $(shell $(LLVM_CONFIG_HOST) --ldflags)
98+
LLVM_CXXFLAGS := $(shell $(LLVM_CONFIG_HOST) --cxxflags)
99+
94100
ifeq ($(JULIACODEGEN),LLVM)
95101
ifneq ($(USE_SYSTEM_LLVM),0)
96-
LLVMLINK += $(shell $(LLVM_CONFIG_HOST) --ldflags --libs --system-libs)
102+
LLVMLINK += $(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --libs --system-libs)
97103
# HACK: llvm-config doesn't correctly point to shared libs on all platforms
98104
# https://github.com/JuliaLang/julia/issues/29981
99105
else
100106
ifneq ($(USE_LLVM_SHLIB),1)
101-
LLVMLINK += $(shell $(LLVM_CONFIG_HOST) --ldflags) $(shell $(LLVM_CONFIG_HOST) --libs $(LLVM_LIBS)) $(shell $(LLVM_CONFIG_HOST) --ldflags) $(shell $(LLVM_CONFIG_HOST) --system-libs 2> /dev/null)
107+
LLVMLINK += $(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --libs $(LLVM_LIBS)) $($(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --system-libs 2> /dev/null)
102108
else
103-
LLVMLINK += $(shell $(LLVM_CONFIG_HOST) --ldflags) -lLLVM
109+
LLVMLINK += $(LLVM_LDFLAGS) -lLLVM
104110
endif
105111
endif
106112
ifeq ($(USE_LLVM_SHLIB),1)
107113
FLAGS += -DLLVM_SHLIB
108114
endif # USE_LLVM_SHLIB == 1
109115
endif
110116

111-
CLANGLINK :=
112-
CLANGLINK += -lclangAnalysis -lclangStaticAnalyzerCore -lclangASTMatchers -lclangAST -lclangLex -lclangBasic
113-
CLANGLINK += $(LLVMLINK)
117+
CLANG_LDFLAGS := $(LLVM_LDFLAGS)
118+
ifeq ($(OS), Darwin)
119+
CLANG_LDFLAGS += -Wl,-undefined,dynamic_lookup
120+
endif
121+
114122

115123
COMMON_LIBS := -L$(build_shlibdir) -L$(build_libdir) $(LIBUV) $(LIBUTF8PROC) $(NO_WHOLE_ARCHIVE) $(LLVMLINK) $(OSLIBS) $(LIBUNWIND)
116124
DEBUG_LIBS := $(WHOLE_ARCHIVE) $(BUILDDIR)/flisp/libflisp-debug.a $(WHOLE_ARCHIVE) $(BUILDDIR)/support/libsupport-debug.a $(COMMON_LIBS)
@@ -154,9 +162,9 @@ $(BUILDDIR)/%.o: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR)
154162
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.c $(HEADERS) | $(BUILDDIR)
155163
@$(call PRINT_CC, $(CC) $(JCPPFLAGS) $(JCFLAGS) $(DEBUGFLAGS) -c $< -o $@)
156164
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp $(SRCDIR)/llvm-version.h $(HEADERS) $(LLVM_CONFIG_ABSOLUTE) | $(BUILDDIR)
157-
@$(call PRINT_CC, $(CXX) $(shell $(LLVM_CONFIG_HOST) --cxxflags) $(JCPPFLAGS) $(JCXXFLAGS) $(SHIPFLAGS) $(CXX_DISABLE_ASSERTION) -c $< -o $@)
165+
@$(call PRINT_CC, $(CXX) $(LLVM_CXXFLAGS) $(JCPPFLAGS) $(JCXXFLAGS) $(SHIPFLAGS) $(CXX_DISABLE_ASSERTION) -c $< -o $@)
158166
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.cpp $(SRCDIR)/llvm-version.h $(HEADERS) $(LLVM_CONFIG_ABSOLUTE) | $(BUILDDIR)
159-
@$(call PRINT_CC, $(CXX) $(shell $(LLVM_CONFIG_HOST) --cxxflags) $(JCPPFLAGS) $(JCXXFLAGS) $(DEBUGFLAGS) -c $< -o $@)
167+
@$(call PRINT_CC, $(CXX) $(LLVM_CXXFLAGS) $(JCPPFLAGS) $(JCXXFLAGS) $(DEBUGFLAGS) -c $< -o $@)
160168

161169
# public header rules
162170
$(eval $(call dir_target,$(build_includedir)/julia))
@@ -196,7 +204,7 @@ endif
196204
$(INSTALL_NAME_CMD)libccalltest.$(SHLIB_EXT) $@
197205

198206
$(build_shlibdir)/libllvmcalltest.$(SHLIB_EXT): $(SRCDIR)/llvmcalltest.cpp $(LLVM_CONFIG_ABSOLUTE)
199-
@$(call PRINT_CC, $(CXX) $(shell $(LLVM_CONFIG_HOST) --cxxflags) $(JCXXFLAGS) $(JCPPFLAGS) $(DEBUGFLAGS) -O3 $< $(fPIC) -shared -o $@ $(JLDFLAGS) -L$(build_shlibdir) -L$(build_libdir) $(NO_WHOLE_ARCHIVE) $(LLVMLINK))
207+
@$(call PRINT_CC, $(CXX) $(LLVM_CXXFLAGS) $(JCXXFLAGS) $(JCPPFLAGS) $(DEBUGFLAGS) -O3 $< $(fPIC) -shared -o $@ $(JLDFLAGS) -L$(build_shlibdir) -L$(build_libdir) $(NO_WHOLE_ARCHIVE) $(LLVMLINK))
200208

201209
julia_flisp.boot.inc.phony: $(BUILDDIR)/julia_flisp.boot.inc
202210

@@ -348,7 +356,8 @@ clean-support:
348356
cleanall: clean clean-flisp clean-support clean-analyzegc
349357

350358
$(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT): $(SRCDIR)/clangsa/GCChecker.cpp $(LLVM_CONFIG_ABSOLUTE)
351-
@$(call PRINT_CC, $(CXX) -g $(fPIC) -shared -o $@ -DCLANG_PLUGIN -I$(build_includedir) $(shell $(LLVM_CONFIG_HOST) --cxxflags) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(CXXLDFLAGS) -L$(build_libdir) $< $(CLANGLINK))
359+
@$(call PRINT_CC, $(CXX) -g $(fPIC) -shared -o $@ -DCLANG_PLUGIN -I$(build_includedir) -L$(build_libdir) \
360+
$(LLVM_CXXFLAGS) $(CLANG_LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(CXXLDFLAGS) $<)
352361

353362
# Throw an error if a proper version of `clang` is not available.
354363
# Note that for a default install, you will need to have run the following
@@ -363,15 +372,28 @@ endif
363372
endif
364373

365374

375+
# Note: we're passing *FLAGS here computed based on your system compiler to
376+
# clang. If that causes you problems, you might want to build and/or run
377+
# specific clang-sa-* files with clang explicitly selected:
378+
# make CC=~+/../usr/tools/clang CXX=~+/../usr/tools/clang USECLANG=1 analyzegc
379+
# make USECLANG=1 clang-sa-*
366380
CLANGSA_FLAGS :=
367381
ifeq ($(OS), Darwin) # on new XCode, the files are hidden
368382
CLANGSA_FLAGS += -isysroot $(shell xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
369383
endif
370-
clang-sa-%: $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) | analyzegc-deps-check
371-
@$(call PRINT_ANALYZE, $(build_depsbindir)/clang --analyze -Xanalyzer -analyzer-werror -Xanalyzer -analyzer-output=text -Xclang -load -Xclang $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) $(CLANGSA_FLAGS) $(CPPFLAGS) $(CFLAGS) $(DEBUGFLAGS) -Xclang -analyzer-checker=core$(COMMA)julia.GCChecker --analyzer-no-default-checks -fcolor-diagnostics -Werror -x c $(SRCDIR)/$*.c)
384+
ifeq ($(USEGCC),1)
385+
# try to help clang find the c++ files for CC by guessing the value for --prefix
386+
# by dropping lib/gcc/<platform>/<version> from the install directory it reports
387+
CLANGSA_FLAGS += --gcc-toolchain="$(abspath $(shell LANG=C $(CC) -print-search-dirs | grep '^install: ' | sed -e "s/^install: //")/../../../..)"
388+
endif
389+
390+
clang-sa-%: $(SRCDIR)/%.c $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) | analyzegc-deps-check
391+
@$(call PRINT_ANALYZE, $(build_depsbindir)/clang --analyze -Xanalyzer -analyzer-werror -Xanalyzer -analyzer-output=text -Xclang -load -Xclang $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) $(CLANGSA_FLAGS) $(JCPPFLAGS) $(JCFLAGS) $(DEBUGFLAGS) -Xclang -analyzer-checker=core$(COMMA)julia.GCChecker --analyzer-no-default-checks -fcolor-diagnostics -Werror -x c $<)
392+
clang-sa-%: $(SRCDIR)/%.cpp $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) | analyzegc-deps-check
393+
@$(call PRINT_ANALYZE, $(build_depsbindir)/clang --analyze -Xanalyzer -analyzer-werror -Xanalyzer -analyzer-output=text -Xclang -load -Xclang $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) $(CLANGSA_FLAGS) $(LLVM_CXXFLAGS) $(JCPPFLAGS) $(JCXXFLAGS) $(DEBUGFLAGS) -Xclang -analyzer-checker=core$(COMMA)julia.GCChecker --analyzer-no-default-checks -fcolor-diagnostics -Werror -x c++ $<)
372394

373395
# Add C files as a target of `analyzegc`
374-
analyzegc: $(addprefix clang-sa-,$(RUNTIME_C_SRCS))
396+
analyzegc: $(addprefix clang-sa-,$(RUNTIME_SRCS))
375397

376398
clean-analyzegc:
377399
rm -f $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT)

src/clangsa/GCChecker.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,10 @@ bool GCChecker::isSafepoint(const CallEvent &Call) const
771771
isCalleeSafepoint = !declHasAnnotation(TDT->getDecl(), "julia_not_safepoint");
772772
}
773773
} else if (FD) {
774-
if (FD->getBuiltinID() != 0)
774+
if (FD->getBuiltinID() != 0 || FD->isTrivial())
775775
isCalleeSafepoint = false;
776-
else if ((FD->getName().startswith_lower("uv_") ||
776+
else if (FD->getDeclName().isIdentifier() &&
777+
(FD->getName().startswith_lower("uv_") ||
777778
FD->getName().startswith_lower("unw_") ||
778779
FD->getName().startswith("_U")) &&
779780
FD->getName() != "uv_run")

src/debuginfo.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class JuliaJITEventListener: public JITEventListener
167167
JuliaJITEventListener(){}
168168
virtual ~JuliaJITEventListener() {}
169169

170-
jl_method_instance_t *lookupLinfo(size_t pointer)
170+
jl_method_instance_t *lookupLinfo(size_t pointer) JL_NOTSAFEPOINT
171171
{
172172
uv_rwlock_rdlock(&threadsafe);
173173
auto region = linfomap.lower_bound(pointer);
@@ -427,7 +427,7 @@ class JuliaJITEventListener: public JITEventListener
427427
// virtual void NotifyFreeingObject(const ObjectImage &Object) {}
428428
// virtual void NotifyFreeingObject(const object::ObjectFile &Obj) {}
429429

430-
std::map<size_t, ObjectInfo, revcomp>& getObjectMap()
430+
std::map<size_t, ObjectInfo, revcomp>& getObjectMap() JL_NOTSAFEPOINT
431431
{
432432
uv_rwlock_rdlock(&threadsafe);
433433
return objectmap;
@@ -442,7 +442,7 @@ JL_DLLEXPORT void ORCNotifyObjectEmitted(JITEventListener *Listener,
442442
((JuliaJITEventListener*)Listener)->_NotifyObjectEmitted(Object, L, memmgr);
443443
}
444444

445-
static std::pair<char *, bool> jl_demangle(const char *name)
445+
static std::pair<char *, bool> jl_demangle(const char *name) JL_NOTSAFEPOINT
446446
{
447447
// This function is not allowed to reference any TLS variables since
448448
// it can be called from an unmanaged thread on OSX.
@@ -487,7 +487,7 @@ JITEventListener *CreateJuliaJITEventListener()
487487
static int lookup_pointer(
488488
object::SectionRef Section, DIContext *context,
489489
jl_frame_t **frames, size_t pointer, int64_t slide,
490-
bool demangle, bool noInline)
490+
bool demangle, bool noInline) JL_NOTSAFEPOINT
491491
{
492492
// This function is not allowed to reference any TLS variables
493493
// since it can be called from an unmanaged thread on OSX.
@@ -510,7 +510,6 @@ static int lookup_pointer(
510510
}
511511
return 1;
512512
}
513-
jl_mutex_lock_maybe_nogc(&codegen_lock);
514513
DILineInfoSpecifier infoSpec(DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath,
515514
DILineInfoSpecifier::FunctionNameKind::ShortName);
516515

@@ -519,7 +518,6 @@ static int lookup_pointer(
519518
int fromC = (*frames)[0].fromC;
520519
int n_frames = inlineInfo.getNumberOfFrames();
521520
if (n_frames == 0) {
522-
jl_mutex_unlock_maybe_nogc(&codegen_lock);
523521
// no line number info available in the context, return without the context
524522
return lookup_pointer(object::SectionRef(), NULL, frames, pointer, slide, demangle, noInline);
525523
}
@@ -571,7 +569,6 @@ static int lookup_pointer(
571569
else
572570
jl_copy_str(&frame->file_name, file_name.c_str());
573571
}
574-
jl_mutex_unlock_maybe_nogc(&codegen_lock);
575572
return n_frames;
576573
}
577574

@@ -607,7 +604,7 @@ struct debug_link_info {
607604
StringRef filename;
608605
uint32_t crc32;
609606
};
610-
static debug_link_info getDebuglink(const object::ObjectFile &Obj)
607+
static debug_link_info getDebuglink(const object::ObjectFile &Obj) JL_NOTSAFEPOINT
611608
{
612609
debug_link_info info = {};
613610
for (const object::SectionRef &Section: Obj.sections()) {
@@ -743,7 +740,7 @@ void jl_register_fptrs(uint64_t sysimage_base, const jl_sysimg_fptrs_t *fptrs,
743740
}
744741

745742
template<typename T>
746-
static inline void ignoreError(T &err)
743+
static inline void ignoreError(T &err) JL_NOTSAFEPOINT
747744
{
748745
#if !defined(NDEBUG)
749746
// Needed only with LLVM assertion build
@@ -752,7 +749,7 @@ static inline void ignoreError(T &err)
752749
}
753750

754751
static void get_function_name_and_base(llvm::object::SectionRef Section, size_t pointer, int64_t slide, bool insysimage,
755-
void **saddr, char **name, bool untrusted_dladdr)
752+
void **saddr, char **name, bool untrusted_dladdr) JL_NOTSAFEPOINT
756753
{
757754
// Assume we only need base address for sysimg for now
758755
if (!insysimage || !sysimg_fptrs.base)
@@ -837,7 +834,7 @@ static void get_function_name_and_base(llvm::object::SectionRef Section, size_t
837834
#endif
838835
}
839836

840-
static objfileentry_t &find_object_file(uint64_t fbase, StringRef fname)
837+
static objfileentry_t &find_object_file(uint64_t fbase, StringRef fname) JL_NOTSAFEPOINT
841838
{
842839
int isdarwin = 0, islinux = 0, iswindows = 0;
843840
#if defined(_OS_DARWIN_)
@@ -1035,7 +1032,7 @@ static objfileentry_t &find_object_file(uint64_t fbase, StringRef fname)
10351032
}
10361033

10371034
// from llvm::SymbolizableObjectFile
1038-
static object::SectionRef getModuleSectionForAddress(const object::ObjectFile *obj, uint64_t Address)
1035+
static object::SectionRef getModuleSectionForAddress(const object::ObjectFile *obj, uint64_t Address) JL_NOTSAFEPOINT
10391036
{
10401037
for (object::SectionRef Sec : obj->sections()) {
10411038
if (!Sec.isText() || Sec.isVirtual())
@@ -1049,7 +1046,7 @@ static object::SectionRef getModuleSectionForAddress(const object::ObjectFile *o
10491046

10501047
extern "C" void jl_refresh_dbg_module_list(void);
10511048
bool jl_dylib_DI_for_fptr(size_t pointer, object::SectionRef *Section, int64_t *slide, llvm::DIContext **context,
1052-
bool onlySysImg, bool *isSysImg, void **saddr, char **name, char **filename)
1049+
bool onlySysImg, bool *isSysImg, void **saddr, char **name, char **filename) JL_NOTSAFEPOINT
10531050
{
10541051
*Section = object::SectionRef();
10551052
*context = NULL;
@@ -1139,7 +1136,7 @@ bool jl_dylib_DI_for_fptr(size_t pointer, object::SectionRef *Section, int64_t *
11391136
}
11401137

11411138
// *name and *filename should be either NULL or malloc'd pointer
1142-
static int jl_getDylibFunctionInfo(jl_frame_t **frames, size_t pointer, int skipC, int noInline)
1139+
static int jl_getDylibFunctionInfo(jl_frame_t **frames, size_t pointer, int skipC, int noInline) JL_NOTSAFEPOINT
11431140
{
11441141
// This function is not allowed to reference any TLS variables if noInline
11451142
// since it can be called from an unmanaged thread on OSX.

src/debuginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ int jl_DI_for_fptr(uint64_t fptr, uint64_t *symsize, int64_t *slide,
66
llvm::object::SectionRef *Section, llvm::DIContext **context) JL_NOTSAFEPOINT;
77

88
bool jl_dylib_DI_for_fptr(size_t pointer, llvm::object::SectionRef *Section, int64_t *slide, llvm::DIContext **context,
9-
bool onlySysImg, bool *isSysImg, void **saddr, char **name, char **filename);
9+
bool onlySysImg, bool *isSysImg, void **saddr, char **name, char **filename) JL_NOTSAFEPOINT;
1010

1111
#if JL_LLVM_VERSION >= 90000
1212
static object::SectionedAddress makeAddress(
13-
llvm::object::SectionRef Section, uint64_t address)
13+
llvm::object::SectionRef Section, uint64_t address) JL_NOTSAFEPOINT
1414
{
1515
return object::SectionedAddress{address, Section.getIndex()};
1616
}
1717
#else
18-
static uint64_t makeAddress(llvm::object::SectionRef Section, uint64_t address)
18+
static uint64_t makeAddress(llvm::object::SectionRef Section, uint64_t address) JL_NOTSAFEPOINT
1919
{
2020
return address;
2121
}

src/julia.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,7 @@ JL_DLLEXPORT void jl_sigatomic_end(void);
16761676
// tasks and exceptions -------------------------------------------------------
16771677

16781678
typedef struct _jl_timing_block_t jl_timing_block_t;
1679+
typedef struct _jl_excstack_t jl_excstack_t;
16791680

16801681
// info describing an exception handler
16811682
typedef struct _jl_handler_t {

src/julia_internal.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ jl_value_t *jl_permbox32(jl_datatype_t *t, int32_t x);
291291
jl_value_t *jl_permbox64(jl_datatype_t *t, int64_t x);
292292
jl_svec_t *jl_perm_symsvec(size_t n, ...);
293293

294+
#if !defined(__clang_analyzer__) // this sizeof(__VA_ARGS__) trick can't be computed until C11, but only the analyzer seems to care
294295
#ifdef __GNUC__
295296
#define jl_perm_symsvec(n, ...) \
296297
(jl_perm_symsvec)(__extension__({ \
@@ -307,6 +308,7 @@ jl_svec_t *jl_perm_symsvec(size_t n, ...);
307308
n; \
308309
}), __VA_ARGS__)
309310
#endif
311+
#endif
310312

311313
jl_value_t *jl_gc_realloc_string(jl_value_t *s, size_t sz);
312314
JL_DLLEXPORT void *jl_gc_counted_malloc(size_t sz);
@@ -754,7 +756,7 @@ JL_DLLEXPORT void jl_gdblookup(void* ip) JL_NOTSAFEPOINT;
754756
void jl_print_native_codeloc(uintptr_t ip) JL_NOTSAFEPOINT;
755757
void jl_print_bt_entry_codeloc(jl_bt_element_t *bt_data) JL_NOTSAFEPOINT;
756758
// *to is NULL or malloc'd pointer, from is allowed to be NULL
757-
STATIC_INLINE char *jl_copy_str(char **to, const char *from)
759+
STATIC_INLINE char *jl_copy_str(char **to, const char *from) JL_NOTSAFEPOINT
758760
{
759761
if (!from) {
760762
free(*to);
@@ -772,14 +774,14 @@ JL_DLLEXPORT size_t jl_capture_interp_frame(jl_bt_element_t *bt_data,
772774

773775
// Exception stack: a stack of pairs of (exception,raw_backtrace).
774776
// The stack may be traversed and accessed with the functions below.
775-
typedef struct _jl_excstack_t {
777+
struct _jl_excstack_t { // typedef in julia.h
776778
size_t top;
777779
size_t reserved_size;
778780
// Pack all stack entries into a growable buffer to amortize allocation
779781
// across repeated exception handling.
780782
// Layout: [bt_data1... bt_size1 exc1 bt_data2... bt_size2 exc2 ..]
781783
// jl_bt_element_t data[]; // Access with jl_excstack_raw
782-
} jl_excstack_t;
784+
};
783785

784786
STATIC_INLINE jl_bt_element_t *jl_excstack_raw(jl_excstack_t *stack) JL_NOTSAFEPOINT
785787
{

src/julia_threads.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ typedef struct {
155155
jl_gc_mark_data_t *data_stack;
156156
} jl_gc_mark_cache_t;
157157

158-
typedef struct _jl_excstack_t jl_excstack_t;
159158
struct _jl_bt_element_t;
160159
// This includes all the thread local states we care about for a thread.
161160
// Changes to TLS field types must be reflected in codegen.

0 commit comments

Comments
 (0)