Page MenuHomePhabricator

[hurd] Make getMainExecutable get the real binary path
ClosedPublic

Authored by sthibaul on Oct 23 2018, 12:45 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

sthibaul created this revision.Oct 23 2018, 12:45 AM
sthibaul added a comment.EditedOct 23 2018, 12:48 AM

Note: I added the realpath call for all OSes hitting this part of the code, in case the behavior would be the same on some other OSes. We could instead just call realpath(exe_path, NULL); only in the __GNU__ case (i.e. GNU/Hurd) instead if it is preferred.

sthibaul added reviewers: rnk, JDevlieghere.
rnk accepted this revision.Oct 23 2018, 9:11 AM

lgtm

I think doing this everywhere is fine.

lib/Support/Unix/Path.inc
188 ↗(On Diff #170577)

Can you add a comment explaining that Hurd needs this realpath call as you have in the commit message? Otherwise some well-meaning person will try to simplify the code and break Hurd.

This revision is now accepted and ready to land.Oct 23 2018, 9:11 AM

(I can not commit this myself)

sthibaul updated this revision to Diff 170674.Oct 23 2018, 9:18 AM
This revision was automatically updated to reflect the committed changes.