[all-commits] [llvm/llvm-project] 762f70: [Support] Fix getMainExecutable on FreeBSD when ca...

Jessica Clarke via All-commits all-commits at lists.llvm.org
Sat May 29 07:01:10 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 762f707c0072abba60b5b4bdbb64c2c69c6152b1
      https://github.com/llvm/llvm-project/commit/762f707c0072abba60b5b4bdbb64c2c69c6152b1
  Author: Jessica Clarke <jrtc27 at jrtc27.com>
  Date:   2021-05-29 (Sat, 29 May 2021)

  Changed paths:
    M llvm/lib/Support/Unix/Path.inc

  Log Message:
  -----------
  [Support] Fix getMainExecutable on FreeBSD when called via an absolute path

On FreeBSD, absolute paths are passed unmodified in AT_EXECPATH, but
relative paths are resolved to absolute paths, and any symlinks will be
followed in the process. This means that the resource dir calculation
will be wrong if Clang is invoked as an absolute path to a symlink, and
this currently causes clang/test/Driver/rocm-detect.hip to fail on
FreeBSD. Thus, make sure to call realpath on the result, just like is
done on macOS.

Whilst here, clean up the old fallback auxargs loop to use the actual
type for auxargs rather than using lots of hacky casts that rely on
addresses and pointers being the same (which is not the case on CHERI,
and thus Arm's prototype Morello, although for little-endian systems it
happens to work still as the word-sized integer will be padded to a full
pointer, and it's someone academic given dereferencing past the end of
environ will give a bounds fault, but CheriBSD is new enough that the
elf_aux_info path will be used). This also makes the code easier to
follow, and removes the confusing double-increment of p.

Reviewed By: dim, arichardson

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




More information about the All-commits mailing list