Nheko-Reborn / mtxclient

Client API library for Matrix, built on top of libcurl
MIT License
40 stars 25 forks source link

Tests don't compile with -flto #80

Closed tastytea closed 1 year ago

tastytea commented 2 years ago

Compiling mtxclient with -flto works fine, but compiling the tests fails:

build failure log ``` [86/91] : && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wall -Wextra -pipe -pedantic -fsized-deallocation -fdiagnostics-color=always -Wno-attributes -Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/messages.dir/tests/messages.cpp.o -o messages -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build libmatrix_client.so.0.8.0 /usr/lib64/libspdlog.so.1.10.0 /usr/lib64/libfmt.so.9.0.0 -Wl,--as-needed /usr/lib64/libcoeurl.so /usr/lib64/libssl.so /usr/lib64/libcrypto.so /usr/lib64/libolm.so.3.2.12 /usr/lib64/libgtest_main.so.1.11.0 /usr/lib64/libgtest.so.1.11.0 && : FAILED: messages : && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wall -Wextra -pipe -pedantic -fsized-deallocation -fdiagnostics-color=always -Wno-attributes -Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/messages.dir/tests/messages.cpp.o -o messages -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build libmatrix_client.so.0.8.0 /usr/lib64/libspdlog.so.1.10.0 /usr/lib64/libfmt.so.9.0.0 -Wl,--as-needed /usr/lib64/libcoeurl.so /usr/lib64/libssl.so /usr/lib64/libcrypto.so /usr/lib64/libolm.so.3.2.12 /usr/lib64/libgtest_main.so.1.11.0 /usr/lib64/libgtest.so.1.11.0 && : lto-wrapper: warning: using serial compilation of 4 LTRANS jobs lto-wrapper: note: see the ‘-flto’ option documentation for more information /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/ccM7FmFB.ltrans1.ltrans.o: in function `RoomEvents_Encrypted_Test::TestBody()': :(.text+0x5d3a): undefined reference to `void mtx::events::from_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > > const&, mtx::events::RoomEvent&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: :(.text+0x5ea5): undefined reference to `void mtx::events::to_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > >&, mtx::events::RoomEvent const&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: :(.text+0x6388): undefined reference to `void mtx::events::to_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > >&, mtx::events::RoomEvent const&)' collect2: error: ld returned 1 exit status [87/91] : && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wall -Wextra -pipe -pedantic -fsized-deallocation -fdiagnostics-color=always -Wno-attributes -Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/requests.dir/tests/requests.cpp.o -o requests -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build libmatrix_client.so.0.8.0 /usr/lib64/libspdlog.so.1.10.0 /usr/lib64/libfmt.so.9.0.0 -Wl,--as-needed /usr/lib64/libcoeurl.so /usr/lib64/libssl.so /usr/lib64/libcrypto.so /usr/lib64/libolm.so.3.2.12 /usr/lib64/libgtest_main.so.1.11.0 /usr/lib64/libgtest.so.1.11.0 && : lto-wrapper: warning: using serial compilation of 3 LTRANS jobs lto-wrapper: note: see the ‘-flto’ option documentation for more information [88/91] : && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wall -Wextra -pipe -pedantic -fsized-deallocation -fdiagnostics-color=always -Wno-attributes -Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/events.dir/tests/events.cpp.o -o events -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build libmatrix_client.so.0.8.0 /usr/lib64/libspdlog.so.1.10.0 /usr/lib64/libfmt.so.9.0.0 -Wl,--as-needed /usr/lib64/libcoeurl.so /usr/lib64/libssl.so /usr/lib64/libcrypto.so /usr/lib64/libolm.so.3.2.12 /usr/lib64/libgtest_main.so.1.11.0 /usr/lib64/libgtest.so.1.11.0 && : FAILED: events : && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wall -Wextra -pipe -pedantic -fsized-deallocation -fdiagnostics-color=always -Wno-attributes -Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/events.dir/tests/events.cpp.o -o events -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build libmatrix_client.so.0.8.0 /usr/lib64/libspdlog.so.1.10.0 /usr/lib64/libfmt.so.9.0.0 -Wl,--as-needed /usr/lib64/libcoeurl.so /usr/lib64/libssl.so /usr/lib64/libcrypto.so /usr/lib64/libolm.so.3.2.12 /usr/lib64/libgtest_main.so.1.11.0 /usr/lib64/libgtest.so.1.11.0 && : lto-wrapper: warning: using serial compilation of 8 LTRANS jobs lto-wrapper: note: see the ‘-flto’ option documentation for more information /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationRequest_Test::TestBody()': :(.text+0x2c35): undefined reference to `void mtx::events::from_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > > const&, mtx::events::Event&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: :(.text+0x3024): undefined reference to `void mtx::events::to_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > >&, mtx::events::Event const&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationStart_Test::TestBody()': :(.text+0x3f30): undefined reference to `void mtx::events::from_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > > const&, mtx::events::Event&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationAccept_Test::TestBody()': :(.text+0x4a13): undefined reference to `void mtx::events::from_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > > const&, mtx::events::Event&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: :(.text+0x4e49): undefined reference to `void mtx::events::to_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > >&, mtx::events::Event const&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationKey_Test::TestBody()': :(.text+0x54f9): undefined reference to `void mtx::events::from_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > > const&, mtx::events::Event&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: :(.text+0x5672): undefined reference to `void mtx::events::to_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > >&, mtx::events::Event const&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationMac_Test::TestBody()': :(.text+0x5c3a): undefined reference to `void mtx::events::from_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > > const&, mtx::events::Event&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: :(.text+0x6085): undefined reference to `void mtx::events::to_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > >&, mtx::events::Event const&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationReady_Test::TestBody()': :(.text+0x6725): undefined reference to `void mtx::events::from_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > > const&, mtx::events::Event&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationDone_Test::TestBody()': :(.text+0x6f42): undefined reference to `void mtx::events::from_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > > const&, mtx::events::Event&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationCancel_Test::TestBody()': :(.text+0x748f): undefined reference to `void mtx::events::from_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > > const&, mtx::events::Event&)' /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: :(.text+0x7688): undefined reference to `void mtx::events::to_json(nlohmann::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector > >&, mtx::events::Event const&)' collect2: error: ld returned 1 exit status [89/91] : && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wall -Wextra -pipe -pedantic -fsized-deallocation -fdiagnostics-color=always -Wno-attributes -Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/responses.dir/tests/responses.cpp.o -o responses -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build libmatrix_client.so.0.8.0 /usr/lib64/libspdlog.so.1.10.0 /usr/lib64/libfmt.so.9.0.0 -Wl,--as-needed /usr/lib64/libcoeurl.so /usr/lib64/libssl.so /usr/lib64/libcrypto.so /usr/lib64/libolm.so.3.2.12 /usr/lib64/libgtest_main.so.1.11.0 /usr/lib64/libgtest.so.1.11.0 && : lto-wrapper: warning: using serial compilation of 7 LTRANS jobs lto-wrapper: note: see the ‘-flto’ option documentation for more information ```

Full build log: https://861731.bugs.gentoo.org/attachment.cgi?id=795278 Gentoo bug: https://bugs.gentoo.org/861731

I don't think anyone needs optimized tests but i thought you may want to know about it. 😊

deepbluev7 commented 2 years ago

Do versions before 0.8.0 compile fine with LTO?

tastytea commented 2 years ago

Previously there were no automated tests for it and i didn't test it manually either. But when i compile it now, 0.7.0 fails in the same way: mtxclient-0.7.0:20220819-222802.log

deepbluev7 commented 2 years ago

Okay, so it is not a regression from the hidden friends at least :D