about summary refs log tree commit diff
path: root/compiler/rustc_session/src/filesearch.rs
AgeCommit message (Collapse)AuthorLines
2025-06-24rustc_session: Add a structure for keeping both explicit and default sysrootsVadim Petrochenkov-17/+1
Also avoid creating and cloning sysroot unnecessarily.
2025-06-17apply clippy::or_fun_callklensy-5/+5
2025-06-05Replace all uses of sysroot_candidates with get_or_default_sysrootbjorn3-29/+7
Before this change we had two different ways to attempt to locate the sysroot which are inconsistently used: * get_or_default_sysroot which tries to locate based on the 0th cli argument and if that doesn't work falls back to locating it using the librustc_driver.so location and returns a single path., * sysroot_candidates which takes the former and additionally does another attempt at locating using librustc_driver.so except without linux multiarch handling and then returns both paths., The latter was originally introduced to be able to locate the codegen backend back when cg_llvm was dynamically linked even for a custom driver when the --sysroot passed in does not contain a copy of cg_llvm. Back then get_or_default_sysroot did not attempt to locate the sysroot based on the location of librustc_driver.so yet. Because that is now done, the only case where removing sysroot_candidates can break things is if you have a custom driver inside what looks like a sysroot including the lib/rustlib directory, but which is missing some parts of the full sysroot like eg rust-lld.
2025-06-05Move canonicalization into current_dll_pathbjorn3-18/+12
And consistently use try_canonicalize rather than canonicalize.
2025-06-01Rollup merge of #141834 - Timmmm:user/timh/wasi, r=NoratriebGuillaume Gomez-0/+5
Add unimplemented `current_dll_path()` for WASI This is the only change needed to Rust to allow compiling rustfmt for WASI (rustfmt uses some internal rustc crates).
2025-06-01Add unimplemented `current_dll_path()` for WASITim Hutt-0/+5
This is the only change needed to Rust to allow compiling rustfmt for WASI (rustfmt uses some internal rustc crates).
2025-05-19current_dll_path: fix mistake in assertion messageRalf Jung-1/+1
2025-05-19dladdr cannot leave dli_fname to be nullRalf Jung-3/+1
2025-05-16Simplify current_dll_path for CygwinBerrysoft-22/+11
2025-05-15Experimental cygwin support in rustc王宇逸-1/+18
Co-authored-by: Ookiineko <chiisaineko@protonmail.com>
2025-03-21Cache current_dll_path outputbjorn3-56/+66
Computing the current dll path is somewhat expensive relative to other work when compiling `fn main() {}` as `dladdr` needs to iterate over the symbol table of librustc_driver.so until it finds a match.
2025-03-12Don't return an error from get_or_default_sysrootbjorn3-27/+21
All callers unwrap the result.
2025-03-07compiler: Use size_of from the prelude instead of importedThalia Archibald-1/+1
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-01-21bumpt compiler and tools to windows 0.59klensy-1/+1
2024-11-15rustc_metadata: Preprocess search paths for better performancePiotr Osiewicz-16/+23
Over in Zed we've noticed that loading crates for a large-ish workspace can take almost 200ms. We've pinned it down to how rustc searches for paths, as it performs a linear search over the list of candidate paths. In our case the candidate list had about 20k entries which we had to iterate over for each dependency being loaded. This commit introduces a simple FilesIndex that's just a sorted Vec under the hood. Since crates are looked up by both prefix and suffix, we perform a range search on said Vec (which constraints the search space based on prefix) and follow up with a linear scan of entries with matching suffixes. FilesIndex is also pre-filtered before any queries are performed using available target information; query prefixes/sufixes are based on the target we are compiling for, so we can remove entries that can never match up front. Overall, this commit brings down build time for us in dev scenarios by about 6%. 100ms might not seem like much, but this is a constant cost that each of our workspace crates has to pay, even when said crate is miniscule.
2024-11-02Rename target triple to target tuple in many places in the compilerNoratrieb-2/+2
This changes the naming to the new naming, used by `--print target-tuple`. It does not change all locations, but many.
2024-10-30fix libc call from i8 to u8Henry Jiang-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-3/+3
2024-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-1/+1
2024-08-22rustc: Simplify getting sysroot library directoryVadim Petrochenkov-15/+1
2024-08-03linker: Pass fewer search directories to the linkerVadim Petrochenkov-0/+5
2024-07-29Reformat `use` declarations.Nicholas Nethercote-10/+9
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-06Improve naming and path operations in crate loaderNilstrieb-9/+9
Simplify the path operation with `join`, clarify some of the names.
2024-05-21add helper to target bin pathRémy Rakic-0/+8
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-4/+3
2024-04-12linker: Remove laziness and caching from native search directory walksVadim Petrochenkov-5/+0
It shouldn't be necessary for performance now.
2024-04-12linker: Avoid some allocations in search directory iterationVadim Petrochenkov-2/+2
2024-03-11Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cjgillotJubilee-0/+6
Allow targets to override default codegen backend Implements https://github.com/rust-lang/compiler-team/issues/670.
2024-02-18windows bump to 0.52klensy-1/+0
2024-02-15Refactor out a repeating pattern with `get_or_default_sysroot`Maybe Waffle-0/+6
2023-11-30Remove unused `FileMatch`.Nicholas Nethercote-6/+0
2023-05-09bump windows crate 0.46 -> 0.48 in workspaceklensy-2/+2
2023-04-14make sysroot finding compatible with multiarch systemsozkanonur-17/+18
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-03-30Rollup merge of #109522 - bzEq:aix-current-dll-path, r=NilstriebMichael Goulet-0/+44
Implement current_dll_path for AIX AIX doesn't feature `dladdr`, use `loadquery` instead. `loadquery` is documented in https://www.ibm.com/docs/en/aix/7.2?topic=l-loadquery-subroutine.
2023-03-28Check data segment rangeKai Luo-6/+5
2023-03-28Address commentKai Luo-5/+11
2023-03-24Avoid misalignKai Luo-3/+8
2023-03-23Rollup merge of #109231 - Zoxc:fs-non-canon, r=eholkMatthias Krüger-2/+3
Add `try_canonicalize` to `rustc_fs_util` and use it over `fs::canonicalize` This adds `try_canonicalize` which tries to call `fs::canonicalize`, but falls back to `std::path::absolute` if it fails. Existing `canonicalize` calls are replaced with it. `fs::canonicalize` is not guaranteed to work on Windows.
2023-03-23Implement current_dll_path for AIXKai Luo-0/+34
2023-03-20migrate compiler, bootstrap, and compiletest to windows-rsAndy Russell-22/+25
2023-03-16Add `try_canonicalize` to `rustc_fs_util` and use it over `fs::canonicalize`John Kåre Alsaker-2/+3
2023-02-28compiler/rustc_session: fix sysroot detection logic ...liushuyu-1/+11
... on systems where /usr/lib contains a multi-arch structure
2023-02-16Replace some `then`s with some `then_some`sMaybe Waffle-1/+1
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-1/+1
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-1/+1
2022-12-19clippy::complexity fixesMatthias Krüger-2/+2
filter_next needless_question_mark bind_instead_of_map manual_find derivable_impls map_identity redundant_slicing skip_while_next unnecessary_unwrap needless_bool
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-1/+0
2022-11-04improve `filesearch::get_or_default_sysroot` r=ozkanonurOnur Özkan-16/+120
Signed-off-by: Onur Özkan <work@onurozkan.dev>
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-03-24Prettify rustc_session fmt with capturing args (nfc)Jubilee Young-1/+1