My build fails with the following linker error message:
FAILED: : && /usr/bin/g++ -Wall -Wextra -Werror -g -fsanitize=undefined,address -Wno-unused-parameter -fsanitize=undefined,address -rdynamic *.o -o SCE -Wl,-rpath,/opt/qt59/lib /opt/qt59/lib/libQt5Widgets.so.5.9.1 /usr/local/lib/libprotobuf.a -lpthread -lutil -lgrpc++ /opt/qt59/lib/libQt5Gui.so.5.9.1 /opt/qt59/lib/libQt5Core.so.5.9.1 && :
/usr/bin/x86_64-linux-gnu-ld: unrecognized option '--push-state--no-as-needed'
You can see the full build log here. The error is in line 2211 and versions are printed in lines 2104ff.
Which tool causes the error?
gcc 7.3.0
using an incorrect linker flag? The ld
documentation indicates that --push-state
and --no-as-needed
are separate commands.ld 2.28
too old to understand the linker flag? The change log doesn't list anything that seems related.&& /usr/bin/g++
looks odd, it should be /usr/bin/g++
. Using make
instead of ninja
shows the same linking error.It builds correctly on Debian testing which is using gcc 7.3.0
as well and ld 2.30
, but there doesn't seem to be a working binutils-2.30
ppa for Ubuntu Trusty.
How do I successfully build my project on Travis?
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.
GCC 7 (7.3.0-16ubuntu3) is still broken on Ubuntu 16.04 and earlier.
What you can do to workaround this:
The problem is fixed on Ubuntu 18.04 (LTS)'s Gcc7.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With