spdlog issues with CMAKE_INTERPROCEDURAL_OPTIMIZATION
Closed this issue · 3 comments
akallabeth commented
On Mac OS:
- check out spdlog (did use ad725d3 )
cmake -GNinja -Bxxx -S. -DCMAKE_INSTALL_PREFIX=/tmp/xxx -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DBUILD_SHARED_LIBS=ONcmake --build xxx --target install- linking fails:
17:14 $ cmake --build xxx/ --target install
[11/12] Linking CXX executable example/example
FAILED: example/example
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -O3 -DNDEBUG -flto=thin -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names example/CMakeFiles/example.dir/example.cpp.o -o example/example -Wl,-rpath,/Users/dev/src/spdlog/xxx libspdlog.1.15.3.dylib && :
Undefined symbols for architecture x86_64:
"spdlog::sinks::base_sink<std::__1::mutex>::set_pattern(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)", referenced from:
vtable for spdlog::sinks::base_sink<std::__1::mutex> in
vtable for spdlog::sinks::daily_file_sink<std::__1::mutex, spdlog::sinks::daily_filename_calculator> in
vtable for spdlog::sinks::callback_sink<std::__1::mutex> in
vtable for spdlog::sinks::udp_sink<std::__1::mutex> in
"spdlog::sinks::base_sink<std::__1::mutex>::set_pattern_(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)", referenced from:
vtable for spdlog::sinks::base_sink<std::__1::mutex> in
vtable for spdlog::sinks::daily_file_sink<std::__1::mutex, spdlog::sinks::daily_filename_calculator> in
vtable for spdlog::sinks::callback_sink<std::__1::mutex> in
vtable for spdlog::sinks::udp_sink<std::__1::mutex> in
"spdlog::sinks::base_sink<std::__1::mutex>::set_formatter(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter>>)", referenced from:
vtable for spdlog::sinks::base_sink<std::__1::mutex> in
vtable for spdlog::sinks::daily_file_sink<std::__1::mutex, spdlog::sinks::daily_filename_calculator> in
vtable for spdlog::sinks::callback_sink<std::__1::mutex> in
vtable for spdlog::sinks::udp_sink<std::__1::mutex> in
"spdlog::sinks::base_sink<std::__1::mutex>::set_formatter_(std::__1::unique_ptr<spdlog::formatter, std::__1::default_delete<spdlog::formatter>>)", referenced from:
vtable for spdlog::sinks::base_sink<std::__1::mutex> in
vtable for spdlog::sinks::daily_file_sink<std::__1::mutex, spdlog::sinks::daily_filename_calculator> in
vtable for spdlog::sinks::callback_sink<std::__1::mutex> in
vtable for spdlog::sinks::udp_sink<std::__1::mutex> in
"spdlog::sinks::base_sink<std::__1::mutex>::log(spdlog::details::log_msg const&)", referenced from:
vtable for spdlog::sinks::base_sink<std::__1::mutex> in
vtable for spdlog::sinks::daily_file_sink<std::__1::mutex, spdlog::sinks::daily_filename_calculator> in
vtable for spdlog::sinks::callback_sink<std::__1::mutex> in
vtable for spdlog::sinks::udp_sink<std::__1::mutex> in
"spdlog::sinks::base_sink<std::__1::mutex>::flush()", referenced from:
vtable for spdlog::sinks::base_sink<std::__1::mutex> in
vtable for spdlog::sinks::daily_file_sink<std::__1::mutex, spdlog::sinks::daily_filename_calculator> in
vtable for spdlog::sinks::callback_sink<std::__1::mutex> in
vtable for spdlog::sinks::udp_sink<std::__1::mutex> in
"spdlog::sinks::base_sink<std::__1::mutex>::base_sink()", referenced from:
_main in
_main in
_main in
ld: symbol(s) not found for architecture x86_64
c++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
akallabeth commented
looks like the export table is broken when turned on:
17:37 $ nm xxx/libspdlog.dylib |grep base_sink
000000000000e3d0 t __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE11set_patternERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE
000000000000e0c0 t __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE12set_pattern_ERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE
000000000000e3e0 t __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE13set_formatterENSt3__110unique_ptrINS_9formatterENS5_14default_deleteIS7_EEEE
000000000000e2c0 t __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE14set_formatter_ENSt3__110unique_ptrINS_9formatterENS5_14default_deleteIS7_EEEE
000000000000e3b0 t __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE3logERKNS2_7log_msgE
000000000000e3c0 t __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE5flushEv
000000000000e380 T __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEEC2ENSt3__110unique_ptrINS_9formatterENS5_14default_deleteIS7_EEEE
000000000000e2f0 T __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEEC2Ev
000000000000e4e0 t __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEED0Ev
000000000000e4e0 t __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEED1Ev
000000000000dfe0 t __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE11set_patternERKNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE
000000000000e0c0 t __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE12set_pattern_ERKNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE
000000000000e030 t __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE13set_formatterENS2_10unique_ptrINS_9formatterENS2_14default_deleteIS6_EEEE
000000000000e2c0 t __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE14set_formatter_ENS2_10unique_ptrINS_9formatterENS2_14default_deleteIS6_EEEE
000000000000df50 t __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE3logERKNS_7details7log_msgE
000000000000dfa0 t __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE5flushEv
000000000000df00 T __ZN6spdlog5sinks9base_sinkINSt3__15mutexEEC2ENS2_10unique_ptrINS_9formatterENS2_14default_deleteIS6_EEEE
000000000000de50 t __ZN6spdlog5sinks9base_sinkINSt3__15mutexEEC2Ev
000000000000e4e0 t __ZN6spdlog5sinks9base_sinkINSt3__15mutexEED0Ev
000000000000e4e0 t __ZN6spdlog5sinks9base_sinkINSt3__15mutexEED1Ev
000000000002f440 t __ZN6spdlog5sinks9base_sinkINSt3__15mutexEED2Ev
0000000000053798 S __ZTIN6spdlog5sinks9base_sinkINS_7details10null_mutexEEE
0000000000053780 S __ZTIN6spdlog5sinks9base_sinkINSt3__15mutexEEE
000000000004b210 S __ZTSN6spdlog5sinks9base_sinkINS_7details10null_mutexEEE
000000000004b1e6 S __ZTSN6spdlog5sinks9base_sinkINSt3__15mutexEEE
00000000000536f8 s __ZTVN6spdlog5sinks9base_sinkINS_7details10null_mutexEEE
0000000000053698 s __ZTVN6spdlog5sinks9base_sinkINSt3__15mutexEEE
public symbols with internal linkage, not sure how to fix that (the class is annotated with SPDLOG_API )
akallabeth commented
so, here is a comparison of all global symbols between lto and nolto: (created with nm -g xxx/libspdlog.dylib |tee lto.txt and then first column deleted for the diff)
diff lto.txt nolto.txt
187a188,193
> T __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE11set_patternERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE
> T __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE12set_pattern_ERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE
> T __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE13set_formatterENSt3__110unique_ptrINS_9formatterENS5_14default_deleteIS7_EEEE
> T __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE14set_formatter_ENSt3__110unique_ptrINS_9formatterENS5_14default_deleteIS7_EEEE
> T __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE3logERKNS2_7log_msgE
> T __ZN6spdlog5sinks9base_sinkINS_7details10null_mutexEE5flushEv
189a196,201
> T __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE11set_patternERKNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE
> T __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE12set_pattern_ERKNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE
> T __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE13set_formatterENS2_10unique_ptrINS_9formatterENS2_14default_deleteIS6_EEEE
> T __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE14set_formatter_ENS2_10unique_ptrINS_9formatterENS2_14default_deleteIS6_EEEE
> T __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE3logERKNS_7details7log_msgE
> T __ZN6spdlog5sinks9base_sinkINSt3__15mutexEE5flushEv
190a203
> T __ZN6spdlog5sinks9base_sinkINSt3__15mutexEEC2Ev
211a225
> T __ZN6spdlog6loggerC2IPKNSt3__110shared_ptrINS_5sinks4sinkEEEEENS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEET_SF_
358d371
< U __ZNKSt11logic_error4whatEv
360d372
< U __ZNKSt3__112bad_weak_ptr4whatEv
368d379
< U __ZNSt12length_errorD0Ev
370d380
< U __ZNSt12out_of_rangeD0Ev
380d389
< U __ZNSt3__112bad_weak_ptrD0Ev
725a735,736
> S __ZTVN6spdlog5sinks9base_sinkINS_7details10null_mutexEEE
> S __ZTVN6spdlog5sinks9base_sinkINSt3__15mutexEEE
tt4g commented
LTO is a compiler feature, it is probably a compiler bug.
There have been several reports of LTO not working on Mac OS.