apolukhin / Boost.DLL

Library for comfortable work with DLL and DSO
https://boost.org/libs/dll
110 stars 69 forks source link

Problems with de-mangled names (Linux) #67

Open loopless opened 6 months ago

loopless commented 6 months ago

Using Boost 1.83.0 Using boost::dll::experimental::smart_library Calling get_function(name)

The library does not seem to be generating correct de-mangled names for a C++ function, so it fails to find a "match" in the actual .so This is only occurring on Linux, on Windows there are no issues. On Linux we are compiling with _GLIBCXX_USE_CXX11_ABI=1

The C++ prototype is

Run (
    std::string const&          filename,
    bool const&          flag,
    std::size_t const           numThreads,
    std::atomic< bool > const&  stopToken,
    std::vector<int64_t> const& selected);

The actual signature is as follows ( using nm to query the .so )

Run( std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool const&, unsigned long, std::atomic<bool> const&, std::vector<long, std::allocator<long> > const&)

When compiled with the Intel ICX (clang) compiler, smart_library makes a mistake with the std::string type smart_library sees the first parameter as std::basic_string ( not std::__cxx11::basic_string) Run( std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool const&, unsigned long, std::atomic<bool> const&, std::vector<long"...

When compiled with gcc 11 , it gets the "string" type correct, but comes up with "long unsigned int" as the 4th parameter ( which is size_t)

Run(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool const&, long unsigned int, std::atomic<bool> const&, std"...

I am able to see the failures in the function template<typename Func> std::string mangled_storage_impl::get_function(const std::string &name) const