-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang::ASTWriter can create a crashing PCH if an incorrect hasErrors value is passed #53952
Comments
@llvm/issue-subscribers-clang-codegen |
Hey there, I am new to open source so can you please explain the issue in detail so I can start working on it |
Hey @Aadi-Mittal-2004 , If you are new to LLVM or open source in general, I'd suggest go through the contribution guidelines you can find here for LLVM https://llvm.org/docs/Contributing.html . About the issue, |
Hi, If no-one is working on this issue, I would like to take up this, can someone please assign the issue to me. As I am not in the contributor list, I am not able to assign it to myself. @phyBrackets Thanks for the contributing guidelines and the detailed explanation of the scenario here. Thanks |
Hi @TestingPlant @phyBrackets @danix800 I am trying to reproduce the issue and find the root cause for the same, but stuck with some linker error, can anyone of you help me in figuring this out. I am new to llvm project, I managed to build clang and llvm properly. I tried few other things with the build to get more exposure on how things work. But when I am trying to compile and link the code given above, I am facing an issue with linker as follows:
I am using the following command to compile & generate the executable for the input C++ program: (bld_ninja is my build directory)
$CLANGLIBS has the clang libraries linked in correct order:
Based on the error above, I assume that this error is because the LLVM libraries are not linked properly, and I am not sure about the order of LLVM libraries that has to be listed as part of this. I tried using Can anyone help me with this. Thanks |
Hi, not exactly sure did you try building with |
@phyBrackets I have tried this still it is the same issue, I have tried passing the absolute paths also, still the same. |
Hi Team, I kind of followed this thread: https://stackoverflow.com/questions/8607432/link-fails-with-clang-llvm-using-g And used https://github.com/loarabia/Clang-tutorial/blob/master/makefile this make file to compile, And then for the linker errors I am getting further, I followed the LLVM thread https://discourse.llvm.org/t/undefined-reference-only-when-including-astmatchers/67687 and added Now I am able to reproduce the issue, I will work to root cause the issue further and post any updates here. Thank you for the time and support! |
Hi Team, I am able to root cause the issue, I can avoid this in two ways:
I am not sure which is better, any ideas or suggestions?? Forcing And one more thing, are we still following Phabricator review process or we moved to pull-requests? Thanks |
The issue llvm#53952 is reported indicating clang is giving a crashing pch file, when hasErrors is been passed incorrectly to WriteAST method. To fix the issue, I have a added an assertion to make sure the given value of ASTHasCompilerErrors is matching with Preprocessor diagnostics. And this assertion will get triggered inside Debug builds. For release builds, based on the conditional check, forcefully set the ASTHasCompilerErrors member variable to a valid value from Preprocessor.
…ber variable correctly based on the PP diagnostics. (#68127)" This reverts commit a50e63b. With clang-14.0.6 as the host compiler, I'm getting: ld.lld: error: undefined symbol: clang::ASTWriter::WriteAST(clang::Sema&, llvm::StringRef, clang::Module*, llvm::StringRef, bool, bool) >>> referenced by ASTUnit.cpp >>> ASTUnit.cpp.o:(clang::ASTUnit::serialize(llvm::raw_ostream&)) in archive lib/libclangFrontend.a
With the following code:
and the below file:
clang
will crash when using theinput.gch
file generated from the code.Output:
The text was updated successfully, but these errors were encountered: