-
Notifications
You must be signed in to change notification settings - Fork 432
Fix UBSan errors: vptr check failures due to lack of RTTI #9384
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,6 +134,9 @@ cmake_arguments_for_slang=( | |
| -DLLVM_ENABLE_PROJECTS=clang | ||
| "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64" | ||
| -DLLVM_BUILD_TOOLS=0 | ||
| # slang-llvm is built with RTTI enabled to support UndefinedBehaviorSanitizer's vptr checks, so | ||
| # LLVM should be built with RTTI as well | ||
| -DLLVM_ENABLE_RTTI=1 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if we built LLVM with RTTI enabled in Slang release packages, these won't ship a build of slang-llvm with sanitizer instrumentation enabled. If we want to instrument slang-llvm with sanitizers as well, we have to build it as part of the sanitizer build instead of downloading the latest Slang release package. If we want to avoid having to build LLVM with RTTI as part of that, I guess we can just use https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#id16 to disable UBSan's vptr checks in slang-llvm (we're unlikely to run into a real type mismatch when casting these Slang COM API types). |
||
| # Get LLVM to use the static linked version of the msvc runtime | ||
| "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>" | ||
| "-DLLVM_USE_CRT_RELEASE=MT" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep this
if(NOT LLVM_ENABLE_RTTI)block here for theUSE_SYSTEM_LLVMoption to work. Some distributions may have LLVM without RTTI, and removing this would cause build errors with that option on such distributions.I think this block shouldn't be running on builds that used
build-llvm.shbecause of the flag that was added in this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I just noticed
<LLVM install dir>/lib/cmake/llvm/LLVMConfig.cmakesetsLLVM_ENABLE_RTTIto what it was set to when the LLVM CMake build was configured. I thoughtLLVM_ENABLE_RTTIwouldn't be set here soNOT LLVM_ENABLE_RTTIwould always be true.