My build fails with the following linker error message:
FAILED: : && /usr/bin/g++ -Wall -Wextra -Werror -g -fsanitize=undefined,address -Wno-unus
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
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 ..