Skip to content

Commit

Permalink
Fixes for cpuid specific binaries patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Jan 4, 2017
1 parent 1c605d2 commit 39e62e7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ julia-inference : julia-base julia-ui-$(JULIA_BUILD_MODE) $(build_prefix)/.examp
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) $(build_private_libdir)/inference.ji JULIA_BUILD_MODE=$(JULIA_BUILD_MODE)

ifneq ($(CPUID_SPECIFIC_BINARIES), 0)
CPUID_TAG = _$(call spawn,$(JULIA_EXECUTABLE) --cpuid)
CPUID_TAG = _$(call exec,$(JULIA_EXECUTABLE) --cpuid)
else
CPUID_TAG =
endif
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ 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\""
DEBUGFLAGS += "-DJL_SYSTEM_IMAGE_PATH=\"$(build_private_libdir_rel)/sys-debug\""
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)\""

ifneq ($(CPUID_SPECIFIC_BINARIES), 0)
override CPPFLAGS += "-DCPUID_SPECIFIC_BINARIES=1"
Expand Down
14 changes: 8 additions & 6 deletions src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ char *shlib_ext = ".dylib";
char *shlib_ext = ".so";
#endif

static char default_sysimg_path[512];
static char system_image_path[256] = "\0" JL_SYSTEM_IMAGE_PATH;
static const char *get_default_sysimg_path()
{
#ifndef CPUID_SPECIFIC_BINARIES
snprintf(default_sysimg_path, 512, "%s%s", JL_SYSTEM_IMAGE_PATH, shlib_ext);
#else
snprintf(default_sysimg_path, 512, "%s_%llx%s", JL_SYSTEM_IMAGE_PATH, jl_cpuid_tag(), shlib_ext);
#ifdef CPUID_SPECIFIC_BINARIES
char *path = &system_image_path[1];
size_t existing_length = strlen(path) - strlen(shlib_ext);
path += existing_length;
snprintf(path, sizeof(system_image_path) - existing_length,
"_%" PRIx64 "%s", jl_cpuid_tag(), shlib_ext);
#endif
return default_sysimg_path;
return &system_image_path[1];
}


Expand Down
6 changes: 6 additions & 0 deletions src/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,12 @@ JL_DLLEXPORT uint64_t jl_cpuid_tag(void)
}
#elif defined(CPUID_SPECIFIC_BINARIES)
#error "CPUID not available on this CPU. Turn off CPUID_SPECIFIC_BINARIES"
#else
// For architectures that don't have CPUID
JL_DLLEXPORT uint64_t jl_cpuid_tag(void)
{
return 0;
}
#endif

JL_DLLEXPORT int jl_uses_cpuid_tag()
Expand Down
5 changes: 3 additions & 2 deletions ui/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <errno.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

#include "uv.h"
#define WHOLE_ARCHIVE
Expand Down Expand Up @@ -177,7 +178,7 @@ static NOINLINE int true_main(int argc, char *argv[])
return 0;
}

extern uint64_t jl_cpuid_tag();
extern JL_DLLEXPORT uint64_t jl_cpuid_tag();

#ifndef _OS_WINDOWS_
int main(int argc, char *argv[])
Expand Down Expand Up @@ -245,7 +246,7 @@ int wmain(int argc, wchar_t *argv[], wchar_t *envp[])
#endif
if (argc >= 2 && strcmp((char *)argv[1], "--cpuid") == 0) {
/* Used by the build system to name CPUID-specific binaries */
printf("%llx", jl_cpuid_tag());
printf("%" PRIx64, jl_cpuid_tag());
return 0;
}
libsupport_init();
Expand Down

0 comments on commit 39e62e7

Please sign in to comment.