debuild buildsystem=cmake リンカフラグの削除

debuild buildsystem=cmake リンカフラグの削除

cmakeとmingwクロスコンパイラを使用してDebianで* .debファイルを作成しようとしています。 .CMakeを使用するとCMakeのコンパイラテストが失敗しますdpkg-buildpackage

一般的なビルドに問題はありません。

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

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.

ログ全体の興味深い部分は、接続中にエラーが発生したことです。

/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オプションを認識しません。 CMakeCache.txt を見ると、diffdpkg-buildpakcage がデフォルトでいくつかのリンカフラグを追加するのがわかります。

< CMAKE_EXE_LINKER_FLAGS:STRING=-Wl,-z,relro
---
> CMAKE_EXE_LINKER_FLAGS:STRING=

どうすればdpkg-buildpackageこれを防ぐことができますか?

注:私のdebian/rulesファイルは次のとおりです。

#!/usr/bin/make -f
%:
    dh $@ --buildsystem=cmake --parallel 

ベストアンサー1

relro強化構成をdebian/rules無効にする必要があります。

#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=-relro

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

バラよりdpkg-buildflagsマンページもっと学ぶ。

(ただし、互換性レベル10以上を使用している場合はデフォルト--parallelで有効になっているため、必要ありません。ほとんどの場合、システムは自動的に検出されるため--buildsystem=cmake削除することもできます。)dh

おすすめ記事