| commit | ff07c9b701dc6372f82d989d01768051e848b30d | [log] [tgz] |
|---|---|---|
| author | Fangrui Song <i@maskray.me> | Wed Feb 28 15:12:31 2024 -0800 |
| committer | GitHub <noreply@github.com> | Wed Feb 28 15:12:31 2024 -0800 |
| tree | b3cb66b3e78572b31ac2f377bded64a604edc0b5 | |
| parent | c345198c7a68cb76e82dbc04d0e91476cb0edc70 [diff] |
[Driver] Unify InstalledDir and Dir (#80527) `Driver::ClangExecutable` is derived from: * (-canonical-prefixes default): `realpath` on the executable path * (-no-canonical-prefixes) argv[0] (consult PATH if argv[0] is a word) `Dir` and `ResourceDir` are derived from `ClangExecutable`. Both variables are used to derive certain include and library paths. `InstalledDir` is a related concept used to derive certain other paths. `InstalledDir` is weird in the -canonical-prefixes mode: Clang calls `make_absolute` but does not follow symlinks (FIXME from 9ade6a9a747c49383ac747bd8ffaa6a0beaef71c). This causes some search and library paths to be mix-and-matched. The "Do a PATH lookup, if there are no directory components." logic makes things worse. `InstalledDir` is different when you invoke it via `PATH`: ``` % which clang /usr/bin/clang % clang -v |& grep InstalledDir InstalledDir: /usr/bin % /usr/lib/llvm-16/bin/clang -v |& grep InstalledDir InstalledDir: /usr/lib/llvm-16/bin ``` I believe `InstalledDir` was a partial solution to `-no-canonical-prefixes` and should be eventually removed. This patch removes `SetInstallDir` and relies on Driver::Driver to set `InstalledDir` to `Dir`. The behavior for regular file `clang` or `-no-canonical-prefixes` is unchanged. If a user creates a symlink to the regular file `clang` and uses the default `-canonical-prefixes`, they now consistently get search and library paths relative to the regular file `clang`, not mix-and-match paths. If a user creates a symlink to the regular file `clang` and replaces some directorys from the actual installation, they should change the symlink to a wrapper that calls the underlying clang with `-no-canonical-prefixes`.
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.