-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[MSVC] Error "relocation against symbol in discarded section: $LN" linking against prebuilt Firebase C++ SDK #62182
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
Comments
@llvm/issue-subscribers-lld-coff |
@llvm/issue-subscribers-lld-coff are there any linker flags I could try to work around this issue, or anything else that would help to debug this further? Thanks! 🙏 |
I'm fairly certain that the symbols being referenced are debug symbol references. It seems that |
The current release of firebase is built in a way that makes debugging impossible as trying to use DWARF debug information would yield undefined symbols (see firebase/firebase-cpp-sdk#793, llvm/llvm-project#62182).
The current release of firebase is built in a way that makes debugging impossible as trying to use DWARF debug information would yield undefined symbols (see firebase/firebase-cpp-sdk#793, llvm/llvm-project#62182).
Thanks @compnerd, so if I understand correctly you suspect this is to be a bug in lld-link? Any idea why this might be happening with these libraries specifically, and is there anything Firebase could change in the build process to prevent this? |
The RelWithDebInfo builds emit codeview so that debugging is possible. A pure release build would not. However, we should understand why lld is ending up preserving the line information with -debug:dwarf as well. |
I’ve build a bunch of libraries with Visual Studio using RelWithDebInfo and linked them with lld, and never came across this issue with any other libraries, so it’s still unclear to me what’s special about the Firebase libraries. Do you know if there’s a workaround we could use, e.g. is there a way to strip codeview before linking? |
oh? That’s good to know! I suspect something else is keeping the symbol alive then. That’s good to know.
I’ve been unable to find one, other than rebuilding. There’s no strip utility that’s provided with MSVC, and llvm-strip is meant to work on final binaries though it should work on object files. I’ve had issues with stripping on windows so I tend to avoid using it there. |
|
I’m getting this error when trying to strip these libraries – any ideas?
|
Intriguing! It seems like a |
According to Firebase project’s GitHub Actions workflow they are building with Visual Studio 2022. They do have a somewhat involved build process with multiple internal dependencies, so something in there must be causing this. However when I build the Firebase libraries myself using Visual Studio 2022 the resulting libraries link just fine. Unfortunately I cannot say what exactly I’m doing differently, or whether it might be caused by a different build environment. Regarding the error from llvm-strip there’s issue #53433 (comment) mentioning this:
|
The One thing that stands out is that the referenced COMDATs are all STL related. It might be a mismatch in the version of msvcprt that it was built against and the version being used for the application. |
This looks WinEH related, I'm not seeing a clear indication that this is codeview related. The sections containing the reference are the catch handler sections ( I would try disabling ICF and section GC, so |
Nice catch @rnk! I didn't notice the |
Just verified that |
I used to see this problem a long while ago at Ubisoft, but never got to the end of it. And then it went away. Thanks for the reproducer @triplef ! I managed to take a look at it again and I have a fix. The issue is both a problem in LLD and in MSVC. In LLD, we don't support label symbols (that is the $LN symbols reported by the linker) in the same way that The following small repro is close to triggering the issue, but I can't figure out what makes MSVC to "forget" the COMDAT for
I've posted https://reviews.llvm.org/D157136 |
Just for completeness, the issue is not with MSVC like I wrote previously, but with binutils |
|
Yes, |
Linking an executable built with Clang against the prebuilt Firebase C++ SDK 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 of the Firebase SDK:
firebase-cpp-sdk-test.zip
This was previously also reported as firebase/firebase-cpp-sdk#793, but I believe this is likely a Clang issue.
Full error output
The text was updated successfully, but these errors were encountered: