[all-commits] [llvm/llvm-project] 75d12e: [libclang] Fall back to getMainExecutable when dla...

Ayke via All-commits all-commits at lists.llvm.org
Sun May 29 04:41:24 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 75d12e49c729e65f77bfdfe65b16df8c39944d35
      https://github.com/llvm/llvm-project/commit/75d12e49c729e65f77bfdfe65b16df8c39944d35
  Author: Ayke van Laethem <aykevanlaethem at gmail.com>
  Date:   2022-05-29 (Sun, 29 May 2022)

  Changed paths:
    M clang/tools/libclang/CIndexer.cpp

  Log Message:
  -----------
  [libclang] Fall back to getMainExecutable when dladdr fails

musl-libc doesn't support dladdr in statically linked binaries:

> Are you using static or dynamic linking? If static, dladdr is just a
> stub that always fails. It could be implemented to work under some
> conditions, but it would be highly dependent on what options you
> compile the binary with, since by default static binaries do not
> contain the bloat that would be needed to perform introspection.

Source: https://www.openwall.com/lists/musl/2013/01/15/25 (in response
to a bug report).

Libclang unfortunately uses dladdr to find the ResourcesPath so will
fail if it is linked statically on Alpine Linux. This patch fixes this
issue by falling back to getMainExecutable if dladdr returns an error.

Reference: https://github.com/llvm/llvm-project/issues/40641#issuecomment-981011427

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




More information about the All-commits mailing list