[clang] [clang][driver] Use platform specific calls to get the executable absolute path (PR #68091)

Liviu Ionescu via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 4 07:56:38 PDT 2023


ilg-ul wrote:

I took some time to analyse the failed tests. I managed to reproduce them (except `rocm-detect.hip`) on my macOS, so I had more freedom to experiment.

The failing tests are:

- `Clang::Driver/mingw-sysroot.cpp`
- `Clang::Driver/no-canonical-prefixes.c`
- `Clang::Driver/program-path-priority.c`

They all create folders where they place various symlinks to clang, then perform some checks on InstalledDir or other output lines.

The question is whether the reliance of these tests on the path where the symlink is located is a feature that must be checked by the tests, or 

As Martin noticed, without a clear definition of the correct way to handle these symlinks, this is a tricky issue. 

Without any other reference, I checked the Apple clang, on my macOS:

```
ilg at wksi ~ % /usr/bin/clang -v
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin


ilg at wksi ~ % mkdir tmp/a 
ilg at wksi ~ % ln -s /usr/bin/clang tmp/a

ilg at wksi ~ % tmp/a/clang -v
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
```

So Apple decided to **follow the links**, and, in my opinion, this is the less ambiguous and expected behaviour.

I think that we first need an agreement from the clang maintainers that this is the correct behaviour, then find a way to fix the  current tests, and possibly improve the implementation (for example i'm not sure if `InstalledDir` should be affected by `-no-canonical-prefixes`). 




https://github.com/llvm/llvm-project/pull/68091


More information about the cfe-commits mailing list