首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >删除debuild buildsystem=cmake链接器标志

删除debuild buildsystem=cmake链接器标志
EN

Unix & Linux用户
提问于 2019-01-18 10:03:25
回答 1查看 610关注 0票数 1

我正在尝试使用带有混合交叉编译器的cmake从debian创建一个*.deb文件。使用dpkg-buildpackage时,CMake的编译器测试失败。

建筑物通常是安全的:

代码语言:javascript
复制
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr 
         -DCMAKE_VERBOSE_MAKEFILE=ON 
         -DCMAKE_BUILD_TYPE=None 
         -DCMAKE_INSTALL_SYSCONFDIR=/etc 
         -DCMAKE_INSTALL_LOCALSTATEDIR=/var
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /etc/alternatives/i686-w64-mingw32-gcc
-- Check for working C compiler: /etc/alternatives/i686-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /etc/alternatives/i686-w64-mingw32-g++
-- Check for working CXX compiler: /etc/alternatives/i686-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done

但是,当我使用dpkg-buildpackage构建它时,它无法配置:

代码语言:javascript
复制
dpkg-buildpackage -uc -us
dpkg-buildpackage: info: source package foo
dpkg-buildpackage: info: source version 1.0
dpkg-buildpackage: info: source distribution stretch
dpkg-buildpackage: info: source changed by $USER
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build hw
 fakeroot debian/rules clean
dh clean --buildsystem=cmake --parallel 
   dh_testdir -O--buildsystem=cmake -O--parallel
   dh_auto_clean -O--buildsystem=cmake -O--parallel
   dh_clean -O--buildsystem=cmake -O--parallel
 dpkg-source -b hw
dpkg-source: info: using source format '3.0 (native)'
dpkg-source: info: building sim-honeywell-ease-control in sim-honeywell-ease-control_1.0.tar.xz
dpkg-source: info: building sim-honeywell-ease-control in sim-honeywell-ease-control_1.0.dsc
 debian/rules build
make: 'build' is up to date.
 fakeroot debian/rules binary
dh binary --buildsystem=cmake --parallel 
   dh_testdir -O--buildsystem=cmake -O--parallel
   dh_update_autotools_config -O--buildsystem=cmake -O--parallel
   dh_auto_configure -O--buildsystem=cmake -O--parallel
    cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_INSTALL_LOCALSTATEDIR=/var
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /etc/alternatives/i686-w64-mingw32-gcc
-- Check for working C compiler: /etc/alternatives/i686-w64-mingw32-gcc -- broken
CMake Error at /usr/share/cmake-3.7/Modules/CMakeTestCCompiler.cmake:51 (message):
  The C compiler "/etc/alternatives/i686-w64-mingw32-gcc" is not able to
  compile a simple test program.

完整日志中有趣的部分是链接期间的失败:

代码语言:javascript
复制
/etc/alternatives/i686-w64-mingw32-gcc  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2   -Wl,-z,relro  -Wl,--whole-archive CMakeFiles/cmTC_fc912.dir/objects.a -Wl,--no-whole-archive  -o cmTC_fc912.exe -Wl,--out-implib,libcmTC_fc912.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles/cmTC_fc912.dir/linklibs.rsp
/usr/bin/i686-w64-mingw32-ld: unrecognized option '-z'

mingw链接器无法识别-z选项。当我diff CMakeCache.txt时,我可以看到dpkg-buildpakcage默认添加了一些链接器标志:

代码语言:javascript
复制
< CMAKE_EXE_LINKER_FLAGS:STRING=-Wl,-z,relro
---
> CMAKE_EXE_LINKER_FLAGS:STRING=

我怎样才能阻止dpkg-buildpackage这样做?

FYI:我的debian/rules文件如下所示:

代码语言:javascript
复制
#!/usr/bin/make -f
%:
    dh $@ --buildsystem=cmake --parallel 
EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2019-01-18 10:08:58

您需要禁用relro强化配置;将debian/rules更改为

代码语言:javascript
复制
#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=-relro

%:
        dh $@ --buildsystem=cmake --parallel

详情请参见这个dpkg-buildflags命令页

(顺便说一句,如果您使用的是compat 10或更高版本,则不需要--parallel,因为默认情况下它是启用的。在许多情况下,您也可以删除--buildsystem=cmake,因为dh将自动检测它。)

票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/495246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档