Skip to content

Commit

Permalink
[GCChecker] support c++ code and improve makefile support (#34078)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vtjnash authored and KristofferC committed Apr 11, 2020
1 parent 505b530 commit 1d96a7e
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ endif
ifeq ($(USECLANG),1)
CC := $(CROSS_COMPILE)clang
CXX := $(CROSS_COMPILE)clang++
JCFLAGS := -pipe $(fPIC) -fno-strict-aliasing -D_FILE_OFFSET_BITS=64
JCFLAGS := -std=gnu99 -pipe $(fPIC) -fno-strict-aliasing -D_FILE_OFFSET_BITS=64
# AArch64 needs this flag to generate the .eh_frame used by libunwind
JCPPFLAGS := -fasynchronous-unwind-tables
JCXXFLAGS := -pipe $(fPIC) -fno-rtti -pedantic
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ ifeq ($(OS),WINNT)
ifeq ($(XC_HOST),)
STD_LIB_PATH ?= $(PATH)
else
STD_LIB_PATH := $(shell LANG=C $(CC) -print-search-dirs | grep programs | sed -e "s/^programs: =//")
STD_LIB_PATH += :$(shell LANG=C $(CC) -print-search-dirs | grep libraries | sed -e "s/^libraries: =//")
STD_LIB_PATH := $(shell LANG=C $(CC) -print-search-dirs | grep '^programs: =' | sed -e "s/^programs: =//")
STD_LIB_PATH += :$(shell LANG=C $(CC) -print-search-dirs | grep '^libraries: =' | sed -e "s/^libraries: =//")
ifneq (,$(findstring CYGWIN,$(BUILD_OS))) # the cygwin-mingw32 compiler lies about it search directory paths
STD_LIB_PATH := $(shell echo '$(STD_LIB_PATH)' | sed -e "s!/lib/!/bin/!g")
endif
Expand Down
68 changes: 45 additions & 23 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,20 @@ ifeq ($(OS),FreeBSD)
FLAGS += -I$(LOCALBASE)/include
endif

RUNTIME_C_SRCS := \
RUNTIME_SRCS := \
jltypes gf typemap ast builtins module interpreter symbol \
dlload sys init task array dump staticdata toplevel jl_uv datatype \
simplevector runtime_intrinsics precompile \
threading partr stackwalk gc gc-debug gc-pages gc-stacks method \
jlapi signal-handling safepoint timing subtype \
crc32c
RUNTIME_SRCS := APInt-C runtime_ccall processor rtutils jloptions $(RUNTIME_C_SRCS)
SRCS := $(RUNTIME_SRCS)

ifeq ($(USEMSVC), 1)
SRCS += getopt
endif
crc32c APInt-C processor
SRCS := jloptions runtime_ccall rtutils

LLVMLINK :=

ifeq ($(JULIACODEGEN),LLVM)
SRCS += codegen jitlayers disasm debuginfo llvm-simdloop llvm-ptls llvm-muladd \
SRCS += codegen llvm-ptls
RUNTIME_SRCS += jitlayers debuginfo disasm llvm-simdloop llvm-muladd \
llvm-final-gc-lowering llvm-pass-helpers llvm-late-gc-lowering \
llvm-lower-handlers llvm-gc-invariant-verifier llvm-propagate-addrspaces \
llvm-multiversioning llvm-alloc-opt cgmemmgr llvm-api
Expand All @@ -77,10 +73,17 @@ FLAGS += -I$(shell $(LLVM_CONFIG_HOST) --src-root)/tools/polly/tools # Required
endif
endif
else
SRCS += anticodegen
RUNTIME_SRCS += anticodegen
LLVM_LIBS := support
endif

ifeq ($(USEMSVC), 1)
SRCS += getopt
endif

SRCS += $(RUNTIME_SRCS)


# headers are used for dependency tracking, while public headers will be part of the dist
UV_HEADERS :=
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)
Expand All @@ -91,26 +94,31 @@ UV_HEADERS += uv/*.h
endif
PUBLIC_HEADER_TARGETS := $(addprefix $(build_includedir)/julia/,$(notdir $(PUBLIC_HEADERS)) $(UV_HEADERS))

LLVM_LDFLAGS := $(shell $(LLVM_CONFIG_HOST) --ldflags)
LLVM_CXXFLAGS := $(shell $(LLVM_CONFIG_HOST) --cxxflags)

ifeq ($(JULIACODEGEN),LLVM)
ifneq ($(USE_SYSTEM_LLVM),0)
LLVMLINK += $(shell $(LLVM_CONFIG_HOST) --ldflags --libs --system-libs)
LLVMLINK += $(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --libs --system-libs)
# HACK: llvm-config doesn't correctly point to shared libs on all platforms
# https://github.com/JuliaLang/julia/issues/29981
else
ifneq ($(USE_LLVM_SHLIB),1)
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)
LLVMLINK += $(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --libs $(LLVM_LIBS)) $($(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --system-libs 2> /dev/null)
else
LLVMLINK += $(shell $(LLVM_CONFIG_HOST) --ldflags) -lLLVM
LLVMLINK += $(LLVM_LDFLAGS) -lLLVM
endif
endif
ifeq ($(USE_LLVM_SHLIB),1)
FLAGS += -DLLVM_SHLIB
endif # USE_LLVM_SHLIB == 1
endif

CLANGLINK :=
CLANGLINK += -lclangAnalysis -lclangStaticAnalyzerCore -lclangASTMatchers -lclangAST -lclangLex -lclangBasic
CLANGLINK += $(LLVMLINK)
CLANG_LDFLAGS := $(LLVM_LDFLAGS)
ifeq ($(OS), Darwin)
CLANG_LDFLAGS += -Wl,-undefined,dynamic_lookup
endif


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

# public header rules
$(eval $(call dir_target,$(build_includedir)/julia))
Expand Down Expand Up @@ -196,7 +204,7 @@ endif
$(INSTALL_NAME_CMD)libccalltest.$(SHLIB_EXT) $@

$(build_shlibdir)/libllvmcalltest.$(SHLIB_EXT): $(SRCDIR)/llvmcalltest.cpp $(LLVM_CONFIG_ABSOLUTE)
@$(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))
@$(call PRINT_CC, $(CXX) $(LLVM_CXXFLAGS) $(JCXXFLAGS) $(JCPPFLAGS) $(DEBUGFLAGS) -O3 $< $(fPIC) -shared -o $@ $(JLDFLAGS) -L$(build_shlibdir) -L$(build_libdir) $(NO_WHOLE_ARCHIVE) $(LLVMLINK))

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

Expand Down Expand Up @@ -348,7 +356,8 @@ clean-support:
cleanall: clean clean-flisp clean-support clean-analyzegc

$(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT): $(SRCDIR)/clangsa/GCChecker.cpp $(LLVM_CONFIG_ABSOLUTE)
@$(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))
@$(call PRINT_CC, $(CXX) -g $(fPIC) -shared -o $@ -DCLANG_PLUGIN -I$(build_includedir) -L$(build_libdir) \
$(LLVM_CXXFLAGS) $(CLANG_LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(CXXLDFLAGS) $<)

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


# Note: we're passing *FLAGS here computed based on your system compiler to
# clang. If that causes you problems, you might want to build and/or run
# specific clang-sa-* files with clang explicitly selected:
# make CC=~+/../usr/tools/clang CXX=~+/../usr/tools/clang USECLANG=1 analyzegc
# make USECLANG=1 clang-sa-*
CLANGSA_FLAGS :=
ifeq ($(OS), Darwin) # on new XCode, the files are hidden
CLANGSA_FLAGS += -isysroot $(shell xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
endif
clang-sa-%: $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) | analyzegc-deps-check
@$(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)
ifeq ($(USEGCC),1)
# try to help clang find the c++ files for CC by guessing the value for --prefix
# by dropping lib/gcc/<platform>/<version> from the install directory it reports
CLANGSA_FLAGS += --gcc-toolchain="$(abspath $(shell LANG=C $(CC) -print-search-dirs | grep '^install: ' | sed -e "s/^install: //")/../../../..)"
endif

clang-sa-%: $(SRCDIR)/%.c $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) | analyzegc-deps-check
@$(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 $<)
clang-sa-%: $(SRCDIR)/%.cpp $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT) | analyzegc-deps-check
@$(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++ $<)

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

clean-analyzegc:
rm -f $(build_shlibdir)/libGCCheckerPlugin.$(SHLIB_EXT)
Expand Down
5 changes: 3 additions & 2 deletions src/clangsa/GCChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,10 @@ bool GCChecker::isSafepoint(const CallEvent &Call) const
isCalleeSafepoint = !declHasAnnotation(TDT->getDecl(), "julia_not_safepoint");
}
} else if (FD) {
if (FD->getBuiltinID() != 0)
if (FD->getBuiltinID() != 0 || FD->isTrivial())
isCalleeSafepoint = false;
else if ((FD->getName().startswith_lower("uv_") ||
else if (FD->getDeclName().isIdentifier() &&
(FD->getName().startswith_lower("uv_") ||
FD->getName().startswith_lower("unw_") ||
FD->getName().startswith("_U")) &&
FD->getName() != "uv_run")
Expand Down
25 changes: 11 additions & 14 deletions src/debuginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class JuliaJITEventListener: public JITEventListener
JuliaJITEventListener(){}
virtual ~JuliaJITEventListener() {}

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

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

static std::pair<char *, bool> jl_demangle(const char *name)
static std::pair<char *, bool> jl_demangle(const char *name) JL_NOTSAFEPOINT
{
// This function is not allowed to reference any TLS variables since
// it can be called from an unmanaged thread on OSX.
Expand Down Expand Up @@ -487,7 +487,7 @@ JITEventListener *CreateJuliaJITEventListener()
static int lookup_pointer(
object::SectionRef Section, DIContext *context,
jl_frame_t **frames, size_t pointer, int64_t slide,
bool demangle, bool noInline)
bool demangle, bool noInline) JL_NOTSAFEPOINT
{
// This function is not allowed to reference any TLS variables
// since it can be called from an unmanaged thread on OSX.
Expand All @@ -510,7 +510,6 @@ static int lookup_pointer(
}
return 1;
}
jl_mutex_lock_maybe_nogc(&codegen_lock);
DILineInfoSpecifier infoSpec(DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath,
DILineInfoSpecifier::FunctionNameKind::ShortName);

Expand All @@ -519,7 +518,6 @@ static int lookup_pointer(
int fromC = (*frames)[0].fromC;
int n_frames = inlineInfo.getNumberOfFrames();
if (n_frames == 0) {
jl_mutex_unlock_maybe_nogc(&codegen_lock);
// no line number info available in the context, return without the context
return lookup_pointer(object::SectionRef(), NULL, frames, pointer, slide, demangle, noInline);
}
Expand Down Expand Up @@ -571,7 +569,6 @@ static int lookup_pointer(
else
jl_copy_str(&frame->file_name, file_name.c_str());
}
jl_mutex_unlock_maybe_nogc(&codegen_lock);
return n_frames;
}

Expand Down Expand Up @@ -607,7 +604,7 @@ struct debug_link_info {
StringRef filename;
uint32_t crc32;
};
static debug_link_info getDebuglink(const object::ObjectFile &Obj)
static debug_link_info getDebuglink(const object::ObjectFile &Obj) JL_NOTSAFEPOINT
{
debug_link_info info = {};
for (const object::SectionRef &Section: Obj.sections()) {
Expand Down Expand Up @@ -743,7 +740,7 @@ void jl_register_fptrs(uint64_t sysimage_base, const jl_sysimg_fptrs_t *fptrs,
}

template<typename T>
static inline void ignoreError(T &err)
static inline void ignoreError(T &err) JL_NOTSAFEPOINT
{
#if !defined(NDEBUG)
// Needed only with LLVM assertion build
Expand All @@ -752,7 +749,7 @@ static inline void ignoreError(T &err)
}

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

static objfileentry_t &find_object_file(uint64_t fbase, StringRef fname)
static objfileentry_t &find_object_file(uint64_t fbase, StringRef fname) JL_NOTSAFEPOINT
{
int isdarwin = 0, islinux = 0, iswindows = 0;
#if defined(_OS_DARWIN_)
Expand Down Expand Up @@ -1035,7 +1032,7 @@ static objfileentry_t &find_object_file(uint64_t fbase, StringRef fname)
}

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

extern "C" void jl_refresh_dbg_module_list(void);
bool jl_dylib_DI_for_fptr(size_t pointer, object::SectionRef *Section, int64_t *slide, llvm::DIContext **context,
bool onlySysImg, bool *isSysImg, void **saddr, char **name, char **filename)
bool onlySysImg, bool *isSysImg, void **saddr, char **name, char **filename) JL_NOTSAFEPOINT
{
*Section = object::SectionRef();
*context = NULL;
Expand Down Expand Up @@ -1139,7 +1136,7 @@ bool jl_dylib_DI_for_fptr(size_t pointer, object::SectionRef *Section, int64_t *
}

// *name and *filename should be either NULL or malloc'd pointer
static int jl_getDylibFunctionInfo(jl_frame_t **frames, size_t pointer, int skipC, int noInline)
static int jl_getDylibFunctionInfo(jl_frame_t **frames, size_t pointer, int skipC, int noInline) JL_NOTSAFEPOINT
{
// This function is not allowed to reference any TLS variables if noInline
// since it can be called from an unmanaged thread on OSX.
Expand Down
6 changes: 3 additions & 3 deletions src/debuginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ int jl_DI_for_fptr(uint64_t fptr, uint64_t *symsize, int64_t *slide,
llvm::object::SectionRef *Section, llvm::DIContext **context) JL_NOTSAFEPOINT;

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

#if JL_LLVM_VERSION >= 90000
static object::SectionedAddress makeAddress(
llvm::object::SectionRef Section, uint64_t address)
llvm::object::SectionRef Section, uint64_t address) JL_NOTSAFEPOINT
{
return object::SectionedAddress{address, Section.getIndex()};
}
#else
static uint64_t makeAddress(llvm::object::SectionRef Section, uint64_t address)
static uint64_t makeAddress(llvm::object::SectionRef Section, uint64_t address) JL_NOTSAFEPOINT
{
return address;
}
Expand Down
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,7 @@ JL_DLLEXPORT void jl_sigatomic_end(void);
// tasks and exceptions -------------------------------------------------------

typedef struct _jl_timing_block_t jl_timing_block_t;
typedef struct _jl_excstack_t jl_excstack_t;

// info describing an exception handler
typedef struct _jl_handler_t {
Expand Down
8 changes: 5 additions & 3 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ jl_value_t *jl_permbox32(jl_datatype_t *t, int32_t x);
jl_value_t *jl_permbox64(jl_datatype_t *t, int64_t x);
jl_svec_t *jl_perm_symsvec(size_t n, ...);

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

jl_value_t *jl_gc_realloc_string(jl_value_t *s, size_t sz);
JL_DLLEXPORT void *jl_gc_counted_malloc(size_t sz);
Expand Down Expand Up @@ -754,7 +756,7 @@ JL_DLLEXPORT void jl_gdblookup(void* ip) JL_NOTSAFEPOINT;
void jl_print_native_codeloc(uintptr_t ip) JL_NOTSAFEPOINT;
void jl_print_bt_entry_codeloc(jl_bt_element_t *bt_data) JL_NOTSAFEPOINT;
// *to is NULL or malloc'd pointer, from is allowed to be NULL
STATIC_INLINE char *jl_copy_str(char **to, const char *from)
STATIC_INLINE char *jl_copy_str(char **to, const char *from) JL_NOTSAFEPOINT
{
if (!from) {
free(*to);
Expand All @@ -772,14 +774,14 @@ JL_DLLEXPORT size_t jl_capture_interp_frame(jl_bt_element_t *bt_data,

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

STATIC_INLINE jl_bt_element_t *jl_excstack_raw(jl_excstack_t *stack) JL_NOTSAFEPOINT
{
Expand Down
1 change: 0 additions & 1 deletion src/julia_threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ typedef struct {
jl_gc_mark_data_t *data_stack;
} jl_gc_mark_cache_t;

typedef struct _jl_excstack_t jl_excstack_t;
struct _jl_bt_element_t;
// This includes all the thread local states we care about for a thread.
// Changes to TLS field types must be reflected in codegen.
Expand Down
Loading

0 comments on commit 1d96a7e

Please sign in to comment.