Skip to content

Conversation

@bolt12
Copy link
Collaborator

@bolt12 bolt12 commented Nov 21, 2025

This PR fixes #1312

@bolt12 bolt12 self-assigned this Nov 21, 2025
TraceFrontend (FrontendClang (ClangErrorCode (SimpleEnum x)))
| Just CXError_ASTReadError <- simpleFromC x -> Debug
_ -> unCustomLogLevel (tCustomLogLevel tracerConfig) trace actualLevel
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TravisCardwell I've approved this PR and told @bolt12 to go ahead and merge this, but this tracerConfigWithoutASTReadError does feel a bit weird to me. It's only on the CLI, and only for this info command, so not a big deal, but nonetheless - do you have any thoughts on this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still do not understand why we are getting the error.

I did not think I got the error before, but I just checked with LLVM/Clang 14 and see it with that version as well. I likely just forgot about the error.

Does this error happen because the header is empty? I tried adding #define HS_BINDGEN_NOP_H to the header, but I still see the error.

Perhaps libclang is trying to parse the printed output? Surely not, but I do not know how to easily check this.

Suppressing the error (in this CLI command only) by changing the level to debug sounds like a suitable mitigation to me.


BTW, when I first tried building with LLVM/Clang 14, it failed because of the cached build for LLVM/Clang 21 in the Cabal store:

Template Haskell error: [Warning] [HsBindgen] [builtin-include-dir] clang version mismatch:
  libclang version: clang version 21.1.6
  clang version:    clang version 14.0.6

This issue (#1244) is annoying, and it is frustrating that there is nothing we can do about it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understood, Clang exits early without fully processing/parsing the input file, i.e. no AST is created and clang_parseTranslationUnit returns CXError_ASTReadError because no AST was built.

So in essence, it prints info and exits without completing the AST construction, regardless of file content

Copy link
Collaborator

@TravisCardwell TravisCardwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@bolt12 bolt12 added this pull request to the merge queue Nov 27, 2025
Merged via the queue into main with commit e895897 Nov 27, 2025
23 checks passed
@bolt12 bolt12 deleted the bolt12/1312 branch November 27, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

info libclang prints nothing?

5 participants