Skip to content

Commit

Permalink
Merge branch 'jn/two_sys'
Browse files Browse the repository at this point in the history
and update contrib/build_sysimg.jl to reflect this change
  • Loading branch information
vtjnash committed Jul 16, 2015
2 parents ce2d89e + d9b71be commit d45e430
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 67 deletions.
6 changes: 2 additions & 4 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,6 @@ else
SHLIB_EXT = so
endif


# if not absolute, then relative to the directory of the julia executable
JCPPFLAGS += "-DJL_SYSTEM_IMAGE_PATH=\"$(build_private_libdir_rel)/sys.$(SHLIB_EXT)\""

# On Windows, we want shared library files to end up in $(build_bindir), instead of $(build_libdir)
ifeq ($(OS),WINNT)
build_shlibdir = $(build_bindir)
Expand Down Expand Up @@ -913,9 +909,11 @@ endif
pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(2)))))

JULIA_BUILD_MODE = release
JULIA_LIBSUFFIX=
ifeq (,$(findstring release,$(MAKECMDGOALS)))
ifneq (,$(findstring debug,$(MAKECMDGOALS)))
JULIA_BUILD_MODE = debug
JULIA_LIBSUFFIX=-debug
endif
endif

Expand Down
75 changes: 38 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ julia-src-release julia-src-debug : julia-src-% : julia-deps
julia-ui-release julia-ui-debug : julia-ui-% : julia-src-%
@$(MAKE) $(QUIET_MAKE) -C ui julia-$*

julia-sysimg : julia-base julia-ui-$(JULIA_BUILD_MODE)
@$(MAKE) $(QUIET_MAKE) $(build_private_libdir)/sys.$(SHLIB_EXT) JULIA_BUILD_MODE=$(JULIA_BUILD_MODE)
julia-inference : julia-base julia-ui-$(JULIA_BUILD_MODE)
@$(MAKE) $(QUIET_MAKE) $(build_private_libdir)/inference.ji

julia-debug julia-release : julia-% : julia-ui-% julia-symlink julia-sysimg julia-libccalltest
julia-sysimg-release : julia-inference julia-ui-release
@$(MAKE) $(QUIET_MAKE) $(build_private_libdir)/sys.$(SHLIB_EXT)

julia-sysimg-debug : julia-inference julia-ui-debug
@$(MAKE) $(QUIET_MAKE) $(build_private_libdir)/sys-debug.$(SHLIB_EXT)

julia-debug julia-release : julia-% : julia-ui-% julia-sysimg-% julia-symlink julia-libccalltest

debug release : % : julia-%

Expand Down Expand Up @@ -132,19 +138,12 @@ ifeq ($(OS), WINNT)
$(build_sysconfdir)/julia/juliarc.jl: contrib/windows/juliarc.jl
endif

.SECONDARY: $(build_private_libdir)/inference0.o
.SECONDARY: $(build_private_libdir)/inference.o
.SECONDARY: $(build_private_libdir)/sys.o

$(build_private_libdir)/%.$(SHLIB_EXT): $(build_private_libdir)/%.o
ifneq ($(USEMSVC), 1)
@$(call PRINT_LINK, $(CXX) $(LDFLAGS) -shared -fPIC -L$(build_private_libdir) -L$(build_libdir) -L$(build_shlibdir) -o $@ $< \
$$([ $(OS) = Darwin ] && echo '' -Wl,-undefined,dynamic_lookup || echo '' -Wl,--unresolved-symbols,ignore-all ) \
$$([ $(OS) = WINNT ] && echo '' -ljulia -lssp))
$(DSYMUTIL) $@
else
@true
endif
@$(call PRINT_LINK, $(CXX) $(LDFLAGS) -shared $(fPIC) -L$(build_private_libdir) -L$(build_libdir) -L$(build_shlibdir) -o $@ $< \
$(if $(findstring -debug.$(SHLIB_EXT),$(notdir $@)),-ljulia-debug,-ljulia) \
$$([ $(OS) = WINNT ] && echo '' -lssp))
@$(INSTALL_NAME_CMD)$(notdir $@) $@
@$(DSYMUTIL) $@

CORE_SRCS := base/boot.jl base/coreimg.jl \
base/abstractarray.jl \
Expand All @@ -170,28 +169,32 @@ CORE_SRCS := base/boot.jl base/coreimg.jl \
base/reduce.jl \
base/reflection.jl \
base/tuple.jl

