debuild buildsystem=cmake 링커 플래그 제거

debuild buildsystem=cmake 링커 플래그 제거

cmake와 mingw 크로스 컴파일러를 사용하여 데비안에서 *.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

관련 정보