Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Undefined symbols when using boost statecharts #42322

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR43352
Status NEW
Importance P normal
Reported by Brian Cody (brian.j.cody@gmail.com)
Reported on 2019-09-18 07:26:01 -0700
Last modified on 2021-10-18 11:09:40 -0700
Version unspecified
Hardware PC Windows NT
CC dblaikie@gmail.com, llvm-bugs@lists.llvm.org, MillerHenry@johndeere.com, ruiu@google.com
Fixed by commit(s)
Attachments boost_statechart_missing_symbol.7z (1016 bytes, application/x-7z-compressed)
Blocks
Blocked by
See also
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<evt_done_state> {};
}

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 & ) {}
Quuxplusone commented 5 years ago

a simplified reproduction could be helpful

where is this undefined function called from, such that the linker thinks it's needed at all?

Quuxplusone commented 5 years ago

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.

Quuxplusone commented 5 years ago

Attached boost_statechart_missing_symbol.7z (1016 bytes, application/x-7z-compressed): Small demonstrator

Quuxplusone commented 5 years ago

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.

Quuxplusone commented 5 years ago

I added -reproduce option to lld/MinGW in http://reviews.llvm.org/rL373705. Could you run lld again with the option for me?

Quuxplusone commented 3 years ago

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)

Quuxplusone commented 3 years ago

Note that my reproduction above was on ubuntu linux, an ELF system. I'm not sure how to track it down more.