BASE_SRCS := $(wildcard base/*.jl base/*/*.jl base/*/*/*.jl)

$(build_private_libdir)/inference0.o: $(CORE_SRCS) | $(build_private_libdir)
$(build_private_libdir)/inference0.ji: $(CORE_SRCS) | $(build_private_libdir)
@$(call PRINT_JULIA, cd base && \
$(call spawn,$(JULIA_EXECUTABLE)) -C $(JULIA_CPU_TARGET) --output-o $(call cygpath_w,$(build_private_libdir)/inference0.o) -f \
$(call spawn,$(JULIA_EXECUTABLE)) -C $(JULIA_CPU_TARGET) --output-ji $(call cygpath_w,$@) -f \
coreimg.jl)

$(build_private_libdir)/inference.o: $(build_private_libdir)/inference0.$(SHLIB_EXT)
$(build_private_libdir)/inference.ji: $(build_private_libdir)/inference0.ji
@$(call PRINT_JULIA, cd base && \
$(call spawn,$(JULIA_EXECUTABLE)) -C $(JULIA_CPU_TARGET) --output-o $(call cygpath_w,$(build_private_libdir)/inference.o) -f \
-J $(call cygpath_w,$(build_private_libdir)/inference0.$(SHLIB_EXT)) coreimg.jl)
$(call spawn,$(JULIA_EXECUTABLE)) -C $(JULIA_CPU_TARGET) --output-ji $(call cygpath_w,$@) -f \
-J $(call cygpath_w,$<) coreimg.jl)

COMMA:=,
$(build_private_libdir)/sys.o: VERSION $(BASE_SRCS) $(build_docdir)/helpdb.jl $(build_private_libdir)/inference.$(SHLIB_EXT)
@$(call PRINT_JULIA, cd base && \
$(call spawn,$(JULIA_EXECUTABLE)) -C $(JULIA_CPU_TARGET) --output-o $(call cygpath_w,$(build_private_libdir)/sys.o) $(JULIA_SYSIMG_BUILD_FLAGS) -f \
-J $(call cygpath_w,$(build_private_libdir)/inference.$(SHLIB_EXT)) sysimg.jl \
|| { echo '*** This error is usually fixed by running `make clean`. If the error persists$(COMMA) try `make cleanall`. ***' && false; } )
define sysimg_builder
$$(build_private_libdir)/sys$1.o: $$(build_private_libdir)/inference.ji VERSION $$(BASE_SRCS) $$(build_docdir)/helpdb.jl
@$$(call PRINT_JULIA, cd base && \
$$(call spawn,$2) -C $$(JULIA_CPU_TARGET) --output-o $$(call cygpath_w,$$@) $$(JULIA_SYSIMG_BUILD_FLAGS) -f \
-J $$(call cygpath_w,$$<) sysimg.jl \
|| { echo '*** This error is usually fixed by running `make clean`. If the error persists$$(COMMA) try `make cleanall`. ***' && false; } )
.SECONDARY: $(build_private_libdir)/sys$1.o
endef
$(eval $(call sysimg_builder,,$(JULIA_EXECUTABLE_release)))
$(eval $(call sysimg_builder,-debug,$(JULIA_EXECUTABLE_debug)))

$(build_bindir)/stringreplace: contrib/stringreplace.c | $(build_bindir)
@$(call PRINT_CC, $(CC) -o $(build_bindir)/stringreplace contrib/stringreplace.c)
@$(call PRINT_CC, $(HOSTCC) -o $(build_bindir)/stringreplace contrib/stringreplace.c)


# public libraries, that are installed in $(prefix)/lib
Expand Down Expand Up @@ -320,6 +323,7 @@ endif
# Copy system image
-$(INSTALL_F) $(build_private_libdir)/sys.ji $(DESTDIR)$(private_libdir)
$(INSTALL_M) $(build_private_libdir)/sys.$(SHLIB_EXT) $(DESTDIR)$(private_libdir)
$(INSTALL_M) $(build_private_libdir)/sys-debug.$(SHLIB_EXT) $(DESTDIR)$(private_libdir)
# Copy in system image build script
$(INSTALL_M) contrib/build_sysimg.jl $(DESTDIR)$(datarootdir)/julia/
# Copy in standalone executable build script
Expand Down Expand Up @@ -364,9 +368,11 @@ else ifeq ($(OS), Linux)
endif

