Skip to content

With 1.9.0-beta4, sysimages aren't built for the specified JULIA_CPU_TARGET #790

@ven-k

Description

@ven-k

Src OS: Linux (WSL and native), CPU: znver3
Target OS: Linux, CPU: znver2
Julia: v1.9.0-beta4
PackageCompiler: 2.1.5 (throws error) and 2.1.2 (relocates, but it doesn't mention pkgimages flag at all)


While building the sysimage with 1.9.0-beta4, even with cpu_target = "generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)", the sysimage builds only for the "native" target.
So, when this sysimage is relocated to another machine, it fails to start with ERROR: Unable to find compatible target in system image. error

When I printed out the cmd returned by addenv, it indicated setting of JULIA_CPU_TARGET var.
This however, isn't an issue when --pkgimages flag isn't mentioned and --cpu-target is passed explicitly, i.e. what v2.1.2 does.

With

sysimage-metadata.patch (by @staticfloat)
diff --git a/src/processor.cpp b/src/processor.cpp
index 13b40ec4f7..accbff5469 100644
--- a/src/processor.cpp
+++ b/src/processor.cpp
@@ -770,12 +770,16 @@ static inline SysimgMatch match_sysimg_targets(S &&sysimg, T &&target, F &&max_v
     SysimgMatch match;
     bool match_name = false;
     int feature_size = 0;
+    jl_printf(JL_STDERR, "target.name: %s\n", target.name.c_str());
+    jl_printf(JL_STDERR, "sysimg.size(): %d\n", sysimg.size());
     for (uint32_t i = 0; i < sysimg.size(); i++) {
         auto &imgt = sysimg[i];
+        jl_printf(JL_STDERR, "[%d]: %s\n", i, imgt.name.c_str());
         if (!(imgt.en.features & target.dis.features).empty()) {
             // Check sysimg enabled features against runtime disabled features
             // This is valid (and all what we can do)
             // even if one or both of the targets are unknown.
+            jl_printf(JL_STDERR, "continue 1\n");
             continue;
         }
         if (imgt.name == target.name) {
@@ -786,6 +790,7 @@ static inline SysimgMatch match_sysimg_targets(S &&sysimg, T &&target, F &&max_v
             }
         }
         else if (match_name) {
+            jl_printf(JL_STDERR, "continue 2 (match_name: %d)\n", match_name);
             continue;
         }
         int new_vsz = max_vector_size(imgt.en.features);

to print out the metadata and

cmdline.patch
diff --git a/src/processor.cpp b/src/processor.cpp
index 13b40ec4f7..9b6c850e65 100644
--- a/src/processor.cpp
+++ b/src/processor.cpp
@@ -734,6 +734,12 @@ static inline jl_image_fptrs_t parse_sysimg(void *hdl, F &&callback)
 template<typename T>
 static inline void check_cmdline(T &&cmdline, bool imaging)
 {
+    jl_printf(JL_STDERR, "Imaging:, %d\n", imaging);
+    jl_printf(JL_STDERR, "cmdline size, %d\n", cmdline.size());
+    for(uint32_t i = 0; i < cmdline.size(); i++) {
+        jl_printf(JL_STDERR,"CMDLINE: [%d]: Flags: %d, Name: %s\n", i, cmdline[i].en.flags, cmdline[i].name.c_str());
+    }
+
     assert(cmdline.size() > 0);
     // It's unclear what does specifying multiple target when not generating
     // sysimg means. Make it an error for now.
to print out the cmdline options, I could see that it indeed ignores the cpu_target in >2.1.2 versions.

The outputs for both versions of PackageCompiler:

The output for [email protected]
julia> cpu_target = "generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)"
julia> PackageCompiler.create_sysimage(; sysimage_path="test_212.so", cpu_target)
target.name: znver3
sysimg.size(): 3
[0]: generic
[1]: sandybridge
[2]: haswell
Imaging:, 0
cmdline size, 1
CMDLINE: [0]: Flags: 0, Name: native
target.name: znver3  -----,
sysimg.size(): 1          |--- These 3 lines repeat 8 more times.
[0]: znver3          -----'
target.name: znver3
sysimg.size(): 3
[0]: generic
[1]: sandybridge
[2]: haswell
Imaging:, 0
cmdline size, 1
CMDLINE: [0]: Flags: 0, Name: native
target.name: generic
sysimg.size(): 3
[0]: generic
[1]: sandybridge
continue 1
[2]: haswell
continue 1
Imaging:, 1
cmdline size, 3
CMDLINE: [0]: Flags: 0, Name: generic
CMDLINE: [1]: Flags: 2, Name: sandybridge
CMDLINE: [2]: Flags: 0, Name: haswell
✔ [02m:39s] PackageCompiler: compiling incremental system image
The output for [email protected]
julia> cpu_target = "generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)"
julia> PackageCompiler.create_sysimage(; sysimage_path="test_215.so", cpu_target)
target.name: znver3
sysimg.size(): 3
[0]: generic
[1]: sandybridge
[2]: haswell
Imaging:, 0
cmdline size, 1
CMDLINE: [0]: Flags: 0, Name: native
target.name: znver3
sysimg.size(): 3
[0]: generic
[1]: sandybridge
[2]: haswell
Imaging:, 0
cmdline size, 1
CMDLINE: [0]: Flags: 0, Name: native
target.name: znver3
sysimg.size(): 3
[0]: generic
[1]: sandybridge
[2]: haswell
Imaging:, 0
cmdline size, 1
CMDLINE: [0]: Flags: 0, Name: native
✔ [02m:40s] PackageCompiler: compiling incremental system image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions