Results 1 to 6 of 6

Thread: RPMLINT ask for -fPIE and -pie compiler flag. But it was not recognized.

  1. #1
    Join Date
    Oct 2018
    Location
    Atlantis
    Posts
    87

    Default RPMLINT ask for -fPIE and -pie compiler flag. But it was not recognized.

    I tried to build Molequeue package here: https://build.opensuse.org/package/s...reat/molequeue

    RPMLINT want me to built with -fPIE/-fpie in compiler flags and -pie in linker flags.


    Code:
    RPMLINT report:
    [   35s] ===============
    [   37s] molequeue.x86_64: W: position-independent-executable-suggested /usr/bin/molequeue
    [   37s] This executable should be position independent (all binaries should).  Check
    [   37s] that it is built with -fPIE/-fpie in compiler flags and -pie in linker flags.
    But I add the flag like so.

    Code:
    %prep
    %setup -q
    
    %build
    export CFLAGS="${CFLAGS} -fPIE" 
    export CXXFLAGS="${CXXFLAGS} -fPIE" 
    export LDFLAGS="${LDFLAGS} -pie"
    
    %cmake -Wno-dev \
     -DENABLE_RPATH:BOOL=OFF \
     -DCMAKE_SKIP_INSTALL_RPATH:BOOL=YES \
     -DCMAKE_SKIP_RPATH:BOOL=YES \
     -DENABLE_TESTING:BOOL=OFF \
     -DBUILD_DOCUMENTATION:BOOL=ON \
     -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE \
     -DPYTHON_EXECUTABLE:FILEPATH=python3 \
     -DCMAKE_BUILD_TYPE:STRING=Release ..
    
    %make_build
    
    pushd docs
    doxygen
    popd
    
    
    
    %install
    %make_install -C build
    Some how, it was not recognized. Same RPMLINT warning. What did I do wrong?
    Thanks.

  2. #2
    Join Date
    Sep 2012
    Posts
    5,321

    Default Re: RPMLINT ask for -fPIE and -pie compiler flag. But it was not recognized.

    If you look at %cmake expansion, it does not use $LDFLAGS at all. Set RPM macro %build_ldflags.

  3. #3
    Join Date
    Oct 2018
    Location
    Atlantis
    Posts
    87

    Default Re: RPMLINT ask for -fPIE and -pie compiler flag. But it was not recognized.

    Quote Originally Posted by arvidjaar View Post
    If you look at %cmake expansion, it does not use $LDFLAGS at all. Set RPM macro %build_ldflags.
    I looked up %build_ldflags but could not find any documentation on it. How do I use this?

    My spec file currently look like this:
    Code:
    %build
    CFLAGS="$CFLAGS -fPIE"
    CXXFLAGS="$CXXFLAGS -fPIE"
    LDFLAGS="$LDFLAGS -pie"
    
    export CFLAGS="%{optflags}" 
    export CXXFLAGS="%{optflags}"
    export LDFLAGS="%{optflags}"
    
    %cmake -Wno-dev \
     -DCMAKE_C_FLAGS:STRING="%optflags" \
     -DCMAKE_CXX_FLAGS:STRING="%optflags" \
     -DCMAKE_LD_FLAGS:STRING="%optflags" \
     -DENABLE_RPATH:BOOL=OFF \
     -DCMAKE_SKIP_INSTALL_RPATH:BOOL=YES \
     -DCMAKE_SKIP_RPATH:BOOL=YES \
     -DENABLE_TESTING:BOOL=OFF \
     -DBUILD_DOCUMENTATION:BOOL=ON \
     -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE \
     -DPYTHON_EXECUTABLE:FILEPATH=python3 \
     -DCMAKE_BUILD_TYPE:STRING=Release ..
    Thanks

  4. #4
    Join Date
    Oct 2018
    Location
    Atlantis
    Posts
    87

    Default Re: RPMLINT ask for -fPIE and -pie compiler flag. But it was not recognized.

    Update.

    I fix the flag, this is what is left.

    Code:
    %build
    
    %cmake -Wno-dev \
     -DCMAKE_C_FLAGS:STRING="%optflags -fPIE" \
     -DCMAKE_CXX_FLAGS:STRING="%optflags -fPIE" \
     -DCMAKE_LD_FLAGS:STRING="%optflags -pie" \
     -DENABLE_RPATH:BOOL=OFF \
     -DCMAKE_SKIP_INSTALL_RPATH:BOOL=YES \
     -DCMAKE_SKIP_RPATH:BOOL=YES \
     -DENABLE_TESTING:BOOL=OFF \
     -DBUILD_DOCUMENTATION:BOOL=ON \
     -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE \
     -DPYTHON_EXECUTABLE:FILEPATH=python3 \
     -DCMAKE_BUILD_TYPE:STRING=Release ..
    
    %make_build
    It seems to pass the -fPIE and -pie flag correctly now.
    But then the build failed all together.

    Any clue what went wrong?
    https://build.opensuse.org/package/s...reat/molequeue
    Code:
    [   74s] [ 13%] Linking CXX shared library ../../lib/libMoleQueueClient.so
    [   74s] cd /home/abuild/rpmbuild/BUILD/molequeue-0.9.0/build/molequeue/client && /usr/bin/cmake -E cmake_link_script CMakeFiles/MoleQueueClient.dir/link.txt --verbose=1
    [   74s] /usr/bin/c++ -fPIC -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fPIE -O3 -DNDEBUG -Wl,--fatal-warnings -Wl,--no-undefined -lc -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -shared -Wl,-soname,libMoleQueueClient.so -o ../../lib/libMoleQueueClient.so CMakeFiles/MoleQueueClient.dir/MoleQueueClient_autogen/mocs_compilation.cpp.o CMakeFiles/MoleQueueClient.dir/client.cpp.o CMakeFiles/MoleQueueClient.dir/jobobject.cpp.o CMakeFiles/MoleQueueClient.dir/jsonrpcclient.cpp.o  /usr/lib64/libQt5Network.so.5.14.1 /usr/lib64/libQt5Core.so.5.14.1 
    [   74s] /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /tmp/libMoleQueueClient.so.MBwiQN.ltrans0.ltrans.o: relocation R_X86_64_PC32 against symbol `_ZN9MoleQueue13JsonRpcClient16staticMetaObjectE' can not be used when making a shared object; recompile with -fPIC
    [   74s] /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: final link failed: bad value
    [   74s] collect2: error: ld returned 1 exit status
    [   74s] make[2]: *** [molequeue/client/CMakeFiles/MoleQueueClient.dir/build.make:134: lib/libMoleQueueClient.so] Error 1
    [   74s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/molequeue-0.9.0/build'
    [   74s] make[1]: *** [CMakeFiles/Makefile2:353: molequeue/client/CMakeFiles/MoleQueueClient.dir/all] Error 2
    [   74s] make[1]: *** Waiting for unfinished jobs....
    [   76s] make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/molequeue-0.9.0/build'
    [   76s] [ 14%] Linking CXX shared library ../../lib/libMoleQueueServerCore.so
    [   76s] cd /home/abuild/rpmbuild/BUILD/molequeue-0.9.0/build/molequeue/servercore && /usr/bin/cmake -E cmake_link_script CMakeFiles/MoleQueueServerCore.dir/link.txt --verbose=1
    [   76s] /usr/bin/c++ -fPIC -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fPIE -O3 -DNDEBUG -Wl,--fatal-warnings -Wl,--no-undefined -lc -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -shared -Wl,-soname,libMoleQueueServerCore.so -o ../../lib/libMoleQueueServerCore.so CMakeFiles/MoleQueueServerCore.dir/MoleQueueServerCore_autogen/mocs_compilation.cpp.o CMakeFiles/MoleQueueServerCore.dir/jsonrpc.cpp.o CMakeFiles/MoleQueueServerCore.dir/localsocketconnection.cpp.o CMakeFiles/MoleQueueServerCore.dir/localsocketconnectionlistener.cpp.o CMakeFiles/MoleQueueServerCore.dir/message.cpp.o CMakeFiles/MoleQueueServerCore.dir/messageidmanager_p.cpp.o  /usr/lib64/libQt5Network.so.5.14.1 /usr/lib64/libQt5Core.so.5.14.1 
    [   76s] /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /tmp/libMoleQueueServerCore.so.63hr9K.ltrans0.ltrans.o: relocation R_X86_64_PC32 against symbol `_ZN10QArrayData11shared_nullE@@Qt_5' can not be used when making a shared object; recompile with -fPIC
    [   76s] /usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: final link failed: bad value
    [   76s] collect2: error: ld returned 1 exit status
    [   76s] make[2]: *** [molequeue/servercore/CMakeFiles/MoleQueueServerCore.dir/build.make:164: lib/libMoleQueueServerCore.so] Error 1
    [   76s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/molequeue-0.9.0/build'
    [   76s] make[1]: *** [CMakeFiles/Makefile2:244: molequeue/servercore/CMakeFiles/MoleQueueServerCore.dir/all] Error 2
    [   76s] make: *** [Makefile:155: all] Error 2
    [   76s] error: Bad exit status from /var/tmp/rpm-tmp.L7ZXMB (%build)
    [   76s] 
    [   76s] 
    [   76s] RPM build errors:
    [   76s]     Bad exit status from /var/tmp/rpm-tmp.L7ZXMB (%build)
    [   76s] ### VM INTERACTION START ###
    [   79s] [   70.879037] sysrq: Power Off
    [   79s] [   70.886709] reboot: Power down
    [   80s] ### VM INTERACTION END ###

  5. #5
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    27,824
    Blog Entries
    15

    Default Re: RPMLINT ask for -fPIE and -pie compiler flag. But it was not recognized.

    Hi
    Can't win.... AFAIK you should just need the -pie in addition to the required link flags (no %{optflags})

    Code:
    can not be used when making a shared object; recompile with -fPIC
    Go back to the one that build and check the buildlog to see where the rpmlint report is failing.
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  6. #6
    Join Date
    Oct 2018
    Location
    Atlantis
    Posts
    87

    Default Re: RPMLINT ask for -fPIE and -pie compiler flag. But it was not recognized.

    I go back to the one that build, RPMLINT ask for -fPIE and -pie flag, which would failed the build. Forget this, I will just leave it to the repo maintainer to figured it out.

    Thanks and happy Valentine day.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •