[cfe-commits] r90577 - in /cfe/trunk: include/clang/Driver/Options.td lib/Driver/Tools.cpp tools/driver/driver.cpp

Rafael Espíndola rafael.espindola at gmail.com
Tue Dec 15 05:35:35 PST 2009


> Presumably, but just to make sure we are on the same page I presume
> you don't really care about relative paths but rather non-canonical
> paths. A relative path can always be turned into an absolute path that
> will behave the same, unless its being resolved in multiple contexts?
>
> This has been implemented as -resource-dir, so that clang -cc1 should
> get its resources dir relative to where the driver found itself. Let
> me know if this works (or doesn't work) for you.

If the absolute path is constructed with something like $(pwd) +
"../foo/bar" it should.

>> I am not sure if there is any user that depends on gcc's behavior of
>> using canonical dirs. Since clang and clang-cc are very careful to
>> always compute it, I assumed you guys did.
>
> It's more a side effect of how GetMainExecutable is implemented than
> an explicit decision. I do personally rely heavily on the ability to
> make a symlink point to the actual compiler, but that works in the
> model I outlined.
>
>> What is the usecase where a canonical path is necessary? Maybe we
>> could always use argv[0]? If not, lets try your suggestion of
>> searching argv[0] first and then the canonical path.
>
> The problem with argv[0] is it isn't always correct, and it may point
> to a symlink. This is why I proposed recursively resolving symbolic
> links via argv[0], in the cases when argv[0] isn't correct this will
> fail immediately and we will fall to the canonical path
>
>> Is there anything you would like me to implement?
>
> If you want to cook up a patch that implements this strategy and
> verify that it solves the original problem, that would be great. To
> make sure we are on the same page, this is what I am imagining, in
> untested pseudo-Python:
>
> --
> def getDriverDirsToSearch(argv0, mainaddr):
>  while os.path.exists(argv0):
>      yield argv0
>      try:
>        next = readlink(argv0)
>      except:
>
>
>      argv0 = readlink

You are probably missing a basedir(argv0) at the start and something
in the except block, but I think it should work.

Thanks,
Rafael




More information about the cfe-commits mailing list