Open llvmbot opened 4 years ago
Note that my reproduction above was on ubuntu linux, an ELF system. I'm not sure how to track it down more.
I was able to reproduce the issue using boost 0.43 (very old, but I'm locked into it for ABI reasons) and clang/llvm 12.0.1. See attached repo.tar file, I assume someone knows how to read them.
The repo.tar file is too large to attach to a bug report though (even compressed), how can I get this to you. (I'm blocked from dropbox and the other obvious places)
I added -reproduce option to lld/MinGW in http://reviews.llvm.org/rL373705. Could you run lld again with the option for me?
I don't have Boost installed on my Windows machine. Looks like you are using lld/MinGW. lld/MinGW lacks the support of --reproduce, so I'll add that option so that you can use that option. I'll update this bug once my patch to add that option is landed.
Small demonstrator Sorry for the delay. I made a minimal example and spent a bit of time over several days trying to figure out why the small example didn't produce the issue. It turned out that the '-g' argument had to be added to the compile step in order to cause the missing symbol.
lld: error: unknown argument: --reproduce=repro.tar
I'm attaching a file with source files and a build batch file. There are two variables to modify in the batch to adjust for your paths. I have not tested on other OS's.
If an input object file contains an undefined symbol that no other object file defines, it is usually an error, even though no one is using that symbol. There are some exceptions though.
Can you run lld with -Wl,--reproduce=repro.tar
? That command creates a tar file containing all input files and the command line options, so that I can run the same command locally with the same input. After that, please share the tar file with me.
a simplified reproduction could be helpful
where is this undefined function called from, such that the linker thinks it's needed at all?
Extended Description
Version 9.0.0 RC5
The same link works in ld. You can use the boost statechart as such:
namespace my_namespace { struct evt_done_state: boost::statechart::event {};
}
lld-link: error: undefined symbol: __ZN5boost10statechart6detail10no_contextIN12my_namespace14evt_done_stateEE11no_funct>>> referenced by (... file path)
Looking at the boost source code, there is declared, undefined function. This was taken from boost 1.63.0, but the specific code is common for older and newer versions: boost\statechart\detail\reaction_dispatcher.hpp:33 template< class Event > struct no_context { void no_function( const Event & ); // <------ };
The method is not called or referenced, and shows up as 'U' in nm. I suspect ld drops the unused, undefined symbol.
We're working around this by changing the offending line to: void no_function( const Event & ) {}