Skip to content

AssertionError: isCursorDefinition(cursor) with CUDA's __device_builtin__ #546

@maleadt

Description

@maleadt

Reduced from the CUDA headers:

// from CUDA's vector_types.h
struct __device_builtin__ char1
{
    signed char x;
};

// from CUDA's driver_types.h
enum __device_builtin__ cudaError
{
    cudaSuccess = 0
};
using Clang.Generators

cd(@__DIR__)

options = load_options(joinpath(@__DIR__, "generator.toml"))

args = get_default_args()

headers = ["./bug.h"]

ctx = create_context(headers, args)

build!(ctx)
[ Info: Processing header: combined.h
cursor = CLCursor (Clang.CLEnumDecl) enum (unnamed at ./bug.h:6:6)
ERROR: LoadError: AssertionError: isCursorDefinition(cursor)
Stacktrace:
 [1] collect_top_level_nodes!(nodes::Vector{ExprNode}, cursor::Clang.CLEnumDecl, options::Dict{Any, Any})
   @ Clang.Generators ~/Julia/pkg/Clang/src/generator/top_level.jl:145
 [2] (::CollectTopLevelNode)(dag::ExprDAG, options::Dict{Any, Any})
   @ Clang.Generators ~/Julia/pkg/Clang/src/generator/passes.jl:50
 [3] build!(ctx::Context, stage::Clang.Generators.BuildStage)
   @ Clang.Generators ~/Julia/pkg/Clang/src/generator/context.jl:181
 [4] build!(ctx::Context)
   @ Clang.Generators ~/Julia/pkg/Clang/src/generator/context.jl:172
 [5] top-level scope
   @ ~/Julia/pkg/Clang/bug.jl:13

I'm not sure where that attribute is defined; some versions of Clang seem to actively ignore it:

    case 'd':    // 1 string to match.
      if (memcmp(Name.data()+1, "evice_builtin", 13) != 0)
        break;
      return AttributeCommonInfo::IgnoredAttribute;      // "device_builtin"

Workaround: -D__device_builtin__=__attribute__((unused))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions