-
Notifications
You must be signed in to change notification settings - Fork 21
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
Items instantiated in header causes duplicate definitions and link errors #51
Comments
Strange, CI has been passing for the build/run of the tests and I periodically build/run all the draco updated apps... I also just updated to main everywhere and build all the tests with no issues. Ubuntu 20.04. Ideas on what might be different? EDIT - it's possible I'm behind on my *_defs... Note I added the flag locally and the 9 other Draco updated apps compile, so it's just an LC issue. Ubuntu 20.04 is gcc 9.4.0, hopefully the upgrade to 22.04 can be soon. |
Yes, I investigated this a bit and found that it GCC 9.x (w/binutils 2.34) put this symbol by default into a common section, and thus does not trigger the error because it silently merges the duplicate symbols into one. But if you add The newer gcc/binutils seem to have made the Anyway - I think this adequately explains why it didn't fail validation with the way it was, but it needs to be corrected because its very wrong to instantiate objects in a header. |
It does raise the point though - we should probably consider addding FWIW, I don't think VxWorks or RTEMS loaders support common sections at all, so if these tests were built on either of those platforms I'm fairly sure this would fail there too. |
Make the table objects in this header "extern" and instantiate them in the C file instead. This solves the duplicate symbol linker errors.
Fix #51, externalize symbols in lc_test_utils.h
Checklist (Please check before submitting)
Describe the bug
The unit test header file
lc_test_utils.h
instantiates objects directly in the header file, which breaks if it is ever included in more than one C file.To Reproduce
Build LC with unit tests enabled, get lots of linker errors:
Expected behavior
Build should work?
Code snips
LC/unit-test/utilities/lc_test_utils.h
Lines 38 to 43 in 543cf6b
System observed on:
Ubuntu
Additional context
I was just trying to build LC "out of the box" - not modified in any way - and it failed badly. Not sure how this ever built or passed any validation testing with this the way it was.
Reporter Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered: