Open triplef opened 2 years ago
The issue can also be reproduced using the auth sample project from quickstart-cpp like this:
-DFIREBASE_CPP_SDK_DIR=<path-to-sdk>
HI @triplef,
It's unclear if this is a build configuration mismatch between the toolchain used to precompile and link the Firebase C++ SDK libraries, and the toolchain you're using to link the final application. Or, it could be a bug in one of the toolchains.
The best way forward to resolve this issue is to build and link the libraries from the source in the repository using the same toolchain you're using in the final app.
I hope this helps!
Hey @triplef. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Thanks for your feedback @DellaBitta. I’ll try building from source and report back after the holidays.
Building from source using the official instructions and Visual Studio 2022 (with MSVC) fixes the linker errors for us. Not sure how our setup would differ from the official builds.
Is there any chance the LLVM toolchain (which is officially supported by Visual Studio) could be supported by this project? We'd much rather use pre-built binaries than having to build ourselves.
Please let me know if there is anything else I can provide towards this.
Hi @triplef
If you need to use LLVM, you will need to build from source. Currently pre-built version does not support it.
Seems like you were able to build it from source with no problem. I will mark it as a FR for now.
I managed to debug and reproduce the issue locally. One one hand, the root issue is caused by the packaging script that uses (binutils) objcopy
which corrupts the output .OBJ when copying it. On the other hand, I have a workaround in LLD, see https://reviews.llvm.org/D157136 (not landed yet). MSVC link.exe seems to support this scenario just fine.
I think if someone was willing to add -L
here https://github.com/firebase/firebase-cpp-sdk/blob/main/.github/workflows/cpp-packaging.yml#L565 and two lines below + update the Ubuntu image to include LLVM, that would fix the issue.
Thank you @aganea for tracking this down! Much appreciated. 🙏
Could you elaborate how the -L
option fixes this and why the Ubuntu image would need LLVM?
-L
makes the packaging script use LLVM binutils instead of the default GNU binutils. LLVM properly supports COFF while GNU doesn't. I've tried the packaging commands with llvm-objcopy
and the final link with lld-link
, like reported in this bug, succeeds fine.
As for the Ubuntu image, the release log points to this image, which doesn't contain the LLVM binutils. LLVM needs to be added if we want -L
to work.
Thanks for the clarification! I’ve opened #1427 with what I think are the required changes.
[REQUIRED] Please fill in the following fields:
[REQUIRED] Please describe the issue here:
Using the LLVM toolchain (specifically lld-link) instead of MSVC (link.exe) results in linker errors "relocation against symbol in discarded section: ..." from lld-link (see logs below).
Using link.exe instead of lld-link works fine, and it does not matter whether the source was built with MSVC or clang-cl.
As we have technical requirements to use lld-link in our projects and this is blocking us from using the Firebase C++ SDK.
Steps to reproduce with sample project:
Steps to reproduce manually:
Error Logs