-
Notifications
You must be signed in to change notification settings - Fork 232
Build with clang-cl/lld-link fails due to missing symbol #1405
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
What build options did you use when building the VSG? Could you send a PR with your changes so I can review and merge the fix. |
Probably just the default. I don't see anything of relevance in the below cmd line:
No I don't think the fix is what you want to use. Here is the diff either way:
Although I only observed it for std::string it probably also occurs for all other types if the |
The diff looks impractical long term. Other compilers have been working fine for years with the code as is, so could there be an issue with the version of clang and CMake? |
No, how often is the Compiler actually wrong? What does that even have to do with CMake? The Code is wrong, the compiler is free to optimize the symbol away since it is a template and thus implicitly inline. So there are two cases here: 1) The case where a TU sees So how did it work fine for all those years? The code wasn't fully optimized.....probably because it is only tested with MSVC on windows? Solutions? (one of the following) but i am no language, compiler or linker lawyer, that is just my interpretation of what is happening. |
The VSG is compiled in Linux, Windows and macOS with GCC, clang and Visual
Studio with a range of CMake version and various versions of the compilers.
Your are the first to hit this particular problem so figuring out which
combination of compiler, CMake and settings will help us figure why it's an
issue on your system and what the most appropriate fix would be.
…On Tue, 25 Feb 2025, 12:05 Alexander Neumann, ***@***.***> wrote:
Other compilers have been working fine for years with the code as is, so
could there be an issue with the version of clang and CMake?
No, how often is the Compiler actually wrong? What does that even have to
do with CMake?
The Code is wrong, the compiler is free to optimize the symbol away since
it is a template and thus implicitly inline. So there are two cases here:
1) The case where a TU sees Value.h and Object.h and can create/inline
setValue and 2) the case where a TU only sees the declaration in Object.h.
In the latter case a call to setValue is emitted and the linker has to
figure it out. If all the TUs seeing case 1) inline setValue no symbol
for it is emitted which leaves the TUs seeing case 2) complaining about the
missing symbol since no TU has it.
So how did it work fine for all those years? The code wasn't fully
optimized.....probably because it is only tested with MSVC on windows?
Solutions? (one of the following)
a) avoid separating of Value.h from Object.h, either make it one header or
move the required definition of Object::setValue actually into Object.h
(instead of having it in Value.h which creates the problem)
b) create a single TU which explicitly instantiate all the possible symbols
c) make sure every user of setValue includes Object.h AND Value.h
but i am no language, compiler or linker lawyer, that is just my
interpretation of what is happening.
—
Reply to this email directly, view it on GitHub
<#1405 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKEGUHPWESBG667DQULTWT2RRMB7AVCNFSM6AAAAABXWV2UHOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBRG42DEMRTHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
[image: Neumann-A]*Neumann-A* left a comment
(vsg-dev/VulkanSceneGraph#1405)
<#1405 (comment)>
Other compilers have been working fine for years with the code as is, so
could there be an issue with the version of clang and CMake?
No, how often is the Compiler actually wrong? What does that even have to
do with CMake?
The Code is wrong, the compiler is free to optimize the symbol away since
it is a template and thus implicitly inline. So there are two cases here:
1) The case where a TU sees Value.h and Object.h and can create/inline
setValue and 2) the case where a TU only sees the declaration in Object.h.
In the latter case a call to setValue is emitted and the linker has to
figure it out. If all the TUs seeing case 1) inline setValue no symbol
for it is emitted which leaves the TUs seeing case 2) complaining about the
missing symbol since no TU has it.
So how did it work fine for all those years? The code wasn't fully
optimized.....probably because it is only tested with MSVC on windows?
Solutions? (one of the following)
a) avoid separating of Value.h from Object.h, either make it one header or
move the required definition of Object::setValue actually into Object.h
(instead of having it in Value.h which creates the problem)
b) create a single TU which explicitly instantiate all the possible symbols
c) make sure every user of setValue includes Object.h AND Value.h
but i am no language, compiler or linker lawyer, that is just my
interpretation of what is happening.
—
Reply to this email directly, view it on GitHub
<#1405 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKEGUHPWESBG667DQULTWT2RRMB7AVCNFSM6AAAAABXWV2UHOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOBRG42DEMRTHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hi, @Neumann-A I think it is very productive when you make concrete suggestions without too many assumptions. Please be assured that this project (and related projects) has a long history on Unix platforms, and so not as you suggested. If you describe what and how you tried out things, we can support you. |
I am only speaking about Windows. Feel free to give #1407 a spin in CI. I expect it to reproduce the error if it does not the next line might need a |
Yep same error in your CI:
(might need to deactivate some warnings though to get a smaller log.) |
As a bit more context to try and make sure everyone's on the same page:
Some cusory googling suggests that CMake sets the compiler ID for As for the error, it looks like it's just another self-sufficient header problem like I've been complaining about for a while, just a more complicated variant. Neumann-A's explanation of the mechanics of the problem seems to be basically correct - it's legitimate for the compiler to not expose the implementation of |
You can avoid the problem this issue is tracking by using MSVC or GCC or regular Clang for Windows builds. This issue's tracking a problem that's specific to clang-cl, and most of the time (excluding problems like this one) it's a drop-in replacement for MSVC and vice versa, so provided it's not for commercial use or you're willing to pay for it, the easiest way to avoid being affected is to just use MSVC instead of clang-cl. Every other library in your project can still use clang-cl. If you're having trouble with regular Clang instead of specifically clang-cl, this issue report isn't the place to discuss it. |
Error:
Probably a include is missing since the definition of the functions is in
Value.h
and notObject.h
. I fixed it by explicitly instantiating the function inObject.cpp
(and includingValue.h
of course)The text was updated successfully, but these errors were encountered: