Skip to content

Commit 5cc7ddf

Browse files
authored
add the ability to specify the external name of a ccallable (JuliaLang#57763)
This will allow exporting julia `main` as something else so a separate native `main` can be written to handle initialization. I'm sure it will have lots of other uses too though.
2 parents fb399f8 + 99294fe commit 5cc7ddf

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/typeinfer.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,8 +1371,7 @@ function typeinf_ext_toplevel(methods::Vector{Any}, worlds::Vector{UInt}, trim_m
13711371
end
13721372
# additionally enqueue the ccallable entrypoint / adapter, which implicitly
13731373
# invokes the above ci
1374-
push!(codeinfos, rt)
1375-
push!(codeinfos, sig)
1374+
push!(codeinfos, item)
13761375
end
13771376
end
13781377
while !isempty(tocompile)

src/verifytrim.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ function get_verify_typeinf_trim(codeinfos::Vector{Any})
256256
caches = IdDict{MethodInstance,CodeInstance}()
257257
errors = ErrorList()
258258
parents = ParentMap()
259-
for i = 1:2:length(codeinfos)
259+
for i = 1:length(codeinfos)
260260
item = codeinfos[i]
261261
if item isa CodeInstance
262262
push!(inspected, item)
@@ -268,14 +268,14 @@ function get_verify_typeinf_trim(codeinfos::Vector{Any})
268268
end
269269
end
270270
end
271-
for i = 1:2:length(codeinfos)
271+
for i = 1:length(codeinfos)
272272
item = codeinfos[i]
273273
if item isa CodeInstance
274274
src = codeinfos[i + 1]::CodeInfo
275275
verify_codeinstance!(item, src, inspected, caches, parents, errors)
276-
else
277-
rt = item::Type
278-
sig = codeinfos[i + 1]::Type
276+
elseif item isa SimpleVector
277+
rt = item[1]::Type
278+
sig = item[2]::Type
279279
ptr = ccall(:jl_get_specialization1,
280280
#= MethodInstance =# Ptr{Cvoid}, (Any, Csize_t, Cint),
281281
sig, this_world, #= mt_cache =# 0)

test/verifytrim.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ let infos = typeinf_ext_toplevel(Any[Core.svec(Base.SecretBuffer, Tuple{Type{Bas
4444
4545
$""", repr)
4646

47-
resize!(infos, 2)
48-
@test infos[1] isa Type && infos[2] isa Type
47+
resize!(infos, 1)
48+
@test infos[1] isa Core.SimpleVector && infos[1][1] isa Type && infos[1][2] isa Type
4949
errors, parents = get_verify_typeinf_trim(infos)
5050
desc = only(errors)
5151
@test !desc.first

0 commit comments

Comments
 (0)