@@ -1519,7 +1519,7 @@ static inline void disable_depends(FeatureList<n> &features)
15191519 ::disable_depends (features, Feature::deps, sizeof (Feature::deps) / sizeof(FeatureDep));
15201520}
15211521
1522- static const llvm::SmallVector<TargetData<feature_sz>, 0 > &get_cmdline_targets (void )
1522+ static const llvm::SmallVector<TargetData<feature_sz>, 0 > &get_cmdline_targets (const char *cpu_target )
15231523{
15241524 auto feature_cb = [] (const char *str, size_t len, FeatureList<feature_sz> &list) {
15251525#ifdef _CPU_AARCH64_
@@ -1536,7 +1536,7 @@ static const llvm::SmallVector<TargetData<feature_sz>, 0> &get_cmdline_targets(v
15361536 set_bit (list, fbit, true );
15371537 return true ;
15381538 };
1539- auto &targets = ::get_cmdline_targets<feature_sz>(feature_cb);
1539+ auto &targets = ::get_cmdline_targets<feature_sz>(cpu_target, feature_cb);
15401540 for (auto &t: targets) {
15411541 if (auto nname = normalize_cpu_name (t.name )) {
15421542 t.name = nname;
@@ -1599,10 +1599,11 @@ static int max_vector_size(const FeatureList<feature_sz> &features)
15991599#endif
16001600}
16011601
1602- static uint32_t sysimg_init_cb (const void *id, jl_value_t **rejection_reason)
1602+ static uint32_t sysimg_init_cb (void *ctx, const void *id, jl_value_t **rejection_reason)
16031603{
16041604 // First see what target is requested for the JIT.
1605- auto &cmdline = get_cmdline_targets ();
1605+ const char *cpu_target = (const char *)ctx;
1606+ auto &cmdline = get_cmdline_targets (cpu_target);
16061607 TargetData<feature_sz> target = arg_target_data (cmdline[0 ], true );
16071608 // Then find the best match in the sysimg
16081609 auto sysimg = deserialize_target_data<feature_sz>((const uint8_t *)id);
@@ -1626,7 +1627,7 @@ static uint32_t sysimg_init_cb(const void *id, jl_value_t **rejection_reason)
16261627 return match.best_idx ;
16271628}
16281629
1629- static uint32_t pkgimg_init_cb (const void *id, jl_value_t **rejection_reason JL_REQUIRE_ROOTED_SLOT)
1630+ static uint32_t pkgimg_init_cb (void *ctx, const void *id, jl_value_t **rejection_reason JL_REQUIRE_ROOTED_SLOT)
16301631{
16311632 TargetData<feature_sz> target = jit_targets.front ();
16321633 auto pkgimg = deserialize_target_data<feature_sz>((const uint8_t *)id);
@@ -1639,9 +1640,9 @@ static uint32_t pkgimg_init_cb(const void *id, jl_value_t **rejection_reason JL_
16391640 return match.best_idx ;
16401641}
16411642
1642- static void ensure_jit_target (bool imaging)
1643+ static void ensure_jit_target (const char *cpu_target, bool imaging)
16431644{
1644- auto &cmdline = get_cmdline_targets ();
1645+ auto &cmdline = get_cmdline_targets (cpu_target );
16451646 check_cmdline (cmdline, imaging);
16461647 if (!jit_targets.empty ())
16471648 return ;
@@ -1852,36 +1853,36 @@ JL_DLLEXPORT jl_value_t *jl_cpu_has_fma(int bits)
18521853#endif
18531854}
18541855
1855- jl_image_t jl_init_processor_sysimg (void *hdl )
1856+ jl_image_t jl_init_processor_sysimg (jl_image_buf_t image, const char *cpu_target )
18561857{
18571858 if (!jit_targets.empty ())
18581859 jl_error (" JIT targets already initialized" );
1859- return parse_sysimg (hdl , sysimg_init_cb);
1860+ return parse_sysimg (image , sysimg_init_cb, ( void *)cpu_target );
18601861}
18611862
1862- jl_image_t jl_init_processor_pkgimg (void *hdl )
1863+ jl_image_t jl_init_processor_pkgimg (jl_image_buf_t image )
18631864{
18641865 if (jit_targets.empty ())
18651866 jl_error (" JIT targets not initialized" );
18661867 if (jit_targets.size () > 1 )
18671868 jl_error (" Expected only one JIT target" );
1868- return parse_sysimg (hdl , pkgimg_init_cb);
1869+ return parse_sysimg (image , pkgimg_init_cb, NULL );
18691870}
18701871
18711872JL_DLLEXPORT jl_value_t * jl_check_pkgimage_clones (char *data)
18721873{
18731874 jl_value_t *rejection_reason = NULL ;
18741875 JL_GC_PUSH1 (&rejection_reason);
1875- uint32_t match_idx = pkgimg_init_cb (data, &rejection_reason);
1876+ uint32_t match_idx = pkgimg_init_cb (NULL , data, &rejection_reason);
18761877 JL_GC_POP ();
18771878 if (match_idx == UINT32_MAX)
18781879 return rejection_reason;
18791880 return jl_nothing;
18801881}
18811882
1882- std::pair<std::string,llvm::SmallVector<std::string, 0 >> jl_get_llvm_target (bool imaging, uint32_t &flags)
1883+ std::pair<std::string,llvm::SmallVector<std::string, 0 >> jl_get_llvm_target (const char *cpu_target, bool imaging, uint32_t &flags)
18831884{
1884- ensure_jit_target (imaging);
1885+ ensure_jit_target (cpu_target, imaging);
18851886 flags = jit_targets[0 ].en .flags ;
18861887 return get_llvm_target_vec (jit_targets[0 ]);
18871888}
@@ -1900,10 +1901,10 @@ const std::pair<std::string,std::string> &jl_get_llvm_disasm_target(void)
19001901}
19011902
19021903#ifndef __clang_gcanalyzer__
1903- llvm::SmallVector<jl_target_spec_t , 0 > jl_get_llvm_clone_targets (void )
1904+ llvm::SmallVector<jl_target_spec_t , 0 > jl_get_llvm_clone_targets (const char *cpu_target )
19041905{
19051906
1906- auto &cmdline = get_cmdline_targets ();
1907+ auto &cmdline = get_cmdline_targets (cpu_target );
19071908 check_cmdline (cmdline, true );
19081909 llvm::SmallVector<TargetData<feature_sz>, 0 > image_targets;
19091910 for (auto &arg: cmdline) {
0 commit comments