Theo Buehler <[email protected]> writes:

> With zig updated to 0.17.1, devel/c2ffi is the last user of devel/llvm/21
> The diff in https://github.com/rpav/c2ffi/pull/133 works in some simple
> examples, so hopefully we can drop llvm/21 soon.

ok semarie@

Thanks


> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/devel/c2ffi/Makefile,v
> diff -u -p -r1.4 Makefile
> --- Makefile  5 Jun 2026 06:08:59 -0000       1.4
> +++ Makefile  16 Nov 2026 19:03:56 -0000
> @@ -5,6 +5,7 @@ DISTNAME =    c2ffi-21.1.0.20260104
>  GH_ACCOUNT = rpav
>  GH_PROJECT = c2ffi
>  GH_COMMIT =  f52a6c90651cd5f2f5239b67b41fb9a7e4de1f2e
> +REVISION =   0
>  
>  CATEGORIES = devel
>  
> @@ -28,7 +29,7 @@ MODULES =   devel/cmake \
>               lang/clang
>  
>  # c2ffi has branches for each llvm version, so stick to the targeted one
> -MODCLANG_VERSION =   21
> +MODCLANG_VERSION =   22
>  
>  BUILD_DEPENDS +=     devel/llvm/${MODCLANG_VERSION}
>  LIB_DEPENDS +=               ${MODCLANG_LIB_DEPENDS}
> Index: patches/patch-CMakeLists_txt
> ===================================================================
> RCS file: /cvs/ports/devel/c2ffi/patches/patch-CMakeLists_txt,v
> diff -u -p -r1.3 patch-CMakeLists_txt
> --- patches/patch-CMakeLists_txt      5 Jun 2026 06:08:59 -0000       1.3
> +++ patches/patch-CMakeLists_txt      16 Nov 2026 19:03:56 -0000
> @@ -3,6 +3,15 @@ link with static libLLVMcore and libLLVM
>  Index: CMakeLists.txt
>  --- CMakeLists.txt.orig
>  +++ CMakeLists.txt
> +@@ -7,7 +7,7 @@ project(c2ffi)
> + set(SOURCE_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
> + 
> + # Apparently the LLVM package doesn't support ranges
> +-find_package(LLVM 21.1 CONFIG)
> ++find_package(LLVM 22.1 CONFIG)
> + find_package(Clang REQUIRED CONFIG)
> + 
> + message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
>  @@ -64,7 +64,11 @@ target_include_directories(c2ffi PUBLIC
>     ${LLVM_INCLUDE_DIRS}
>     ${SOURCE_ROOT}/src/include
> Index: patches/patch-src_AST_cpp
> ===================================================================
> RCS file: patches/patch-src_AST_cpp
> diff -N patches/patch-src_AST_cpp
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_AST_cpp 16 Nov 2026 19:03:56 -0000
> @@ -0,0 +1,18 @@
> +add llvm22 support
> +https://github.com/rpav/c2ffi/pull/133
> +
> +Index: src/AST.cpp
> +--- src/AST.cpp.orig
> ++++ src/AST.cpp
> +@@ -295,11 +295,6 @@ Decl* C2FFIASTConsumer::make_decl(const clang::RecordD
> + 
> + bool is_underlying_valid(const clang::Type* t)
> + {
> +-    if_const_cast(e, clang::ElaboratedType, t)
> +-    {
> +-        return is_underlying_valid(e->getNamedType().getTypePtr());
> +-    }
> +-
> +     if_const_cast(rt, clang::RecordType, t)
> +     {
> +         if(rt->getDecl()->isInvalidDecl()) return false;
> Index: patches/patch-src_Decl_cpp
> ===================================================================
> RCS file: patches/patch-src_Decl_cpp
> diff -N patches/patch-src_Decl_cpp
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_Decl_cpp        16 Nov 2026 19:03:56 -0000
> @@ -0,0 +1,23 @@
> +add llvm22 support
> +https://github.com/rpav/c2ffi/pull/133
> +
> +Index: src/Decl.cpp
> +--- src/Decl.cpp.orig
> ++++ src/Decl.cpp
> +@@ -21,6 +21,7 @@
> + #include <clang/AST/ASTContext.h>
> + #include <clang/AST/DeclCXX.h>
> + #include <clang/AST/DeclObjC.h>
> ++#include <clang/AST/TypeBase.h>
> + 
> + #include "c2ffi.h"
> + #include "c2ffi/ast.h"
> +@@ -160,7 +161,7 @@ void RecordDecl::fill_record_decl(C2FFIASTConsumer* as
> + {
> +     clang::ASTContext& ctx  = ast->ci().getASTContext();
> +     std::string        name = d->getDeclName().getAsString();
> +-    const clang::Type* t    = d->getTypeForDecl();
> ++    const clang::Type* t    = ctx.getCanonicalTypeDeclType(d)->getTypePtr();
> + 
> +     if(!t->isIncompleteType() && !t->isInstantiationDependentType()) {
> +         set_bit_size(ctx.getTypeSize(t));
> Index: patches/patch-src_Type_cpp
> ===================================================================
> RCS file: patches/patch-src_Type_cpp
> diff -N patches/patch-src_Type_cpp
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_Type_cpp        16 Nov 2026 19:03:56 -0000
> @@ -0,0 +1,27 @@
> +add llvm22 support
> +https://github.com/rpav/c2ffi/pull/133
> +
> +Index: src/Type.cpp
> +--- src/Type.cpp.orig
> ++++ src/Type.cpp
> +@@ -99,10 +99,6 @@ Type* Type::make_type(C2FFIASTConsumer *ast, const cla
> +         return new SimpleType(ci, td, tdd->getDeclName().getAsString());
> +     }
> + 
> +-    if_const_cast(e, clang::ElaboratedType, t) {
> +-        return make_type(ast, e->getNamedType().getTypePtr());
> +-    }
> +-
> +     if_const_cast(tt, clang::SubstTemplateTypeParmType, t) {
> +         if(tt != tt->desugar().getTypePtr())
> +             return make_type(ast, tt->desugar().getTypePtr());
> +@@ -115,9 +111,6 @@ Type* Type::make_type(C2FFIASTConsumer *ast, const cla
> + 
> +         return new BasicType(ci, t, make_builtin_name(bt));
> +     }
> +-
> +-    if_const_cast(e, clang::ElaboratedType, t)
> +-        return make_type(ast, e->getNamedType().getTypePtr());
> + 
> +     if(t->isFunctionPointerType())
> +         return new SimpleType(ci, t, ":function-pointer");
> Index: patches/patch-src_drivers_Sexp_cpp
> ===================================================================
> RCS file: patches/patch-src_drivers_Sexp_cpp
> diff -N patches/patch-src_drivers_Sexp_cpp
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_drivers_Sexp_cpp        16 Nov 2026 19:03:56 -0000
> @@ -0,0 +1,26 @@
> +add llvm22 support
> +https://github.com/rpav/c2ffi/pull/133
> +
> +Index: src/drivers/Sexp.cpp
> +--- src/drivers/Sexp.cpp.orig
> ++++ src/drivers/Sexp.cpp
> +@@ -44,6 +44,10 @@ namespace c2ffi {
> + 
> +                 os()  << "(" << i->first << " ";
> +                 write(*(i->second));
> ++                os() << " ";
> ++                os() << ":bit-offset " << i->second->bit_offset() << " "
> ++                     << ":bit-size " << i->second->bit_size() << " "
> ++                     << ":bit-alignment " << i->second->bit_alignment();
> +                 os() << ")";
> +             }
> + 
> +@@ -245,6 +249,8 @@ namespace c2ffi {
> +                 os() << ":id " << d.id();
> +             else
> +                 os() << d.name();
> ++
> ++            os() << " :size " << d.bit_size();
> + 
> +             write_fields(d.fields());
> +             os() << ")"; endl();
> Index: patches/patch-src_include_c2ffi_opt_h
> ===================================================================
> RCS file: patches/patch-src_include_c2ffi_opt_h
> diff -N patches/patch-src_include_c2ffi_opt_h
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_include_c2ffi_opt_h     16 Nov 2026 19:03:56 -0000
> @@ -0,0 +1,14 @@
> +add llvm22 support
> +https://github.com/rpav/c2ffi/pull/133
> +
> +Index: src/include/c2ffi/opt.h
> +--- src/include/c2ffi/opt.h.orig
> ++++ src/include/c2ffi/opt.h
> +@@ -26,7 +26,6 @@
> + 
> + #include <vector>
> + #include <string>
> +-#include <iostream>
> + #include <fstream>
> + 
> + #include "c2ffi.h"
> Index: patches/patch-src_init_cpp
> ===================================================================
> RCS file: patches/patch-src_init_cpp
> diff -N patches/patch-src_init_cpp
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_init_cpp        16 Nov 2026 19:03:56 -0000
> @@ -0,0 +1,25 @@
> +add llvm22 support
> +https://github.com/rpav/c2ffi/pull/133
> +
> +Index: src/init.cpp
> +--- src/init.cpp.orig
> ++++ src/init.cpp
> +@@ -171,8 +171,7 @@ void c2ffi::init_ci(config &c, clang::CompilerInstance
> +         }
> +     }
> + 
> +-    // Create the compilers actual diagnostics engine.
> +-    ci.createDiagnostics(*llvm::vfs::getRealFileSystem());
> ++    ci.createDiagnostics(new clang::TextDiagnosticPrinter(llvm::errs(), 
> DiagOpts));
> +     ci.getDiagnostics().setWarningsAsErrors(c.warn_as_error);
> +     if (c.error_limit >= 0)
> +       ci.getDiagnostics().setErrorLimit(c.error_limit);
> +@@ -209,7 +208,7 @@ void c2ffi::init_ci(config &c, clang::CompilerInstance
> +                                                       pti->getTriple(), 
> includes, c.std);
> +     //clang::LangOptions::setLangDefaults(lo, c.kind.getLanguage(), 
> pti->getTriple(), includes, c.std);
> +     ci.createFileManager();
> +-    ci.createSourceManager(ci.getFileManager());
> ++    ci.createSourceManager();
> + 
> +     // examples/clang-interpreter/main.cpp
> +     // Infer the builtin include path if unspecified.
> Index: patches/patch-src_options_cpp
> ===================================================================
> RCS file: patches/patch-src_options_cpp
> diff -N patches/patch-src_options_cpp
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_options_cpp     16 Nov 2026 19:03:56 -0000
> @@ -0,0 +1,15 @@
> +add llvm22 support
> +https://github.com/rpav/c2ffi/pull/133
> +
> +Index: src/options.cpp
> +--- src/options.cpp.orig
> ++++ src/options.cpp
> +@@ -69,7 +69,7 @@ static void usage(void);
> + static c2ffi::OutputDriver* select_driver(std::string name, std::ostream 
> *os);
> + 
> + clang::LangStandard::Kind parseStd(std::string std) {
> +-#define LANGSTANDARD(ident, name, lang, desc, features) if(std == name) 
> return clang::LangStandard::lang_##ident;
> ++#define LANGSTANDARD(ident, name, lang, desc, features, version) if(std == 
> name) return clang::LangStandard::lang_##ident;
> + #include "clang/Basic/LangStandards.def"
> +     return clang::LangStandard::lang_unspecified;
> + }
-- 
Sebastien Marie

Reply via email to