ld: unrecognized option '--push-state--no-as-needed'

后端 未结 2 2087
清歌不尽
清歌不尽 2021-02-08 12:53

My build fails with the following linker error message:

FAILED: : && /usr/bin/g++ -Wall -Wextra -Werror -g -fsanitize=undefined,address -Wno-unus

相关标签:
2条回答
  • 2021-02-08 13:43

    If option D (from ollo's answer) is not working for you try next commands:

    sudo add-apt-repository ppa:jonathonf/binutils --yes
    sudo apt-get update -qq --yes
    sudo apt-get install -qq --yes --force-yes binutils
    

    This is from: https://github.com/Project-OSRM/osrm-backend/blob/master/scripts/travis/before_install.x86_64-asan.sh

    And the issue was discribed here: https://github.com/Project-OSRM/osrm-backend/issues/3216

    0 讨论(0)
  • 2021-02-08 13:44

    GCC 7 is fixed with 7.3.0-16ubuntu3 (tested on Ubuntu 18.04). This version is available though the Ubuntu Toolchain Test PPA (for 16.04.1 and 14.04).

    Tested with Make only, but it should work with Ninja too. Both Sanitizer, ASan and UBsan, enabled.

    There's not much related to this problem in the changelog though:

    gcc-7 (7.3.0-16ubuntu3) bionic; urgency=medium

    • Update to SVN 20180415 (r259389) from the gcc-7-branch.
      • Fix PR libstdc++/85222.
    • Remove our own PR libstdc++/85222 backport.

    Update:

    GCC 7 (7.3.0-16ubuntu3) is still broken on Ubuntu 16.04 and earlier.

    What you can do to workaround this:

    A. Update to Ubuntu 18.04

    The problem is fixed on Ubuntu 18.04 (LTS)'s Gcc7.


    B. Dockerize and update to Ubuntu 18.04

    If an update is not possible, eg. running on a CI system, it's still an option to use Docker and an up-to-date Ubuntu.


    C. Disable UB Sanitizer

    The Problem occurs only when using GCC7 with UB Sanitizer enabled. As tobias-brüll noted in the comments: Turning the UB Sanitizer off prevents the error.


    D. Use Gold Linker

    Another workaround posted by makerj: Using the Gold Linker doesn't cause the problem.

    Eg. on CMake pass it through the CMAKE_EXE_LINKER_FLAGS:

    cmake -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=gold ..
    
    0 讨论(0)
提交回复
热议问题