Skip to content

Commit e1f1cc8

Browse files
pchintalapudiKristofferC
authored and
KristofferC
committed
Don't mark nonlocal symbols as hidden (#51530)
Co-authored-by: Valentin Churavy <[email protected]> (cherry picked from commit ac8246f)
1 parent 0e9addd commit e1f1cc8

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/aotcompile.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,12 @@ static SmallVector<Partition, 32> partitionModule(Module &M, unsigned threads) {
835835
continue;
836836
if (!canPartition(G))
837837
continue;
838-
G.setLinkage(GlobalValue::ExternalLinkage);
839-
G.setVisibility(GlobalValue::HiddenVisibility);
838+
// Currently ccallable global aliases have extern linkage, we only want to make the
839+
// internally linked functions/global variables extern+hidden
840+
if (G.hasLocalLinkage()) {
841+
G.setLinkage(GlobalValue::ExternalLinkage);
842+
G.setVisibility(GlobalValue::HiddenVisibility);
843+
}
840844
if (auto F = dyn_cast<Function>(&G)) {
841845
partitioner.make(&G, getFunctionWeight(*F).weight);
842846
} else {

src/codegen.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -6801,6 +6801,10 @@ const char *jl_generate_ccallable(LLVMOrcThreadSafeModuleRef llvmmod, void *sysi
68016801
int found = jl_dlsym(sysimg_handle, name, &addr, 0);
68026802
if (found)
68036803
add_named_global(name, addr);
6804+
else {
6805+
err = jl_get_exceptionf(jl_errorexception_type, "%s not found in sysimg", name);
6806+
jl_throw(err);
6807+
}
68046808
}
68056809
else {
68066810
jl_method_instance_t *lam = jl_get_specialization1((jl_tupletype_t*)sigt, world, &min_valid, &max_valid, 0);

src/staticdata.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -3371,7 +3371,7 @@ static jl_value_t *jl_validate_cache_file(ios_t *f, jl_array_t *depmods, uint64_
33713371
}
33723372

33733373
// TODO?: refactor to make it easier to create the "package inspector"
3374-
static jl_value_t *jl_restore_package_image_from_stream(ios_t *f, jl_image_t *image, jl_array_t *depmods, int completeinfo, const char *pkgname, bool needs_permalloc)
3374+
static jl_value_t *jl_restore_package_image_from_stream(void* pkgimage_handle, ios_t *f, jl_image_t *image, jl_array_t *depmods, int completeinfo, const char *pkgname, bool needs_permalloc)
33753375
{
33763376
JL_TIMING(LOAD_IMAGE, LOAD_Pkgimg);
33773377
jl_timing_printf(JL_TIMING_DEFAULT_BLOCK, pkgname);
@@ -3426,7 +3426,7 @@ static jl_value_t *jl_restore_package_image_from_stream(ios_t *f, jl_image_t *im
34263426
size_t world = jl_atomic_load_acquire(&jl_world_counter);
34273427
jl_insert_backedges((jl_array_t*)edges, (jl_array_t*)ext_targets, (jl_array_t*)new_specializations, world); // restore external backedges (needs to be last)
34283428
// reinit ccallables
3429-
jl_reinit_ccallable(&ccallable_list, base, NULL);
3429+
jl_reinit_ccallable(&ccallable_list, base, pkgimage_handle);
34303430
arraylist_free(&ccallable_list);
34313431

34323432
if (completeinfo) {
@@ -3457,11 +3457,11 @@ static void jl_restore_system_image_from_stream(ios_t *f, jl_image_t *image, uin
34573457
jl_restore_system_image_from_stream_(f, image, NULL, checksum | ((uint64_t)0xfdfcfbfa << 32), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
34583458
}
34593459

3460-
JL_DLLEXPORT jl_value_t *jl_restore_incremental_from_buf(const char *buf, jl_image_t *image, size_t sz, jl_array_t *depmods, int completeinfo, const char *pkgname, bool needs_permalloc)
3460+
JL_DLLEXPORT jl_value_t *jl_restore_incremental_from_buf(void* pkgimage_handle, const char *buf, jl_image_t *image, size_t sz, jl_array_t *depmods, int completeinfo, const char *pkgname, bool needs_permalloc)
34613461
{
34623462
ios_t f;
34633463
ios_static_buffer(&f, (char*)buf, sz);
3464-
jl_value_t *ret = jl_restore_package_image_from_stream(&f, image, depmods, completeinfo, pkgname, needs_permalloc);
3464+
jl_value_t *ret = jl_restore_package_image_from_stream(pkgimage_handle, &f, image, depmods, completeinfo, pkgname, needs_permalloc);
34653465
ios_close(&f);
34663466
return ret;
34673467
}
@@ -3474,7 +3474,7 @@ JL_DLLEXPORT jl_value_t *jl_restore_incremental(const char *fname, jl_array_t *d
34743474
"Cache file \"%s\" not found.\n", fname);
34753475
}
34763476
jl_image_t pkgimage = {};
3477-
jl_value_t *ret = jl_restore_package_image_from_stream(&f, &pkgimage, depmods, completeinfo, pkgname, true);
3477+
jl_value_t *ret = jl_restore_package_image_from_stream(NULL, &f, &pkgimage, depmods, completeinfo, pkgname, true);
34783478
ios_close(&f);
34793479
return ret;
34803480
}
@@ -3545,7 +3545,7 @@ JL_DLLEXPORT jl_value_t *jl_restore_package_image_from_file(const char *fname, j
35453545

35463546
jl_image_t pkgimage = jl_init_processor_pkgimg(pkgimg_handle);
35473547

3548-
jl_value_t* mod = jl_restore_incremental_from_buf(pkgimg_data, &pkgimage, *plen, depmods, completeinfo, pkgname, false);
3548+
jl_value_t* mod = jl_restore_incremental_from_buf(pkgimg_handle, pkgimg_data, &pkgimage, *plen, depmods, completeinfo, pkgname, false);
35493549

35503550
return mod;
35513551
}

0 commit comments

Comments
 (0)