diff options
Diffstat (limited to 'coal.spec')
| -rw-r--r-- | coal.spec | 49 |
1 files changed, 48 insertions, 1 deletions
@@ -27,6 +27,17 @@ BuildRequires: git # provider;官方 EPOL 源的对应开发包为 octomap-devel(提供 # /usr/lib64/octomap/octomap-config.cmake,coal 的 CMake 配置依赖它)。 BuildRequires: octomap-devel +# openEuler 的 assimp-devel 在 assimpTargets.cmake 的 +# INTERFACE_LINK_LIBRARIES 里硬编码了绝对路径 /usr/lib64/libz.so 与裸名 +# minizip;coal 以 PRIVATE 链接 assimp::assimp,这两项会进入 libcoal.so +# 的链接行:前者是 Makefile 级前置依赖,文件不存在即报 +# "No rule to make target '/usr/lib64/libz.so'";后者展开为 -lminizip, +# 缺 .so 链接名即报 "cannot find -lminizip"。运行时包 zlib/minizip 只带 +# libz.so.1 / libminizip.so.1,不带开发用 .so 链接名,故必须显式声明二者 +# 对应的 -devel 包(zlib-devel 由 OS/everything 源提供,minizip-devel 由 +# everything 源提供)。 +BuildRequires: zlib-devel +BuildRequires: minizip-devel BuildRequires: python3 BuildRequires: python3-lxml BuildRequires: python3-numpy @@ -37,6 +48,10 @@ Requires: assimp-devel Requires: boost-devel Requires: eigen3-devel Requires: octomap-devel +# 与 BuildRequires 同步:coal 导出的 CMake 配置会 find_dependency(assimp), +# 下游包链接 libcoal.so 时同样会拉入上面那两项,故一并声明。 +Requires: zlib-devel +Requires: minizip-devel Requires: python3 Requires: python3-numpy @@ -55,6 +70,31 @@ An extension of the Flexible Collision Library. export PYTHONPATH=/opt/ros/%{ros_distro}/lib/python%{python3_version}/site-packages${PYTHONPATH:+:$PYTHONPATH} export PKG_CONFIG_PATH=/opt/ros/%{ros_distro}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH} mkdir -p .obj && cd .obj +# 构建机资源极小:本次 COPR 任务的 backend.log 记录 memory_reqs=2048(2GB 内存)、 +# make -j4(4 vCPU)。上游默认构建类型 RelWithDebInfo = "-O2 -g",而 coal_pywrap +# 的 boost::python 模板编译单元(python/collision.cc、 +# python/collision-geometries.cc,每源文件均几十 KB 且深度实例化)单进程峰值内存 +# 极高,-j4 并行时触发内核 OOM killer——build 112469 的 builder-live.log 尾部: +# c++: fatal error: Killed signal terminated program cc1plus +# make[2]: *** [python/CMakeFiles/coal_pywrap.dir/build.make:121: +# python/CMakeFiles/coal_pywrap.dir/collision.cc.o] Error 1 +# 该轮已推进到九成(src 的 75 个编译单元全部完成),可见瓶颈只在 python 绑定的 +# 大模板单元。据此做两项调整: +# 1) 把 -O1 -g0 追加到各目标的编译选项末尾:-O1 降低模板实例化/内联的内存与时间 +# 开销,-g0 关闭调试信息(spec 头部已关闭 debug_package,调试信息既不打包也无 +# 下游消费者)。之所以用 sed 直接改生成物 flags.make 而不是给 cmake 传 +# -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="...":本 spec 无法实证 rpm 宏是否会把它 +# 按空格二次分词(一旦被拆成独立参数,cmake 会因未知参数 -g0 直接失败),而 +# shell 命令里的空格没有这个风险,且 GCC 取命令行最后一个 -O/-g 的语义保证 +# 该追加稳定生效。 +# 2) 分步构建:C++ 库(体量小,-j4 实测可通过)仍并行;python 绑定单独用 -j1 +# 串行编译,保证任一时刻只有一个大编译单元驻留内存;最后再跑一次收尾 +# (文档/字节码等剩余目标,已建目标不会重编)。 +# +# 本段注释一律不写百分号开头的宏名:RPM 会展开脚本体注释行里的宏,而 cmake3 宏 +# 是多行展开,写进注释后第 2 行起将脱离 "#" 变成真命令(build 112470 即栽在 +# 这里:cmake 收到 "注入的 optflags ..." 这类中文参数而报 source directory +# 不存在)。 %cmake3 \ -DCMAKE_INSTALL_PREFIX="/opt/ros/%{ros_distro}" \ -DAMENT_PREFIX_PATH="/opt/ros/%{ros_distro}" \ @@ -63,7 +103,14 @@ mkdir -p .obj && cd .obj -DSETUPTOOLS_DEB_LAYOUT=OFF \ -DBUILD_TESTING=OFF -DTESTING=OFF -DCMAKE_SUPPRESS_REGENERATION=ON \ .. -make %{?_smp_mflags} +for f in $(find . -name flags.make); do + sed -i -E 's/^(CXX_FLAGS = .*)$/\1 -O1 -g0/; s/^(C_FLAGS = .*)$/\1 -O1 -g0/' "$f" +done +# 打日志确认追加生效(若上游改了 flags.make 格式,sed 静默不匹配,这里能看出来) +grep -m1 '^CXX_FLAGS' python/CMakeFiles/coal_pywrap.dir/flags.make || true +make %{?_smp_mflags} coal +make -j1 coal_pywrap +make -j1 %install [ -f /opt/ros/%{ros_distro}/setup.sh ] && source /opt/ros/%{ros_distro}/setup.sh || true |