# Overwrite JL_SYSTEM_IMAGE_PATH in julia library
for julia in $(DESTDIR)$(private_libdir)/libjulia*.$(SHLIB_EXT) ; do \
$(call spawn,$(build_bindir)/stringreplace $$(strings -t x - $$julia | grep "sys.$(SHLIB_EXT)$$" | awk '{print $$1;}' ) "$(private_libdir_rel)/sys.$(SHLIB_EXT)" 256 $(call cygpath_w,$$julia)); \
done
define stringreplace
$(build_bindir)/stringreplace $$(strings -t x - $1 | grep '$2' | awk '{print $$1;}') '$3' 255 "$(call cygpath_w,$1)"
endef
$(call stringreplace,$(DESTDIR)$(private_libdir)/libjulia.$(SHLIB_EXT),sys.$(SHLIB_EXT)$$,$(private_libdir_rel)/sys.$(SHLIB_EXT))
$(call stringreplace,$(DESTDIR)$(private_libdir)/libjulia-debug.$(SHLIB_EXT),sys-debug.$(SHLIB_EXT)$$,$(private_libdir_rel)/sys-debug.$(SHLIB_EXT))
endif

mkdir -p $(DESTDIR)$(sysconfdir)
Expand Down Expand Up @@ -406,11 +412,6 @@ ifeq ($(OS), Darwin)
-cat ./contrib/mac/juliarc.jl >> $(DESTDIR)$(prefix)/etc/julia/juliarc.jl
endif

# purge sys.{dll,so,dylib} as that file is not relocatable across processor architectures
ifeq ($(JULIA_CPU_TARGET), native)
-rm -f $(DESTDIR)$(private_libdir)/sys.$(SHLIB_EXT)
endif

