Skip to content

Commit

Permalink
[loader]: Re-export symbols for C embedding, rename to `libjulia-inte…
Browse files Browse the repository at this point in the history
…rnal` (JuliaLang#38160)
  • Loading branch information
staticfloat authored Dec 2, 2020
1 parent 5b6a081 commit 2e3364e
Show file tree
Hide file tree
Showing 44 changed files with 1,653 additions and 548 deletions.
51 changes: 35 additions & 16 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ USEGCC := 0
USECLANG := 0
USEICC := 0
else
USEMSVC := 0
ifeq ($(USECLANG), 1)
USEGCC := 0
USEICC := 0
Expand Down Expand Up @@ -522,7 +523,7 @@ ifneq ($(OS), WINNT)
# Do not enable on windows to avoid warnings from libuv.
JCXXFLAGS += -pedantic
endif
DEBUGFLAGS := -O0 -ggdb2 -DJL_DEBUG_BUILD -fstack-protector-all
DEBUGFLAGS := -O0 -ggdb2 -DJL_DEBUG_BUILD -fstack-protector
SHIPFLAGS := -O3 -ggdb2 -falign-functions
endif

Expand All @@ -533,7 +534,7 @@ 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
DEBUGFLAGS := -O0 -g -DJL_DEBUG_BUILD -fstack-protector-all
DEBUGFLAGS := -O0 -g -DJL_DEBUG_BUILD -fstack-protector
SHIPFLAGS := -O3 -g
ifeq ($(OS), Darwin)
ifeq ($(MACOSX_VERSION_MIN),)
Expand All @@ -557,7 +558,7 @@ CXX := icpc
JCFLAGS := -std=gnu11 -pipe $(fPIC) -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -fp-model precise -fp-model except -no-ftz
JCPPFLAGS :=
JCXXFLAGS := -pipe $(fPIC) -fno-rtti
DEBUGFLAGS := -O0 -g -DJL_DEBUG_BUILD -fstack-protector-all
DEBUGFLAGS := -O0 -g -DJL_DEBUG_BUILD -fstack-protector
SHIPFLAGS := -O3 -g -falign-functions
endif

Expand Down Expand Up @@ -623,6 +624,24 @@ else
SHLIB_EXT := so
endif

ifeq ($(SHLIB_EXT), so)
define SONAME_FLAGS
-Wl,-soname=$1
endef
else
define SONAME_FLAGS
endef
endif

ifeq ($(OS)$(USEMSVC),WINNT0)
define IMPLIB_FLAGS
-Wl,--out-implib,$(build_libdir)/$(notdir $1).a
endef
else
define IMPLIB_FLAGS
endef
endif

# On Windows, we want shared library files to end up in $(build_bindir), instead of $(build_libdir)
# We also don't really have a private bindir on windows right now, due to lack of RPATH.
ifeq ($(OS),WINNT)
Expand Down Expand Up @@ -1507,11 +1526,11 @@ define dep_lib_path
$$($(PYTHON) $(call python_cygpath,$(JULIAHOME)/contrib/relative_path.py) $(1) $(2))
endef

LIBJULIA_BUILD_DEPLIB := $(call dep_lib_path,$(build_bindir),$(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT))
LIBJULIA_INSTALL_DEPLIB := $(call dep_lib_path,$(bindir),$(shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT))
LIBJULIAINTERNAL_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_shlibdir)/libjulia-internal.$(JL_MAJOR_MINOR_SHLIB_EXT))
LIBJULIAINTERNAL_INSTALL_DEPLIB := $(call dep_lib_path,$(libdir),$(private_shlibdir)/libjulia-internal.$(JL_MAJOR_MINOR_SHLIB_EXT))

LIBJULIA_DEBUG_BUILD_DEPLIB := $(call dep_lib_path,$(build_bindir),$(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT))
LIBJULIA_DEBUG_INSTALL_DEPLIB := $(call dep_lib_path,$(bindir),$(shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT))
LIBJULIAINTERNAL_DEBUG_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_shlibdir)/libjulia-internal-debug.$(JL_MAJOR_MINOR_SHLIB_EXT))
LIBJULIAINTERNAL_DEBUG_INSTALL_DEPLIB := $(call dep_lib_path,$(libdir),$(private_shlibdir)/libjulia-internal-debug.$(JL_MAJOR_MINOR_SHLIB_EXT))

