<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/112430>112430</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Memory sanitizer on shared library issue
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          VA-GS
      </td>
    </tr>
</table>

<pre>
    Hello, is there a way to make a shared library built with Memory sanitizer that is importable from Python ? I tried with Pybind11 and I am getting either undefined symbols on the import or if I link libclang_rt.msan-x86_64.a explicitly, I get `relocation R_X86_64_TPOFF32 against __msan::is_in_symbolizer_or_unwinder cannot be used with -shared`.

To keep it simple, the example below does not add Pybind11 to the mix:
```
/*
clang++ -o msan_test.so -shared -fsanitize=memory msan_test.cpp -fuse-ld=lld -stdlib=libc++ -v -Wl,-v

python -c "import msan_test"
undefined symbol: __msan_init

clang++ -o msan_test.so -shared -fsanitize=memory msan_test.cpp -fuse-ld=lld -stdlib=libc++ -v -Wl,-v /usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.msan-x86_64.a
relocation R_X86_64_TPOFF32 against msan_expect_umr cannot be used with -shared
*/
int main() {
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVEGPszYQ_TXmMiICm5DlwGH3i2j3UHXVfmp7QwZPwnSNjWyzSfrrKwP5drWtqt4-KYoYPDy_N-_Z0ns6G8Sa7Z_Y_pjIOQzW1b89pj_8mnRW3eofUWvL-BcgD2FAhyDhIm8QLIzyNVZ-kA4VaOqcdDfoZtIBLhQG-AlH627gpaFAf6GDMMgQgWicrAuy0wgnZ0d4uYXBGmCigWcIjlCtAC-3jozKc5BGwTPIEc4YApkzIEUyMBuFJzKowN_GzmoP1kSa2w5gHdAJnkGTeY0Mey3NuXVhN3pp0utD2ZbFTgJeJ009BX2LSp_jLsDKzKG2vQxkDfzS_rE0t19ffm4awUGeJRkfoG0jFBOPTDySb8m0K5Oot7Wunc2FjEIHvTTGBugQZn_Xl66zY2W2Y9mRZY_r_1cLr4gTUABP46Qxsoqq8CpjCR1qewFl0UPElEq9jyrYpXWkayS1opbZ9ltL3jC-LS0DYfyJ8SdILUQtbUAfdt7e2UF6ujvIxHFcPX1v7KcJ0tPsMdWKiaPWClIflKYuVtT1d_Q3SH_XjH9J3z5qnVbr0x4Y55tr38AZ52vXZ5-ZeNwm35Kh8BHwuygCxpvZO8ab2MUbrd_GNH_4Vm-kmg-vNJn5ulb_nspVzv_J4EIdrxP2oZ3H_47aloAlBMszmQCjJMP4A-MVsMPT1nM4fkpPomqhKlHJBOv8wKuMC14WyVD3J152kotKVYdC9HuRZaeiOsgsk3lXin1CNc94kWf5nmd5wYtdL8qyrKr-UB6EOKBgRYajJL2Lg9tZd07I-xnrPOeFyBItO9R-uaQ4N3iBZTWmY39MXL1Mu5vPnhWZJh_8O0ygoLH-x0Vkzedra0FMZqfrIYTJx7MTj0lzpjDM3a6342br3d3J2T-xD4w3y6c-uruyfav53wEAAP__MmG6hg">