使用LTO导致对std :: basic_string析构函数的未定义引用

时间:2019-07-19 18:40:59

标签: c++ gcc c++17 ld lto

决定在我的构建中尝试使用LTO(CentOS 7,CMake 3.14.3,gcc 8.2.1,-std=c++17):

# this adds "-flto -fno-fat-lto-objects"
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)

除以下项目外,所有项目均可正常运行

/home/user/vcpkg/installed/x64-linux/lib/libazurestorage.a(operation_context.cpp.o): In function `_GLOBAL__sub_I_operation_context.cpp':
operation_context.cpp:(.text.startup+0x9c): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/home/user/vcpkg/installed/x64-linux/lib/libazurestorage.a(cloud_block_blob.cpp.o): In function `_GLOBAL__sub_I_cloud_block_blob.cpp':
cloud_block_blob.cpp:(.text.startup+0x9c): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/home/user/vcpkg/installed/x64-linux/lib/libazurestorage.a(cloud_blob_container.cpp.o): In function `_GLOBAL__sub_I_cloud_blob_container.cpp':
cloud_blob_container.cpp:(.text.startup+0x9c): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/home/user/vcpkg/installed/x64-linux/lib/libazurestorage.a(cloud_blob_shared.cpp.o): In function `_GLOBAL__sub_I_cloud_blob_shared.cpp':
cloud_blob_shared.cpp:(.text.startup+0x9c): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/home/user/vcpkg/installed/x64-linux/lib/libazurestorage.a(cloud_blob_ostreambuf.cpp.o): In function `_GLOBAL__sub_I_cloud_blob_ostreambuf.cpp':
cloud_blob_ostreambuf.cpp:(.text.startup+0x9c): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/home/user/vcpkg/installed/x64-linux/lib/libazurestorage.a(cloud_blob_client.cpp.o):cloud_blob_client.cpp:(.text.startup+0x9c): more undefined references to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' follow
collect2: error: ld returned 1 exit status

由于vcpkg提供的一些神秘原因libazurestorage.a(在没有 LTO的情况下构建)无法解析std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()(并且只有该符号!)。

要使其变得更加有趣-使用libazurestorage.a的其他项目也可以正常构建。我已经检查了链接器的cmdline,它们看起来几乎是相同的(几乎相同的一组lib,几乎相同的顺序)。

任何想法可能有什么问题吗?还是如何弄清楚为什么其他项目可以正常构建?

0 个答案:

没有答案