Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup julia_init options #9266

Merged
merged 7 commits into from
Dec 14, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ else ifeq ($(OS), Linux)
done
endif

# Overwrite JL_SYSTEM_IMAGE_PATH in julia binaries
for julia in $(DESTDIR)$(bindir)/julia* ; do \
# 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.ji$$" | awk '{print $$1;}' ) "$(private_libdir_rel)/sys.ji" 256 $(call cygpath_w,$$julia)); \
done
endif
Expand Down
3 changes: 0 additions & 3 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,10 @@ import .Terminals
import .REPL

function _start()
early_init()

try
init_parallel()
init_bind_addr(ARGS)
any(a->(a=="--worker"), ARGS) || init_head_sched()
init_load_path()
(quiet,repl,startup,color_set,no_history_file) = process_options(copy(ARGS))

local term
Expand Down
2 changes: 2 additions & 0 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ function __init__()
reinit_stdio()
Multimedia.reinit_displays() # since Multimedia.displays uses STDOUT as fallback
fdwatcher_init()
early_init()
init_load_path()
end

include("precompile.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ static void coverageVisitLine(std::string filename, int line)

void write_log_data(logdata_t logData, const char *extension)
{
std::string base = std::string(julia_home);
std::string base = std::string(jl_compileropts.julia_home);
base = base + "/../share/julia/base/";
logdata_t::iterator it = logData.begin();
for (; it != logData.end(); it++) {
Expand Down
2 changes: 1 addition & 1 deletion src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static uv_lib_t *jl_load_dynamic_library_(char *modname, unsigned flags, int thr
ext = extensions[i];
path[0] = '\0';
handle->handle = NULL;
if (dl_path[len-1] == PATHSEP)
if (dl_path[len-1] == PATHSEPSTRING[0])
snprintf(path, PATHBUF, "%s%s%s", dl_path, modname, ext);
else
snprintf(path, PATHBUF, "%s" PATHSEPSTRING "%s%s", dl_path, modname, ext);
Expand Down
18 changes: 8 additions & 10 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ void jl_deserialize_lambdas_from_mod(ios_t *s)

extern jl_array_t *jl_module_init_order;

DLLEXPORT void jl_save_system_image(char *fname)
DLLEXPORT void jl_save_system_image(const char *fname)
{
jl_gc_collect();
jl_gc_collect();
Expand Down Expand Up @@ -1339,8 +1339,8 @@ DLLEXPORT void jl_save_system_image(char *fname)
for(i=0; i < jl_array_len(jl_module_init_order); i++) {
// NULL out any modules that weren't saved
jl_value_t *mod = jl_cellref(jl_module_init_order, i);
if (ptrhash_get(&backref_table, mod) == HT_NOTFOUND)
jl_cellset(jl_module_init_order, i, NULL);
(void)mod;
assert(ptrhash_get(&backref_table, mod) != HT_NOTFOUND);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, shouldn't this whole loop be removed? But I don't understand what changed here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed from putting NULL's in the jl_module_init_order table (which don't appear to be checked for later, so they would cause a segfault), to asserting that everything in the module init order list has been serialized (which I believe should be true by construction)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then the comment above should definitely be changed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. looks like the comment didn't transfer when I backported this from #8745

annoyingly, this assert can get correctly triggered by Gtk.jl, since the module initializers are getting called in the incorrect order / at the incorrect time, given the following code:

file A.jl:

module A
  __init__() = println("init A")
end

file B.jl:

module B
  module C
    __init__() = println("init B")
  end
  require("A") # this causes B.C.__init__() to get invoked before A.__init__()
end # B.C.__init__() should have been called here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the init order problem lead to one of the modules not getting serialized?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, i copied this code to jl_save_new_module, and that's actually where it failed, not this one. when trying to serialize A, it discovers B.C.__init__ is in the list to be called also

it's not directly related, it just made me realize that the __init__ call order can end up getting out of sequence

}
}
jl_serialize_value(&f, jl_module_init_order);
Expand All @@ -1360,11 +1360,10 @@ extern void jl_get_system_hooks(void);
extern void jl_get_uv_hooks();

DLLEXPORT
void jl_restore_system_image(char *fname)
void jl_restore_system_image(const char *fname)
{
ios_t f;
char *fpath = fname;
if (ios_file(&f, fpath, 1, 0, 0, 0) == NULL) {
if (ios_file(&f, fname, 1, 0, 0, 0) == NULL) {
JL_PRINTF(JL_STDERR, "System image file \"%s\" not found\n", fname);
exit(1);
}
Expand Down Expand Up @@ -1432,14 +1431,13 @@ void jl_restore_system_image(char *fname)
//ios_printf(ios_stderr, "backref_list.len = %d\n", backref_list.len);
arraylist_free(&backref_list);
ios_close(&f);
if (fpath != fname) free(fpath);

#ifdef JL_GC_MARKSWEEP
if (en) jl_gc_enable();
#endif
// restore the value of our "magic" JULIA_HOME variable/constant
jl_get_binding_wr(jl_core_module, jl_symbol("JULIA_HOME"))->value =
jl_cstr_to_string(julia_home);
jl_cstr_to_string(jl_compileropts.julia_home);
mode = last_mode;
jl_update_all_fptrs();
}
Expand Down Expand Up @@ -1543,7 +1541,7 @@ jl_value_t *jl_uncompress_ast(jl_lambda_info_t *li, jl_value_t *data)
}

DLLEXPORT
int jl_save_new_module(char *fname, jl_module_t *mod)
int jl_save_new_module(const char *fname, jl_module_t *mod)
{
ios_t f;
if (ios_file(&f, fname, 1, 1, 1, 1) == NULL) {
Expand Down Expand Up @@ -1583,7 +1581,7 @@ jl_function_t *jl_method_cache_insert(jl_methtable_t *mt, jl_tuple_t *type,
jl_function_t *method);

DLLEXPORT
jl_module_t *jl_restore_new_module(char *fname)
jl_module_t *jl_restore_new_module(const char *fname)
{
ios_t f;
if (ios_file(&f, fname, 1, 0, 0, 0) == NULL) {
Expand Down
Loading