https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102803
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |UNCONFIRMED Ever confirmed|1 |0 --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Ubuntu's GCC is built with --with-sysroot=/ which sounds like the issue here really. So when you install it a different directory, it uses a new sysroot of that directory. And GCC calls realpath on the "./usr/bin/../../" for the sysroot. Here is the configure line for Ubuntu 1804 (aarch64)'s GCC: Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 7.4.0-1ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu So you can see the --with-sysroot=/ option. try this: ./usr/bin/gcc -no-canonical-prefixes -print-sysroot See what it prints.