hrsakai opened a new pull request #1997: Fix: set visibility,exclude-libs options to CMAKE_CXX_FLAGS URL: https://github.com/apache/incubator-pulsar/pull/1997 ### Motivation Currently, we can't set `-fvisibility=hidden -Wl,--exclude-libs,ALL`options to MAKE_CXX_FLAGS. Also, I got below error logs when I execute unit test using `libpulsar.so` compiled with `-exclude-libs,ALL` option. ``` CMakeFiles/main.dir/AuthPluginTest.cc.o: In function `AuthPluginTest_testTls_Test::TestBody()': /pulsar/pulsar-client-cpp/tests/AuthPluginTest.cc:52: undefined reference to `pulsar::AuthTls::create(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' CMakeFiles/main.dir/AuthPluginTest.cc.o: In function `AuthPluginTest_testAthenz_Test::TestBody()': /pulsar/pulsar-client-cpp/tests/AuthPluginTest.cc:163: undefined reference to `pulsar::AuthAthenz::create(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' CMakeFiles/main.dir/ZTSClientTest.cc.o: In function `pulsar::ZTSClientWrapper::parseUri(char const*)': /pulsar/pulsar-client-cpp/tests/ZTSClientTest.cc:28: undefined reference to `pulsar::ZTSClient::parseUri(char const*)' /pulsar/pulsar-client-cpp/tests/ZTSClientTest.cc:28: undefined reference to `pulsar::ZTSClient::parseUri(char const*)' /pulsar/pulsar-client-cpp/tests/ZTSClientTest.cc:28: undefined reference to `pulsar::ZTSClient::parseUri(char const*)' /pulsar/pulsar-client-cpp/tests/ZTSClientTest.cc:28: undefined reference to `pulsar::ZTSClient::parseUri(char const*)' /pulsar/pulsar-client-cpp/tests/ZTSClientTest.cc:28: undefined reference to `pulsar::ZTSClient::parseUri(char const*)' collect2: error: ld returned 1 exit status tests/CMakeFiles/main.dir/build.make:785: recipe for target 'tests/main' failed make[2]: *** [tests/main] Error 1 CMakeFiles/Makefile2:828: recipe for target 'tests/CMakeFiles/main.dir/all' failed make[1]: *** [tests/CMakeFiles/main.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2 ``` ### Modifications * set `visibility,exclude-libs` options correctly. * add `Add GCC visibility push(default)` to header files for unit test. * include auth codes in libpulsar instead of creating auth static libraries to fix above error. ### Result We can compile pulsar cpp codes with `-fvisibility=hidden -Wl,--exclude-libs,ALL`. ``` before $ nm -D -C ./pulsar-client-cpp/lib/libpulsar.so.2.1.0-incubating-SNAPSHOT |wc -l 23006 after $ nm -D -C ./pulsar-client-cpp/lib/libpulsar.so.2.1.0-incubating-SNAPSHOT |wc -l 6543 ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
