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

僤鯓⒐⒋嵵緔 提交于 2019-11-30 09:15:38

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 ..

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!