Swift Package produces mangled "undefined symbol" errors

Hello,

I have been trying to link statically a hand-built C++ library.

I'm using SPM with a C++ target with LinkerSettings.unsafeFlags and CXXSettings.unsafeFlags. If I won't provide a -lboost_filesystem linker flag, swift build ends with following result:

# SPM swiftc output
Undefined symbols for architecture arm64:
  "__ZN5boost10filesystem4path9append_v3EPKcS3_", referenced from:
      __ZN3pcl9MTLReader4readERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_ in libpcl_io.a(obj_io.cpp.o)
      __ZN3pcl9MTLReader4readERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE in libpcl_io.a(obj_io.cpp.o)

notice, that all the symbols are mangled C++.

If I use swift package generate-xcodeproj and try to build the same project using Xcode, build will result in following output:

# Xcode clang++ output
Undefined symbols for architecture arm64:
  "boost::filesystem::path::append_v3(char const*, char const*)", referenced from:
      pcl::MTLReader::read(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libpcl_io.a(obj_io.cpp.o)
      pcl::MTLReader::read(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libpcl_io.a(obj_io.cpp.o)

all the symbols are human-readable.

I have tried to find what are the differences between Xcode and SPM and I haven't found a solution.

Is there a simple fix for this? Some flag that I should provide to SPM? Or is this a bug?