ifeq ($(OS), WINNT)
[ ! -d dist-extras ] || ( cd dist-extras && \
cp 7z.exe 7z.dll libexpat-1.dll zlib1.dll libgfortran-3.dll libquadmath-0.dll libstdc++-6.dll libgcc_s_s*-1.dll libssp-0.dll $(bindir) && \
Expand Down Expand Up @@ -501,7 +502,7 @@ distcleanall: cleanall
.PHONY: default debug release check-whitespace release-candidate \
julia-debug julia-release julia-deps \
julia-ui-release julia-ui-debug julia-src-release julia-src-debug \
julia-symlink julia-base julia-sysimg \
julia-symlink julia-base julia-inference julia-sysimg-release julia-sysimg-debug \
test testall testall1 test clean distcleanall cleanall \
run-julia run-julia-debug run-julia-release run \
install binary-dist light-source-dist.tmp light-source-dist \
Expand All @@ -511,7 +512,7 @@ test: check-whitespace $(JULIA_BUILD_MODE)
@$(MAKE) $(QUIET_MAKE) -C test default JULIA_BUILD_MODE=$(JULIA_BUILD_MODE)

testall: check-whitespace $(JULIA_BUILD_MODE)
cp $(build_prefix)/lib/julia/sys.$(SHLIB_EXT) local.$(SHLIB_EXT) && $(JULIA_EXECUTABLE) -J local.$(SHLIB_EXT) -e 'true' && rm local.$(SHLIB_EXT)
cp $(build_prefix)/lib/julia/sys$(JULIA_LIBSUFFIX).$(SHLIB_EXT) local.$(SHLIB_EXT) && $(JULIA_EXECUTABLE) -J local.$(SHLIB_EXT) -e 'true' && rm local.$(SHLIB_EXT)
@$(MAKE) $(QUIET_MAKE) -C test all JULIA_BUILD_MODE=$(JULIA_BUILD_MODE)

testall1: check-whitespace $(JULIA_BUILD_MODE)
Expand Down
9 changes: 2 additions & 7 deletions contrib/build_sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,13 @@ function link_sysimg(sysimg_path=default_sysimg_path, ld=find_system_linker())
FLAGS = ["-L$julia_libdir"]
if OS_NAME == :Darwin
push!(FLAGS, "-dylib")
push!(FLAGS, "-undefined")
push!(FLAGS, "dynamic_lookup")
push!(FLAGS, "-macosx_version_min")
push!(FLAGS, "10.7")
else
push!(FLAGS, "-shared")
# on windows we link using gcc for now
wl = @windows? "-Wl," : ""
push!(FLAGS, wl * "--unresolved-symbols")
push!(FLAGS, wl * "ignore-all")
end
@windows_only append!(FLAGS, ["-ljulia", "-lssp-0"])
push!(FLAGS, "-ljulia")
@windows_only push!(FLAGS, "-lssp")

info("Linking sys.$(Libdl.dlext)")
run(`$ld $FLAGS -o $sysimg_path.$(Libdl.dlext) $sysimg_path.o`)
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ DOBJS = $(SRCS:%=$(BUILDDIR)/%.dbg.obj)
DEBUGFLAGS += $(FLAGS)
SHIPFLAGS += $(FLAGS)

# if not absolute, then relative to the directory of the julia executable
SHIPFLAGS += "-DJL_SYSTEM_IMAGE_PATH=\"$(build_private_libdir_rel)/sys.$(SHLIB_EXT)\""
DEBUGFLAGS += "-DJL_SYSTEM_IMAGE_PATH=\"$(build_private_libdir_rel)/sys-debug.$(SHLIB_EXT)\""

ifeq ($(JULIAGC),MARKSWEEP)
SRCS += gc
endif
Expand Down
1 change: 0 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ static Function *jlgetnthfieldchecked_func;
static Function *resetstkoflw_func;
#endif
static Function *diff_gc_total_bytes_func;
static Function *show_execution_point_func;

static std::vector<Type *> two_pvalue_llvmt;
static std::vector<Type *> three_pvalue_llvmt;
Expand Down
13 changes: 1 addition & 12 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,6 @@ static int jl_load_sysimg_so()
return -1;

int imaging_mode = jl_generating_output();
#ifdef _OS_WINDOWS_
//XXX: the windows linker forces our system image to be
// linked against only one dll, I picked libjulia-release
if (jl_is_debugbuild()) imaging_mode = 1;
#endif
// in --build mode only use sysimg data, not precompiled native code
if (!imaging_mode && jl_options.use_precompiled==JL_OPTIONS_USE_PRECOMPILED_YES) {
sysimg_gvars = (jl_value_t***)jl_dlsym(jl_sysimg_handle, "jl_sysimg_gvars");
Expand Down Expand Up @@ -1542,13 +1537,7 @@ DLLEXPORT void jl_preload_sysimg_so(const char *fname)
}

// Get handle to sys.so
#ifdef _OS_WINDOWS_
if (!jl_is_debugbuild()) {
#endif
jl_sysimg_handle = (uv_lib_t*)jl_load_dynamic_library_e(fname_shlib, JL_RTLD_DEFAULT | JL_RTLD_GLOBAL);
#ifdef _OS_WINDOWS_
}
#endif
jl_sysimg_handle = (uv_lib_t*)jl_load_dynamic_library_e(fname_shlib, JL_RTLD_DEFAULT | JL_RTLD_GLOBAL);

// set cpu target if unspecified by user and available from sysimg
// otherwise default to native.
Expand Down
4 changes: 2 additions & 2 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ DLLEXPORT void jlbacktrace();
DLLEXPORT void gdbbacktrace();
DLLEXPORT void gdblookup(ptrint_t ip);

static const char system_image_path[256] = JL_SYSTEM_IMAGE_PATH;
static const char system_image_path[256] = "\0" JL_SYSTEM_IMAGE_PATH;

jl_options_t jl_options = { 0, // quiet
NULL, // julia_home
Expand All @@ -92,7 +92,7 @@ jl_options_t jl_options = { 0, // quiet
NULL, // print
NULL, // postboot
NULL, // load
system_image_path, // image_file
&system_image_path[1], // image_file
NULL, // cpu_taget ("native", "core2", etc...)
0, // nprocs
NULL, // machinefile
Expand Down
4 changes: 0 additions & 4 deletions ui/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
#define WHOLE_ARCHIVE
#include "../src/julia.h"

#ifndef JL_SYSTEM_IMAGE_PATH
#error "JL_SYSTEM_IMAGE_PATH not defined!"
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down

0 comments on commit d45e430

Please sign in to comment.