-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This combines the .o emission code from #5787 with some error checking code for cpuid mismatch. When releasing a binary, set JULIA_CPU_TARGET to "core2" (we discussed that this is a reasonable minimum) in your Make.user and everything should work just fine.
- Loading branch information
Showing
9 changed files
with
146 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,9 +95,11 @@ static void write_as_tag(ios_t *s, uint8_t tag) | |
static void jl_serialize_value_(ios_t *s, jl_value_t *v); | ||
static jl_value_t *jl_deserialize_value(ios_t *s); | ||
static jl_value_t *jl_deserialize_value_internal(ios_t *s); | ||
static jl_value_t ***sysimg_gvars = NULL; | ||
jl_value_t ***sysimg_gvars = NULL; | ||
|
||
extern int globalUnique; | ||
extern void cpuid(int32_t CPUInfo[4], int32_t InfoType); | ||
extern const char *jl_cpu_string; | ||
|
||
static void jl_load_sysimg_so(char *fname) | ||
{ | ||
|
@@ -108,6 +110,24 @@ static void jl_load_sysimg_so(char *fname) | |
if (sysimg_handle != 0) { | ||
sysimg_gvars = (jl_value_t***)jl_dlsym(sysimg_handle, "jl_sysimg_gvars"); | ||
globalUnique = *(size_t*)jl_dlsym(sysimg_handle, "jl_globalUnique"); | ||
const char *cpu_target = (const char*)jl_dlsym(sysimg_handle, "jl_sysimg_cpu_target"); | ||
if (strcmp(cpu_target,jl_cpu_string) != 0) | ||
jl_error("Julia and the system image were compiled for different architectures."); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Keno
Author
Member
|
||
uint32_t info[4]; | ||
cpuid((int32_t*)info, 1); | ||
if (strcmp(cpu_target,"native") == 0) | ||
{ | ||
uint64_t saved_cpuid = *(uint64_t*)jl_dlsym(sysimg_handle, "jl_sysimg_cpu_cpuid"); | ||
if (saved_cpuid != (((uint64_t)info[2])|(((uint64_t)info[3])<<32))) | ||
jl_error("Target architecture mismatch. Please regenerate sys.{so,dll,dylib}."); | ||
} else if(strcmp(cpu_target,"core2") == 0) { | ||
int HasSSSE3 = (info[3] & 1<<9); | ||
if (!HasSSSE3) | ||
jl_error("The current host does not support SSSE3, but the system image was compiled for Core2.\n" | ||
"Please delete or regenerate sys.{so,dll,dylib}."); | ||
} else { | ||
jl_error("System image has unknown target cpu architecture."); | ||
} | ||
} | ||
else { | ||
sysimg_gvars = 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What is the worst that can happen here? In #7124, I'm experimenting with making
jl_cpu_string
a runtime option so that we can do things like ship ani386
sys.so, and then on startup Julia can check CPU capabilities and notify users that they can rebuild their system image for faster startup.I started getting warnings from here, but since I'm going from restricted image -> unrestricted executable, I'm pretty sure nothing bad is going to happen. The bad stuff happens when you have a restricted executable running an unrestricted image, am I right? I think it might be worthwhile to have a more complex test here where we can compare individual CPU features and still load a system image that has a subset of the currently available CPU features, but not a superset. Does that sound reasonable?