@@ -1510,7 +1510,7 @@ static inline void disable_depends(FeatureList<n> &features)
15101510 ::disable_depends (features, Feature::deps, sizeof (Feature::deps) / sizeof(FeatureDep));
15111511}
15121512
1513- static const llvm::SmallVector<TargetData<feature_sz>, 0 > &get_cmdline_targets (void )
1513+ static const llvm::SmallVector<TargetData<feature_sz>, 0 > &get_cmdline_targets (const char *cpu_target )
15141514{
15151515 auto feature_cb = [] (const char *str, size_t len, FeatureList<feature_sz> &list) {
15161516#ifdef _CPU_AARCH64_
@@ -1527,7 +1527,7 @@ static const llvm::SmallVector<TargetData<feature_sz>, 0> &get_cmdline_targets(v
15271527 set_bit (list, fbit, true );
15281528 return true ;
15291529 };
1530- auto &targets = ::get_cmdline_targets<feature_sz>(feature_cb);
1530+ auto &targets = ::get_cmdline_targets<feature_sz>(cpu_target, feature_cb);
15311531 for (auto &t: targets) {
15321532 if (auto nname = normalize_cpu_name (t.name )) {
15331533 t.name = nname;
@@ -1590,10 +1590,11 @@ static int max_vector_size(const FeatureList<feature_sz> &features)
15901590#endif
15911591}
15921592
1593- static uint32_t sysimg_init_cb (const void *id, jl_value_t **rejection_reason)
1593+ static uint32_t sysimg_init_cb (void *ctx, const void *id, jl_value_t **rejection_reason)
15941594{
15951595 // First see what target is requested for the JIT.
1596- auto &cmdline = get_cmdline_targets ();
1596+ const char *cpu_target = (const char *)ctx;
1597+ auto &cmdline = get_cmdline_targets (cpu_target);
15971598 TargetData<feature_sz> target = arg_target_data (cmdline[0 ], true );
15981599 // Then find the best match in the sysimg
15991600 auto sysimg = deserialize_target_data<feature_sz>((const uint8_t *)id);
@@ -1617,7 +1618,7 @@ static uint32_t sysimg_init_cb(const void *id, jl_value_t **rejection_reason)
16171618 return match.best_idx ;
16181619}
16191620
1620- static uint32_t pkgimg_init_cb (const void *id, jl_value_t **rejection_reason JL_REQUIRE_ROOTED_SLOT)
1621+ static uint32_t pkgimg_init_cb (void *ctx, const void *id, jl_value_t **rejection_reason JL_REQUIRE_ROOTED_SLOT)
16211622{
16221623 TargetData<feature_sz> target = jit_targets.front ();
16231624 auto pkgimg = deserialize_target_data<feature_sz>((const uint8_t *)id);
@@ -1630,9 +1631,9 @@ static uint32_t pkgimg_init_cb(const void *id, jl_value_t **rejection_reason JL_
16301631 return match.best_idx ;
16311632}
16321633
1633- static void ensure_jit_target (bool imaging)
1634+ static void ensure_jit_target (const char *cpu_target, bool imaging)
16341635{
1635- auto &cmdline = get_cmdline_targets ();
1636+ auto &cmdline = get_cmdline_targets (cpu_target );
16361637 check_cmdline (cmdline, imaging);
16371638 if (!jit_targets.empty ())
16381639 return ;
@@ -1843,36 +1844,36 @@ JL_DLLEXPORT jl_value_t *jl_cpu_has_fma(int bits)
18431844#endif
18441845}
18451846
1846- jl_image_t jl_init_processor_sysimg (void *hdl )
1847+ jl_image_t jl_init_processor_sysimg (jl_image_buf_t image, const char *cpu_target )
18471848{
18481849 if (!jit_targets.empty ())
18491850 jl_error (" JIT targets already initialized" );
1850- return parse_sysimg (hdl , sysimg_init_cb);
1851+ return parse_sysimg (image , sysimg_init_cb, ( void *)cpu_target );
18511852}
18521853
1853- jl_image_t jl_init_processor_pkgimg (void *hdl )
1854+ jl_image_t jl_init_processor_pkgimg (jl_image_buf_t image )
18541855{
18551856 if (jit_targets.empty ())
18561857 jl_error (" JIT targets not initialized" );
18571858 if (jit_targets.size () > 1 )
18581859 jl_error (" Expected only one JIT target" );
1859- return parse_sysimg (hdl , pkgimg_init_cb);
1860+ return parse_sysimg (image , pkgimg_init_cb, NULL );
18601861}
18611862
18621863JL_DLLEXPORT jl_value_t * jl_check_pkgimage_clones (char *data)
18631864{
18641865 jl_value_t *rejection_reason = NULL ;
18651866 JL_GC_PUSH1 (&rejection_reason);
1866- uint32_t match_idx = pkgimg_init_cb (data, &rejection_reason);
1867+ uint32_t match_idx = pkgimg_init_cb (NULL , data, &rejection_reason);
18671868 JL_GC_POP ();
18681869 if (match_idx == UINT32_MAX)
18691870 return rejection_reason;
18701871 return jl_nothing;
18711872}
18721873
1873- std::pair<std::string,llvm::SmallVector<std::string, 0 >> jl_get_llvm_target (bool imaging, uint32_t &flags)
1874+ std::pair<std::string,llvm::SmallVector<std::string, 0 >> jl_get_llvm_target (const char *cpu_target, bool imaging, uint32_t &flags)
18741875{
1875- ensure_jit_target (imaging);
1876+ ensure_jit_target (cpu_target, imaging);
18761877 flags = jit_targets[0 ].en .flags ;
18771878 return get_llvm_target_vec (jit_targets[0 ]);
18781879}
@@ -1891,10 +1892,10 @@ const std::pair<std::string,std::string> &jl_get_llvm_disasm_target(void)
18911892}
18921893
18931894#ifndef __clang_gcanalyzer__
1894- llvm::SmallVector<jl_target_spec_t , 0 > jl_get_llvm_clone_targets (void )
1895+ llvm::SmallVector<jl_target_spec_t , 0 > jl_get_llvm_clone_targets (const char *cpu_target )
18951896{
18961897
1897- auto &cmdline = get_cmdline_targets ();
1898+ auto &cmdline = get_cmdline_targets (cpu_target );
18981899 check_cmdline (cmdline, true );
18991900 llvm::SmallVector<TargetData<feature_sz>, 0 > image_targets;
19001901 for (auto &arg: cmdline) {
0 commit comments