Uh oh!
There was an error while loading. Please reload this page.
fix(host): Export correct symbols for shared library builds - #29
Conversation
The shared library was built with -fvisibility=hidden but had no export annotations, resulting in zero exported symbols. Introduce LIBRMCS_API visibility macro for Handler and PacketBuilder, enabling correct symbol export in shared library builds. Default build is changed to static; release Dockerfile explicitly opts into shared. - Add host/include/librmcs/export.hpp with platform-aware export macro - Mark Handler and PacketBuilder with LIBRMCS_API - Add -fvisibility-inlines-hidden for GCC/Clang - Change BUILD_STATIC_LIBRMCS default to ON - Set -DBUILD_STATIC_LIBRMCS=OFF in Dockerfile.build_sdk for release
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
Walkthrough更改构建流程:将 CMake 中 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
诗歌
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
host/CMakeLists.txt (1)
37-37: 建议把-fvisibility-inlines-hidden限定到 C++ 编译单元,提高代码一致性。虽然当前项目中没有 C 源文件,但
-fvisibility-inlines-hidden是 C++ 专用选项。为了与firmware/c_board/CMakeLists.txt中的做法保持一致,建议用COMPILE_LANGUAGE:CXX条件分离,便于未来维护。🔧 参考修复
- add_compile_options(-g -Wall -Wextra -Wpedantic -fvisibility=hidden -fvisibility-inlines-hidden)+ add_compile_options(-g -Wall -Wextra -Wpedantic -fvisibility=hidden)+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fvisibility-inlines-hidden>)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@host/CMakeLists.txt` at line 37, The add_compile_options invocation adds the C++-only flag -fvisibility-inlines-hidden globally; restrict this flag to C++ compilations by using the generator expression form so only CXX files get -fvisibility-inlines-hidden (leave the common flags like -g -Wall -Wextra -Wpedantic -fvisibility=hidden applied to all languages). Update the add_compile_options call (the one using add_compile_options with -g -Wall -Wextra -Wpedantic -fvisibility=hidden -fvisibility-inlines-hidden) to apply -fvisibility-inlines-hidden with a $<COMPILE_LANGUAGE:CXX> generator expression so the option is only used for C++ translation units.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@host/include/librmcs/export.hpp`:
- Around line 3-18: The preprocessor macro block defining LIBRMCS_API has
indentation/formatting that violates clang-format rules and causes CI lint
failures; run clang-format (or apply the project's formatting rules) to reflow
the conditional blocks around LIBRMCS_API so `#if/`#elif/#else/#endif and the
inner lines have consistent indentation and spacing, ensure the GCC/Clang and
MSVC branches and the final else are formatted uniformly, remove any trailing
whitespace, and commit the formatted export.hpp changes.
---
Nitpick comments:
In `@host/CMakeLists.txt`:
- Line 37: The add_compile_options invocation adds the C++-only flag
-fvisibility-inlines-hidden globally; restrict this flag to C++ compilations by
using the generator expression form so only CXX files get
-fvisibility-inlines-hidden (leave the common flags like -g -Wall -Wextra
-Wpedantic -fvisibility=hidden applied to all languages). Update the
add_compile_options call (the one using add_compile_options with -g -Wall
-Wextra -Wpedantic -fvisibility=hidden -fvisibility-inlines-hidden) to apply
-fvisibility-inlines-hidden with a $<COMPILE_LANGUAGE:CXX> generator expression
so the option is only used for C++ translation units.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
Dockerfile.build_sdkhost/CMakeLists.txthost/include/librmcs/export.hpphost/include/librmcs/protocol/handler.hpp
Uh oh!
There was an error while loading. Please reload this page.
qzhhhi
commented
Mar 3, 2026
@coderabbitai full review |
✅ Actions performedFull review triggered. |
The shared library was built with -fvisibility=hidden but had no export annotations, resulting in zero exported symbols. Introduce LIBRMCS_API visibility macro for Handler and PacketBuilder, enabling correct symbol export in shared library builds. Default build is changed to static; release Dockerfile explicitly opts into shared.
修复共享库构建的符号导出
该 PR 通过引入平台感知的导出宏并调整构建配置,修复了在开启 -fvisibility=hidden 时共享库没有导出任何符号的问题。
主要变更
新增导出机制(host/include/librmcs/export.hpp)
标注公共接口(host/include/librmcs/protocol/handler.hpp)
编译器选项与构建模式调整(host/CMakeLists.txt)
Docker 构建配置(Dockerfile.build_sdk)
影响