D53557-hurd-self-exe-realpath
authorLLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Mon, 23 Mar 2020 10:59:23 +0000 (10:59 +0000)
committerGianfranco Costamagna <locutusofborg@debian.org>
Mon, 23 Mar 2020 10:59:23 +0000 (10:59 +0000)
commitc61d113d8788360b369a3119f28a6ce706476dc4
tree9cb9d3650632d6d66eeff89583d6ea74a4359dc1
parent3c29f029a0cdacf4cb4f3d7c5ca4f65296e03cd9
D53557-hurd-self-exe-realpath

[hurd] Make getMainExecutable get the real binary path

On GNU/Hurd, llvm-config is returning bogus value, such as:

$ llvm-config-6.0 --includedir
/usr/include

while it should be:
$ llvm-config-6.0 --includedir
/usr/lib/llvm-6.0/include

This is because getMainExecutable does not get the actual installation
path. On GNU/Hurd, /proc/self/exe is indeed a symlink to the path that
was used to start the program, and not the eventual binary file. Llvm's
getMainExecutable thus needs to run realpath over it to get the actual
place where llvm was installed (/usr/lib/llvm-6.0/bin/llvm-config), and
not /usr/bin/llvm-config-6.0. This will not change the result on Linux,
where /proc/self/exe already points to the eventual file.

Patch by Samuel Thibault!

While making changes here, I reformatted this block a bit to reduce
indentation and match 2 space indent style.

Differential Revision: https://reviews.llvm.org/D53557

Gbp-Pq: Name D53557-hurd-self-exe-realpath.diff
lib/Support/Unix/Path.inc