JuliaInterop / Clang.jl

C binding generator and Julia interface to libclang
https://juliainterop.github.io/Clang.jl/
MIT License
217 stars 68 forks source link

Bump Clang_jll's version #465

Closed Gnimuc closed 4 months ago

Gnimuc commented 6 months ago

fix #464

Gnimuc commented 6 months ago

There are some undocumented behavior changes introduced in Clang16...

C

typedef struct ImVector_ImDrawCmd {int Size;int Capacity;ImDrawCmd* Data;} ImVector_ImDrawCmd;

typedef struct ImVector_ImDrawIdx {int Size;int Capacity;ImDrawIdx* Data;} ImVector_ImDrawIdx;

struct ImDrawChannel
{
    ImVector_ImDrawCmd _CmdBuffer;
    ImVector_ImDrawIdx _IdxBuffer;
};

Clang 16:

getTypeDeclaration(type) = CLCursor (Clang.CLStructDecl) ImDrawChannel
 Clang.CLStructDecl ImDrawChannel
    Clang.CLFieldDecl a Clang.CLElaborated ImVector_ImDrawCmd _CmdBuffer
    Clang.CLFieldDecl a Clang.CLElaborated ImVector_ImDrawIdx _IdxBuffer
(c, ty, getNamedType(ty)) = (CLCursor (Clang.CLFieldDecl) _CmdBuffer, CLType (Clang.CLElaborated) , CLType (Clang.CLTypedef) )
ERROR: LoadError: AssertionError: jlty isa JuliaCenum || jlty isa JuliaCrecord
Stacktrace:
 [1] tojulia(x::Clang.CLElaborated)
   @ Clang.Generators ~/.julia/dev/Clang/src/generator/jltypes.jl:151
 [2] collect_dependent_system_nodes!(dag::ExprDAG, type::Clang.CLRecord, system_nodes::Dict{ExprNode, Int64})
   @ Clang.Generators ~/.julia/dev/Clang/src/generator/system_deps.jl:133
 [3] collect_dependent_system_nodes!(dag::ExprDAG, node::ExprNode{Clang.Generators.StructForwardDecl, Clang.CLStructDecl}, system_nodes::Dict{ExprNode, Int64})
   @ Clang.Generators ~/.julia/dev/Clang/src/generator/system_deps.jl:124

Clang 15

getTypeDeclaration(type) = CLCursor (Clang.CLStructDecl) ImDrawChannel
 Clang.CLStructDecl ImDrawChannel
    Clang.CLFieldDecl a Clang.CLTypedef ImVector_ImDrawCmd _CmdBuffer
    Clang.CLFieldDecl a Clang.CLTypedef ImVector_ImDrawIdx _IdxBuffer
ERROR: LoadError: MethodError: no method matching getNamedType(::Clang.CLTypedef)

Closest candidates are:
  getNamedType(::Clang.CLElaborated)
   @ Clang ~/.julia/dev/Clang/src/type.jl:152
  getNamedType(::Clang.LibClang.CXType)
   @ Clang ~/.julia/dev/Clang/src/type.jl:151

Stacktrace:
 [1] macro expansion
   @ ./show.jl:1181 [inlined]
 [2] collect_dependent_system_nodes!(dag::ExprDAG, type::Clang.CLRecord, system_nodes::Dict{ExprNode, Int64})
   @ Clang.Generators ~/.julia/dev/Clang/src/generator/system_deps.jl:132
Gnimuc commented 6 months ago

I dont know why ImVector_ImDrawCmd needs to be represented as an elaborated type.

JamesWrigley commented 5 months ago

MWE:

typedef int foo;

typedef struct X
{
    foo field;
} X;

Also, where is CLElaborated defined? :thinking: It's used in a couple places but I can't find the definition anywhere.

JamesWrigley commented 5 months ago

Oh NVM, I see it's created automatically in cltypes.jl. Man, this is weird :confused: I might try doing a poor-mans bisect with the available Clang_jll versions: https://github.com/JuliaRegistries/General/blob/master/jll/C/Clang_jll/Versions.toml

Gnimuc commented 5 months ago

Oh NVM, I see it's created automatically in cltypes.jl. Man, this is weird 😕 I might try doing a poor-mans bisect with the available Clang_jll versions: https://github.com/JuliaRegistries/General/blob/master/jll/C/Clang_jll/Versions.toml

it would be faster to check the source directly. but this is not urgent. one can always run the generator with the old Julia version .

JamesWrigley commented 5 months ago

Actually I need it to fix more method ambiguities in 1.11 :sweat_smile: Example failure: https://github.com/JuliaWeb/LibSSH.jl/actions/runs/7698581250/job/20978180881

Similar to #458. But you're right, it's not urgent yet.