ifeq ($(OS),WINNT)
ifeq ($(BINARY),32)
Expand All @@ -1532,16 +1551,16 @@ LIBGCC_NAME := libgcc_s.$(SHLIB_EXT).1
endif


LIBGCC_BUILD_DEPLIB := $(call dep_lib_path,$(build_bindir),$(build_shlibdir)/$(LIBGCC_NAME))
LIBGCC_INSTALL_DEPLIB := $(call dep_lib_path,$(bindir),$(private_shlibdir)/$(LIBGCC_NAME))
LIBGCC_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_shlibdir)/$(LIBGCC_NAME))
LIBGCC_INSTALL_DEPLIB := $(call dep_lib_path,$(libdir),$(private_shlibdir)/$(LIBGCC_NAME))

# USE_SYSTEM_LIBM causes it to get symlinked into build_private_shlibdir
ifeq ($(USE_SYSTEM_LIBM),1)
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_bindir),$(build_private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
else
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_bindir),$(build_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
endif
LIBM_INSTALL_DEPLIB := $(call dep_lib_path,$(bindir),$(private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
LIBM_INSTALL_DEPLIB := $(call dep_lib_path,$(libdir),$(private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))

# We list:
# * libgcc_s, because FreeBSD needs to load ours, not the system one.
Expand All @@ -1552,10 +1571,10 @@ LIBM_INSTALL_DEPLIB := $(call dep_lib_path,$(bindir),$(private_shlibdir)/$(LIBMN
# * debug builds must link against libjuliadebug, not libjulia
# * install time relative paths are not equal to build time relative paths (../lib vs. ../lib/julia)
# That second point will no longer be true for most deps once they are placed within Artifacts directories.
LOADER_BUILD_DEP_LIBS = $(LIBGCC_BUILD_DEPLIB):$(LIBM_BUILD_DEPLIB):$(LIBJULIA_BUILD_DEPLIB)
LOADER_DEBUG_BUILD_DEP_LIBS = $(LIBGCC_BUILD_DEPLIB):$(LIBM_BUILD_DEPLIB):$(LIBJULIA_DEBUG_BUILD_DEPLIB)
LOADER_INSTALL_DEP_LIBS = $(LIBGCC_INSTALL_DEPLIB):$(LIBM_INSTALL_DEPLIB):$(LIBJULIA_INSTALL_DEPLIB)
LOADER_DEBUG_INSTALL_DEP_LIBS = $(LIBGCC_INSTALL_DEPLIB):$(LIBM_INSTALL_DEPLIB):$(LIBJULIA_DEBUG_INSTALL_DEPLIB)
LOADER_BUILD_DEP_LIBS = $(LIBGCC_BUILD_DEPLIB):$(LIBM_BUILD_DEPLIB):$(LIBJULIAINTERNAL_BUILD_DEPLIB)
LOADER_DEBUG_BUILD_DEP_LIBS = $(LIBGCC_BUILD_DEPLIB):$(LIBM_BUILD_DEPLIB):$(LIBJULIAINTERNAL_DEBUG_BUILD_DEPLIB)
LOADER_INSTALL_DEP_LIBS = $(LIBGCC_INSTALL_DEPLIB):$(LIBM_INSTALL_DEPLIB):$(LIBJULIAINTERNAL_INSTALL_DEPLIB)
LOADER_DEBUG_INSTALL_DEP_LIBS = $(LIBGCC_INSTALL_DEPLIB):$(LIBM_INSTALL_DEPLIB):$(LIBJULIAINTERNAL_DEBUG_INSTALL_DEPLIB)

# Colors for make
ifndef VERBOSE
Expand Down
29 changes: 15 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ julia-libccalltest: julia-deps
julia-libllvmcalltest: julia-deps
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src libllvmcalltest

julia-src-release julia-src-debug : julia-src-% : julia-deps julia_flisp.boot.inc.phony
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src libjulia-$*
julia-src-release julia-src-debug : julia-src-% : julia-deps julia_flisp.boot.inc.phony julia-cli-%
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src $*

julia-cli-release julia-cli-debug : julia-cli-% : julia-src-%
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/cli julia-$*
julia-cli-release julia-cli-debug: julia-cli-% :
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/cli $*

julia-sysimg-ji : julia-stdlib julia-base julia-cli-$(JULIA_BUILD_MODE) | $(build_private_libdir)
julia-sysimg-ji : julia-stdlib julia-base julia-cli-$(JULIA_BUILD_MODE) julia-src-$(JULIA_BUILD_MODE) | $(build_private_libdir)
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) -f sysimage.mk sysimg-ji JULIA_EXECUTABLE='$(JULIA_EXECUTABLE)'

julia-sysimg-bc : julia-stdlib julia-base julia-cli-$(JULIA_BUILD_MODE) | $(build_private_libdir)
julia-sysimg-bc : julia-stdlib julia-base julia-cli-$(JULIA_BUILD_MODE) julia-src-$(JULIA_BUILD_MODE) | $(build_private_libdir)
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) -f sysimage.mk sysimg-bc JULIA_EXECUTABLE='$(JULIA_EXECUTABLE)'

julia-sysimg-release julia-sysimg-debug : julia-sysimg-% : julia-sysimg-ji julia-cli-%
Expand Down Expand Up @@ -155,13 +155,16 @@ julia-base-cache: julia-sysimg-$(JULIA_BUILD_MODE) | $(DIRS) $(build_datarootdir
$(call cygpath_w,$(build_datarootdir)/julia/base.cache))

# public libraries, that are installed in $(prefix)/lib
JL_TARGETS := julia julialoader
JL_TARGETS := julia
ifeq ($(BUNDLE_DEBUG_LIBS),1)
JL_TARGETS += julia-debug julialoader-debug
JL_TARGETS += julia-debug
endif

# private libraries, that are installed in $(prefix)/lib/julia
JL_PRIVATE_LIBS-0 := libccalltest libllvmcalltest
JL_PRIVATE_LIBS-0 := libccalltest libllvmcalltest libjulia-internal
ifeq ($(BUNDLE_DEBUG_LIBS),1)
JL_TARGETS += libjulia-internal-debug
endif
ifeq ($(USE_GPL_LIBS), 1)
JL_PRIVATE_LIBS-0 += libsuitesparse_wrapper
JL_PRIVATE_LIBS-$(USE_SYSTEM_SUITESPARSE) += libamd libbtf libcamd libccolamd libcholmod libcolamd libklu libldl librbio libspqr libsuitesparseconfig libumfpack
Expand Down Expand Up @@ -356,13 +359,11 @@ endif
endif

ifneq ($(LOADER_BUILD_DEP_LIBS),$(LOADER_INSTALL_DEP_LIBS))
# Next, overwrite relative path to libjulia in our loaders if $(LOADER_BUILD_DEP_LIBS) != $(LOADER_INSTALL_DEP_LIBS)
$(call stringreplace,$(DESTDIR)$(bindir)/julia,$(LOADER_BUILD_DEP_LIBS)$$,$(LOADER_INSTALL_DEP_LIBS))
$(call stringreplace,$(DESTDIR)$(shlibdir)/libjulialoader.$(JL_MAJOR_MINOR_SHLIB_EXT),$(LOADER_BUILD_DEP_LIBS)$$,$(LOADER_INSTALL_DEP_LIBS))
# Next, overwrite relative path to libjulia-internal in our loader if $(LOADER_BUILD_DEP_LIBS) != $(LOADER_INSTALL_DEP_LIBS)
$(call stringreplace,$(DESTDIR)$(shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT),$(LOADER_BUILD_DEP_LIBS)$$,$(LOADER_INSTALL_DEP_LIBS))

ifeq ($(BUNDLE_DEBUG_LIBS),1)
$(call stringreplace,$(DESTDIR)$(bindir)/julia-debug,$(LOADER_DEBUG_BUILD_DEP_LIBS)$$,$(LOADER_DEBUG_INSTALL_DEP_LIBS))
$(call stringreplace,$(DESTDIR)$(shlibdir)/libjulialoader-debug.$(JL_MAJOR_MINOR_SHLIB_EXT),$(LOADER_DEBUG_BUILD_DEP_LIBS)$$,$(LOADER_DEBUG_INSTALL_DEP_LIBS))
$(call stringreplace,$(DESTDIR)$(shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT),$(LOADER_DEBUG_BUILD_DEP_LIBS)$$,$(LOADER_DEBUG_INSTALL_DEP_LIBS))
endif
endif

Expand Down
97 changes: 68 additions & 29 deletions cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ include $(JULIAHOME)/Make.inc
include $(JULIAHOME)/deps/llvm-ver.make


HEADERS := $(addprefix $(JULIAHOME)/src/,julia.h julia_assert.h julia_threads.h julia_internal.h options.h) \
$(BUILDDIR)/../src/julia_version.h $(wildcard $(JULIAHOME)/src/support/*.h) $(LIBUV_INC)/uv.h
HEADERS := jl_exports.h loader.h $(addprefix $(JULIAHOME)/src/support/,platform.h dirpath.h) $(addprefix $(JULIAHOME)/src/,jl_exported_data.inc jl_exported_funcs.inc)

LOADER_CFLAGS = $(JCFLAGS) -I$(BUILDROOT)/src -I$(JULIAHOME)/src -I$(JULIAHOME)/src/support -I$(build_includedir) -ffreestanding
LOADER_LDFLAGS = $(JLDFLAGS) -ffreestanding
LOADER_LDFLAGS = $(JLDFLAGS) -ffreestanding -L$(build_shlibdir) -L$(build_libdir)

ifeq ($(OS),WINNT)
LOADER_CFLAGS += -municode -mconsole -nostdlib -fno-stack-check -fno-stack-protector -mno-stack-arg-probe
Expand All @@ -31,20 +30,35 @@ endif
SHIPFLAGS += -DDEP_LIBS="\"$(LOADER_BUILD_DEP_LIBS)\""
DEBUGFLAGS += -DDEP_LIBS="\"$(LOADER_DEBUG_BUILD_DEP_LIBS)\""

SRCS := loader_exe loader_lib
OBJS := $(SRCS:%=$(BUILDDIR)/%.o)
DOBJS := $(SRCS:%=$(BUILDDIR)/%.dbg.obj)
EXE_OBJS := $(BUILDDIR)/loader_exe.o
EXE_DOBJS := $(BUILDDIR)/loader_exe.dbg.obj
LIB_OBJS := $(BUILDDIR)/loader_lib.o
LIB_DOBJS := $(BUILDDIR)/loader_lib.dbg.obj

# If this is an architecture that supports dynamic linking, link in a trampoline definition
ifneq (,$(wildcard $(SRCDIR)/trampolines/trampolines_$(ARCH).S))
LIB_OBJS += $(BUILDDIR)/loader_trampolines.o
LIB_DOBJS += $(BUILDDIR)/loader_trampolines.o
endif

default: release
all: release debug
release debug : % : julia-%
release debug : % : julia-% libjulia-%

$(BUILDDIR)/%.o: $(SRCDIR)/%.c $(HEADERS)
$(BUILDDIR)/loader_lib.o : $(SRCDIR)/loader_lib.c $(HEADERS)
@$(call PRINT_CC, $(CC) -DLIBRARY_EXPORTS $(SHIPFLAGS) $(LOADER_CFLAGS) -c $< -o $@)
$(BUILDDIR)/loader_lib.dbg.obj : $(SRCDIR)/loader_lib.c $(HEADERS)
@$(call PRINT_CC, $(CC) -DLIBRARY_EXPORTS $(DEBUGFLAGS) $(LOADER_CFLAGS) -c $< -o $@)
$(BUILDDIR)/loader_exe.o : $(SRCDIR)/loader_exe.c $(HEADERS)
@$(call PRINT_CC, $(CC) $(SHIPFLAGS) $(LOADER_CFLAGS) -c $< -o $@)
$(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.c $(HEADERS)
$(BUILDDIR)/loader_exe.dbg.obj : $(SRCDIR)/loader_exe.c $(HEADERS)
@$(call PRINT_CC, $(CC) $(DEBUGFLAGS) $(LOADER_CFLAGS) -c $< -o $@)
$(BUILDDIR)/loader_trampolines.o : $(SRCDIR)/trampolines/trampolines_$(ARCH).S
@$(call PRINT_CC, $(CC) $(DEBUGFLAGS) $(LOADER_CFLAGS) $< -c -o $@)

DIRS = $(build_bindir) $(build_libdir)
$(DIRS):
@mkdir -p $@

ifeq ($(OS),WINNT)
ifneq ($(USEMSVC), 1)
Expand All @@ -54,14 +68,11 @@ $(BUILDDIR)/julia_res.o: $(JULIAHOME)/contrib/windows/julia.rc $(JULIAHOME)/VERS
'/^(\d+)\.?(\d*)\.?(\d*)/ && \
print int $$1,",",int $$2,",0,",int $$3'` && \
$(CROSS_COMPILE)windres $< -O coff -o $@ -DJLVER=$$JLVERi -DJLVER_STR=\\\"$$JLVER\\\"
OBJS += julia_res.o
DOBJS += julia_res.o
EXE_OBJS += $(BUILDDIR)/julia_res.o
EXE_DOBJS += $(BUILDDIR)/julia_res.o
endif
endif

julia-release: $(build_bindir)/julia$(EXE) $(build_shlibdir)/libjulialoader.$(JL_MAJOR_MINOR_SHLIB_EXT)
julia-debug: $(build_bindir)/julia-debug$(EXE) $(build_shlibdir)/libjulialoader-debug.$(JL_MAJOR_MINOR_SHLIB_EXT)

# Embed an Info.plist in the julia executable
# Create an intermediate target Info.plist for Darwin code signing.
ifeq ($(DARWIN_FRAMEWORK),1)
Expand All @@ -78,30 +89,58 @@ $(build_bindir)/julia$(EXE): $(BUILDDIR)/Info.plist
$(build_bindir)/julia-debug$(EXE): $(BUILDDIR)/Info.plist
endif

$(build_shlibdir)/libjulialoader.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_OBJS)
@$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) -shared $(SHIPFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH_LIB))
ifneq ($(OS), WINNT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulialoader.$(JL_MAJOR_SHLIB_EXT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulialoader.$(SHLIB_EXT)
endif
julia-release: $(build_bindir)/julia$(EXE)
julia-debug: $(build_bindir)/julia-debug$(EXE)
libjulia-release: $(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT)
libjulia-debug: $(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT)

ifeq ($(OS),WINNT)
# On Windows we need to strip out exported functions from the generated import library.
# On i686, there's an extra underscore at the beginning
ifeq ($(ARCH),i686)
ABI_UNDERSCORE := _\#\#
else
ABI_UNDERSCORE :=
endif
EXPORTED_FUNCS := $(shell echo -e "#include \"jl_exported_funcs.inc\"\n#define XX(x) $(ABI_UNDERSCORE)x\nJL_EXPORTED_FUNCS(XX)" | $(CPP) -I$(JULIAHOME)/src - | tail -n 1)
STRIP_EXPORTED_FUNCS := $(patsubst %,--strip-symbol=%,$(EXPORTED_FUNCS))

# Note that if the objcopy command starts getting too long, we can use `@file` to read
# command-line options from `file` instead.
define strip_implib
$(OBJCOPY) $(1).a $(STRIP_EXPORTED_FUNCS) $(1).a.stripped
mv $(1).a.stripped $(1).a
endef
endif

$(build_shlibdir)/libjulialoader-debug.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_DOBJS)
@$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) -shared $(DEBUGFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH_LIB))
$(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_OBJS) | $(build_shlibdir) $(build_libdir)
@$(call PRINT_LINK, $(CC) $(call IMPLIB_FLAGS,$@) $(LOADER_CFLAGS) -DLIBRARY_EXPORTS -shared $(SHIPFLAGS) $(LIB_OBJS) -o $@ $(LOADER_LDFLAGS) $(RPATH_LIB)) $(call SONAME_FLAGS,$(notdir $@))
$(INSTALL_NAME_CMD)libjulia.$(SHLIB_EXT) $@
ifneq ($(OS), WINNT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulialoader-debug.$(JL_MAJOR_SHLIB_EXT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulialoader-debug.$(SHLIB_EXT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulia.$(JL_MAJOR_SHLIB_EXT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulia.$(SHLIB_EXT)
else
$(call strip_implib,$(build_libdir)/libjulia.$(SHLIB_EXT))
endif

$(build_bindir)/julia$(EXE): $(OBJS)
@$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) $(SHIPFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH))
$(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_DOBJS) | $(build_shlibdir) $(build_libdir)
@$(call PRINT_LINK, $(CC) $(call IMPLIB_FLAGS,$@) $(LOADER_CFLAGS) -DLIBRARY_EXPORTS -shared $(DEBUGFLAGS) $(LIB_DOBJS) -o $@ $(LOADER_LDFLAGS) $(RPATH_LIB)) $(call SONAME_FLAGS,$(notdir $@))
$(INSTALL_NAME_CMD)libjulia-debug.$(SHLIB_EXT) $@
ifneq ($(OS), WINNT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulia-debug.$(JL_MAJOR_SHLIB_EXT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulia-debug.$(SHLIB_EXT)
else
$(call strip_implib,$(build_libdir)/libjulia-debug.$(SHLIB_EXT))
endif

$(build_bindir)/julia-debug$(EXE): $(DOBJS)
@$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) $(DEBUGFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH))
$(build_bindir)/julia$(EXE): $(EXE_OBJS) $(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT) | $(build_bindir)
@$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) $(SHIPFLAGS) $(EXE_OBJS) -o $@ $(LOADER_LDFLAGS) $(RPATH) -ljulia)

$(build_bindir)/julia-debug$(EXE): $(EXE_DOBJS) $(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT) | $(build_bindir)
@$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) $(DEBUGFLAGS) $(EXE_DOBJS) -o $@ $(LOADER_LDFLAGS) $(RPATH) -ljulia-debug)

clean: | $(CLEAN_TARGETS)
rm -f *.o *.dbg.obj
rm -f $(BUILDDIR)/*.o $(BUILDDIR)/*.dbg.obj
rm -f $(build_bindir)/julia*

.PHONY: clean release debug julia-release julia-debug
31 changes: 31 additions & 0 deletions cli/jl_exports.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license
// Bring in the curated lists of exported data and function symbols, then
// perform C preprocessor magic upon them to generate lists of declarations and
// functions to re-export our function symbols from libjulia-internal to libjulia.
#include "../src/jl_exported_data.inc"
#include "../src/jl_exported_funcs.inc"

// Define data symbols as `const void * $(name);`
#define XX(name) JL_DLLEXPORT const void * name;
JL_EXPORTED_DATA(XX)
#undef XX

// Define holder locations for function addresses as `const void * $(name)_addr`
#define XX(name) JL_HIDDEN const void * name##_addr;
JL_EXPORTED_FUNCS(XX)
#undef XX

// Generate lists of function names and addresses
#define XX(name) #name,
static const char *const jl_exported_func_names[] = {
JL_EXPORTED_FUNCS(XX)
NULL
};
#undef XX

#define XX(name) &name##_addr,
static const void ** jl_exported_func_addrs[] = {
JL_EXPORTED_FUNCS(XX)
NULL
};
#undef XX
Loading

0 comments on commit 2e3364e

Please sign in to comment.