IBM / gWhisper

A gRPC CLI featuring reflection and tab-completion
Apache License 2.0
58 stars 15 forks source link

Build error on macOS #153

Open remcg opened 2 months ago

remcg commented 2 months ago

Describe the bug Running the build with the default configuration using build.sh fails with the error

ld: unknown options: --push-state --no-as-needed --whole-archive --pop-state clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [bin/testServer] Error 1 make[1]: [tests/testServer/CMakeFiles/testServer.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....

To Reproduce Run build.sh

Expected behavior Build completes without eerror

Provide details about your environment

Additional context Full log attached. Retried the build with the test server turned off using the command cmake .. -D GWHISPER_BUILD_TESTSERVER=OFF

This time got another linker error

[100%] Linking CXX static library libcli.a [100%] Built target cli [100%] Generating HelpString.h [100%] Building CXX object src/gwhisper/CMakeFiles/gwhisper.dir/gwhisper.cpp.o [100%] Linking CXX executable ../../bin/gwhisper ld: warning: ignoring duplicate libraries: '../../third_party/gRPC_utils/libreflection.a', '../libArgParse/libArgParse.a', '../libCli/libcli.a', '../libLocalDescriptorCache/libDescDbProxy.a' ld: library 'stdc++fs' not found clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [bin/gwhisper] Error 1 make[1]: [src/gwhisper/CMakeFiles/gwhisper.dir/all] Error 2 make: *** [all] Error 2

Work around: Commented out stdc++fs in src/libLocalDescriptorCache/CMakeLists.txt and src/utils/CMakeLists.txt to be able to build gwhisper binary. build.log

rainerschoe commented 1 month ago

Thanks for reporting.

Unfortunately I do not have a MacOS test environment. But thanks to your clear error description I see two issues:

  1. Unsupported Linker options when linking gRPC reflection libs. using the official gRPC examples as a reference, I see we need to handle Darwin specially.
  2. An issue around linking standard filesystems library. This is actually only required for old compilers and can be omitted for most modern compilers.

I am working on supporting MacOS based on your information in #157. @remcg Could you help me by reviewing this PR and verify if this fixes both issues?

rainerschoe commented 1 month ago

NOTE: I just realized that CI in #157 fails. Obviously it only makes sense to test this on MacOS after CI passes. I am running out of time for today, so still a work in progress. If you like to have a look, feel free to, otherwise I will continue on this when I have some more time.

remcg commented 1 month ago

I was able to build successfully on MacOS with #157 . Both issues are resolved when I run build with the command ./build.sh. There were some warnings that can be ignored I guess but sharing them anyway in case you want to fix those too.

[100%] Building CXX object tests/testServer/CMakeFiles/testServer.dir/ServiceComplexTypeRpcs.cpp.o In file included from /Users/XXXXX/github/test/gWhisper/src/libCli/Call.cpp:15: In file included from /Users/XXXXX/github/test/gWhisper/src/libCli/libCli/Call.hpp:17: In file included from /Users/XXXXX/github/test/gWhisper/src/libArgParse/libArgParse/ArgParse.hpp:37: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/memory:898: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/memory/shared_ptr.h:31: /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__memory/unique_ptr.h:68:5: warning: delete called on 'cli::MessageFormatter' that is abstract but has non-virtual destructor [-Wdelete-abstract-non-virtual-dtor] delete ptr; ^ /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/memory/unique_ptr.h:300:7: note: in instantiation of member function 'std::default_delete::operator()' requested here ptr_.second()(tmp); ^ /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/memory/unique_ptr.h:266:75: note: in instantiation of member function 'std::unique_ptr::reset' requested here _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); } ^ /Users/XXXXX/github/test/gWhisper/src/libCli/Call.cpp:199:33: note: in instantiation of member function 'std::unique_ptr::~unique_ptr' requested here auto messageFormatter = createMessageFormatter(parseTree); ^ In file included from /Users/XXXXX/github/test/gWhisper/src/libCli/Call.cpp:15: In file included from /Users/XXXXX/github/test/gWhisper/src/libCli/libCli/Call.hpp:17: In file included from /Users/XXXXX/github/test/gWhisper/src/libArgParse/libArgParse/ArgParse.hpp:37: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/memory:898: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/memory/shared_ptr.h:31: /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__memory/unique_ptr.h:68:5: warning: delete called on 'cli::MessageParser' that is abstract but has non-virtual destructor [-Wdelete-abstract-non-virtual-dtor] delete ptr; ^ /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/memory/unique_ptr.h:300:7: note: in instantiation of member function 'std::default_delete::operator()' requested here ptr_.second()(tmp); ^ /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/memory/unique_ptr.h:266:75: note: in instantiation of member function 'std::unique_ptr::reset' requested here _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); } ^ /Users/XXXXX/github/test/gWhisper/src/libCli/Call.cpp:200:30: note: in instantiation of member function 'std::unique_ptr::~unique_ptr' requested here auto messageParser = createMessageParser(parseTree); ^ 2 warnings generated.

remcg commented 1 month ago

I looked at the CI build failures and tried to replicate them. I ran these commands to run tests cmake -B build -DCMAKE_BUILD_TYPE=Release -DGWHISPER_BUILD_TESTS=ON cmake --build ./build --config Release --parallel 8 ctest -C Release --verbose

Got similar test failures as the CI tests.

The following tests FAILED: 2 - CompletionFunctionTests (Failed) 3 - CompletionFunctionTests_fish (Failed) 4 - RpcExecutionTests (Failed) 5 - SslFunctionTests (Failed) 6 - RpcTimeoutTests (Failed) 7 - CacheTests (Failed)

Attached test log files. LastTest.log

rainerschoe commented 1 month ago

Thanks for helping out here. The warning seems easy enough to fix. Will fix it :-)

The failing tests are all related to testing gWhisper against a test server specifically started for the test. I think something about starting the server / opening a TCP socket and gWhisper connecting to it does not work the same on mac as it does on linux.

It is kind of hard for me to debug, as I only have the CI to test on, so I am quite happy that you could replicate on your local setup.

Could you maybe try starting the test server manually and run gwhisper with some arbitrary RPCs against it on your setup? If it is OK for you, we could also schedule a PP session to work together on this.