Skip to content

running clang via ld-linux-x86-64.so.2 clang test.c is't work #148154

Open
@leleliu008

Description

@leleliu008

run clang as /home/leleliu008/Downloads/glibc/lib/ld-linux-x86-64.so.2 ./clang -v -c test.c

I got following:

clang version 18.1.8
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/leleliu008/Downloads/llvm+clang-18.1.8-linux-glibc-x86_64.release.old/bin/.
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Selected multilib: .;@m64
 (in-process)
 "/home/leleliu008/Downloads/glibc/lib/ld-linux-x86-64.so.2" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/leleliu008/Downloads/llvm+clang-18.1.8-linux-glibc-x86_64.release.old/bin -v -fcoverage-compilation-dir=/home/leleliu008/Downloads/llvm+clang-18.1.8-linux-glibc-x86_64.release.old/bin -resource-dir /home/leleliu008/Downloads/llvm+clang+lld-18.1.8-linux-glibc-x86_64.release/lib/clang/18 -internal-isystem /home/leleliu008/Downloads/llvm+clang+lld-18.1.8-linux-glibc-x86_64.release/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o test.o -x c test.c
clang -cc1 version 18.1.8 based upon LLVM 18.1.8 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/leleliu008/Downloads/llvm+clang+lld-18.1.8-linux-glibc-x86_64.release/lib/clang/18/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.

As you can see, cc1 is invoked via /home/leleliu008/Downloads/glibc/lib/ld-linux-x86-64.so.2" -cc1

I guess clang use /proc/self/exe to determine self path on GNU/Linux.

Why I use this way to run clang?

Becase this is the most portable way to run dynamically linked executables on all GNU/Linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'platform:linux

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions