new binding for libclang-v17
Newbluecake opened this issue · 6 comments
Hi, I'm using this library to parse c/c++ code. Everying is good until I need a new api in v17. I try to gen binding for this version, but there seems to be some error. Could you support this version?
The same request. Is this library planned to be ported to the latest LLVM release?
I have ported one https://github.com/Newbluecake/bootstrap/tree/clang-v17, but not latest version
Thank you @Newbluecake for your work.
I am trying to compile this code with your library https://gist.githubusercontent.com/josharian/54b2268af5792ff0e62f06437f28a8c9/raw/f4d07e7340ae0bf84991deaa9d2cb478b7909d4a/gen_git2go_enum.go
and I have a warning:
# github.com/Newbluecake/bootstrap/clang
cgo-gcc-prolog: In function ‘_cgo_19b11e5eef9a_Cfunc_clang_getDiagnosticCategoryName’:
cgo-gcc-prolog:269:2: warning: ‘clang_getDiagnosticCategoryName’ is deprecated [-Wdeprecated-declarations]
In file included from ../../../go/pkg/mod/github.com/!newbluecake/bootstrap@v0.17.1/clang/clang_gen.go:4:
../../../go/pkg/mod/github.com/!newbluecake/bootstrap@v0.17.1/clang/./clang-c/CXDiagnostic.h:314:1: note: declared here
314 | clang_getDiagnosticCategoryName(unsigned Category);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
it seems harmless. But then I run the tool with ./tool -fname ~/sources/libgit2/include/git2/oid.h
but it fails:
/usr/include/time.h:29:10: fatal error: 'stddef.h' file not found
PROBLEM: 'stddef.h' file not found
which seems comes from
tu := idx.ParseTranslationUnit(*fname, []string{"-DDOCURIUM=1"}, nil, 0)
line. Do you have any idea why does it fail to find clang's stddef.h
file?
My system is Arch Linux up-to-date with clang v17:
$ clang --version
clang version 17.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Yeah, it seems that libclang did't automatically add system dir for header search. I add following code in my project to fix this problem:
cmd := exec.Command("bash", "-c", "echo | clang -E -v -")
output, err := cmd.CombinedOutput()
if err != nil {
return utils.LogError("exec clang err: %v", err)
}
outputStr := string(output)
lines := strings.Split(outputStr, "\n")
var start, end int
for i, line := range lines {
if line == "#include <...> search starts here:" {
start = i + 1
} else if line == "End of search list." {
end = i - 1
break
}
}
for i := start; i <= end; i++ {
dir := strings.TrimSpace(lines[i])
if dir == "" {
continue
}
psr.SysInclude = append(psr.SysInclude, dir)
}
It is a bit strange that libclang is unable to detect the clang's sysinclude dir automatically.
BTW @Newbluecake is there any chance you can update the bindings to clang-v18?
@anatol Sorry about that, you may checkout https://github.com/Newbluecake/gen and try it. If you have any question, I can help you.