<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113851>113851</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLVM Build Fails with MemorySanitizer Instrumentation Due to Uninitialized Value Errors
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JacobNowitsky
</td>
</tr>
</table>
<pre>
**Issue Description**
I am attempting to build LLVM with MemorySanitizer (MemoryWithOrigins) as described in the [MemorySanitizer libc++ guide](https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo), but I encounter persistent build failures and uninitialized value errors.
**Build Configuration:**
```
cmake -GNinja ../llvm \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_USE_SANITIZER=MemoryWithOrigins
```
**Build Failure Output:**
I am running ninja to build with the above configuration. The following error is typical of what I see:
**#7 0x555f2def5c9c in llvm::RecordKeeper::addClass(std::unique_ptr<llvm::Record, std::default_delete<llvm::Record> >) /home/j/llvm-project/llvm/include/llvm/TableGen/Record.h:2027:24
...
SUMMARY: MemorySanitizer: use-of-uninitialized-value /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_tree.h:1336:4 in _M_lower_bound_tr<llvm::StringRef, void>**
The full build log can be found in my Stack Overflow question: LLVM error with libc++ instrumentation.
https://stackoverflow.com/questions/79131437/llvm-build-fails-with-memorysanitizer-enabled
**Additional Steps Tried**
While building without MemoryWithOrigins completes successfully, the instrumentation necessary to use MemorySanitizer with libc++ is missing, making it ineffective for my application.
Expected Behavior
The build should succeed with MemoryWithOrigins enabled, allowing the MemorySanitizer to instrument libc++ without throwing uninitialized value errors during the build process.
Questions
Is there a known workaround for these errors?
Are there additional flags or configuration options to enable a successful build with MemorySanitizer?
Any insights or further troubleshooting steps would be greatly appreciated.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VllzGjsT_TXipQsKNKwPPLBNPhIv-Yyd5b5QmlHPjGIhES1g8utvSQM2Bt9UpURGbvVy-vSRmLWiVIhj0puS3rzBvKu0GX9muc7u9F44-3xoZJofxoROCJ0srfUIc7S5EVsntKq3SXtO2sd1CWwDzDncbJ1QJTgNmReSw83Nt1vYC1fBLW60OayYEk78QQOEDuut78JV90aUQllCR8As8BgqQw5CgasQSG96eVyKLCd0SugUSi84kt6c0GHl3NaSZEJoSmhaClf5rJXrTfjQupRIaGpPPiyh6V48C0LTC-83IstfXv6n94-a0BGhM8i8gyWgyrVXDg1s0VhhHSp3LLRgQnqDFpji4JUInpgUf5DDjkmPgMZoY1vnqL1bI6bT6GumVSFKb1gEO5lc431c--3jv_iZb9gzQvPTnVC_GLRahKZS7jZAerPaAACgOZ_dTr4s1tOn5c18_fjz64Ik8weUyCyeWTbnoXPrxd1kerNYf324_7yYPa5IMieUyogOSab1f1gmCKXvztYhZuvZ_e3X5c3igSTzXDJVfpzK7MePK8tja68Selot1qvJ3fJx-U80vqbQR8hcQ5zW7YJ777befYhx5LTxSgVCq4jpK60jowMzWaZ3CPl5w1rwWCEUWkq9D0dj40FYcIetyJkEXcC-YoFPFjGE_islCE0G0H7p9XoF5Vj08lEexiJ0NpxNJg-Ya8O_IG7R1DuM85lk1hI6tI7Xe16J3x7XW2dIMrs8HBj-asmxYF66NUeJDj-yThZAkkUYVkLTSm_CVP06sq25NfoX5u74SWgqVC49x7eNR5ZJ_ISK0LR22KpIMqFtOgg_3br4Vus4Kqun29vJw0-STC4lJGx5i01dNN8NXLMeOEJTbw2haSZCqHoeRBakIM8JTV-G_XW_25RC-ZdmqTyhaadzMrxY3mo4is7JOBMuyIh1cu0MYqykkyR9kky6oU3r27XUezTrTHvF1xfor5wRqnzAIjRgpwWPsF4SMdLJS3nkntQl5ExBF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