<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62182>62182</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MSVC] Linker error "relocation against symbol in discarded section: $LN" linking against prebuilt Firebase C++ SDK
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
triplef
</td>
</tr>
</table>
<pre>
Linking an executable built with Clang against the prebuilt [Firebase C++ SDK](https://github.com/firebase/firebase-cpp-sdk/releases) static libraries built using Visual Studio 2022 results in linker errors like:
lld-link: error: relocation against symbol in discarded section: $LN10
This was reproduced with the official Clang 16.0.1 release as well as older Clang releases, and happens both when using clang.exe or the clang-cl driver. Using the Visual Studio compiler and linker works fine.
Here is a minimal sample project using CMake and [v10.7.0](https://github.com/firebase/firebase-cpp-sdk/releases/tag/v10.7.0) of the Firebase SDK:
[firebase-cpp-sdk-test.zip](https://github.com/llvm/llvm-project/files/11251161/firebase-cpp-sdk-test.zip)
This was previously also reported as https://github.com/firebase/firebase-cpp-sdk/issues/793, but I believe this is likely a Clang issue.
**Full error output**
```
cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -fuse-ld=lld-link -nostartfiles -nostdlib -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -Xlinker /subsystem:console CMakeFiles/test.dir/test.cpp.obj -o test.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:test.lib -Xlinker /pdb:test.pdb -Xlinker /version:0.0 C:/Users/frede/Dev/firebase-cpp-sdk-test/firebase_cpp_sdk/libs/windows/VS2019/MD/x64/Debug/firebase_app.lib -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames && cd ."
lld-link: error: relocation against symbol in discarded section: $LN10
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:917
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_util.obj):(__catch$??$_Emplace_reallocate@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEAAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@QEAV21@$$QEAV21@@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN10
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:917
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_variant_util.obj):(__catch$??$_Emplace_reallocate@AEBQEAUNamespace@f_b_flatbuffers@@@?$vector@PEAUNamespace@f_b_flatbuffers@@V?$allocator@PEAUNamespace@f_b_flatbuffers@@@std@@@std@@AEAAPEAPEAUNamespace@f_b_flatbuffers@@QEAPEAU23@AEBQEAU23@@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN36
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:1279
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_variant_util.obj):($LN34)
lld-link: error: relocation against symbol in discarded section: $LN10
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:917
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_variant_util.obj):(__catch$??$_Emplace_reallocate@AEBUValue@Builder@f_b_flexbuffers@@@?$vector@UValue@Builder@f_b_flexbuffers@@V?$allocator@UValue@Builder@f_b_flexbuffers@@@std@@@std@@AEAAPEAUValue@Builder@f_b_flexbuffers@@QEAU234@AEBU234@@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN10
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:917
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_heartbeat_storage_desktop.obj):(__catch$??$_Emplace_reallocate@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEAAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@QEAV21@$$QEAV21@@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN8
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:1608
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_variant_util.obj):(__catch$??$_Resize_reallocate@U_Value_init_tag@std@@@?$vector@EV?$allocator@E@std@@@std@@AEAAX_KAEBU_Value_init_tag@1@@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN10
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:917
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_variant_util.obj):(__catch$??$_Emplace_reallocate@E@?$vector@EV?$allocator@E@std@@@std@@AEAAPEAEQEAE$$QEAE@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN10
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:917
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_variant_util.obj):(__catch$??$_Emplace_reallocate@UValue@Builder@f_b_flexbuffers@@@?$vector@UValue@Builder@f_b_flexbuffers@@V?$allocator@UValue@Builder@f_b_flexbuffers@@@std@@@std@@AEAAPEAUValue@Builder@f_b_flexbuffers@@QEAU234@$$QEAU234@@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN8
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:1608
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_variant_util.obj):(__catch$??$_Resize_reallocate@U_Value_init_tag@std@@@?$vector@UValue@Builder@f_b_flexbuffers@@V?$allocator@UValue@Builder@f_b_flexbuffers@@@std@@@std@@AEAAX_KAEBU_Value_init_tag@1@@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN10
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:917
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_variant_util.obj):(__catch$??$_Emplace_reallocate@VVariant@firebase@@@?$vector@VVariant@firebase@@V?$allocator@VVariant@firebase@@@std@@@std@@AEAAPEAVVariant@firebase@@QEAV23@$$QEAV23@@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN28
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:1221
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_variant_util.obj):(__catch$??$_Insert_counted_range@PEBE@?$vector@EV?$allocator@E@std@@@std@@AEAAXV?$_Vector_const_iterator@V?$_Vector_val@U?$_Simple_types@E@std@@@std@@@1@PEBE_K@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN10
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:917
>>> firebase_app.lib(d3d7d08a438878e74aeb2cbaaedfc967_flatbuffers.dir_Debug_idl_parser.obj):(__catch$??$_Emplace_reallocate@AEBQEAUNamespace@f_b_flatbuffers@@@?$vector@PEAUNamespace@f_b_flatbuffers@@V?$allocator@PEAUNamespace@f_b_flatbuffers@@@std@@@std@@AEAAPEAPEAUNamespace@f_b_flatbuffers@@QEAPEAU23@AEBQEAU23@@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN10
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:917
>>> firebase_app.lib(d3d7d08a438878e74aeb2cbaaedfc967_flatbuffers.dir_Debug_idl_parser.obj):(__catch$??$_Emplace_reallocate@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEAAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@QEAV21@AEBV21@@Z$0)
lld-link: error: relocation against symbol in discarded section: $LN32
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:1255
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_variant_util.obj):($LN30)
lld-link: error: relocation against symbol in discarded section: $LN29
>>> referenced by C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include\vector:1125
>>> firebase_app.lib(d94e1bff3c0e8414a6679ea91c3e103e_firebase_app.dir_Debug_variant_util.obj):(__catch$?insert@?$vector@EV?$allocator@E@std@@@std@@QEAA?AV?$_Vector_iterator@V?$_Vector_val@U?$_Simple_types@E@std@@@std@@@2@V?$_Vector_const_iterator@V?$_Vector_val@U?$_Simple_types@E@std@@@std@@@2@_KAEBE@Z$0)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWk9v27gS_zTMhZAhUZL_HHKQb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