Callback for `for_each_path` now indicates machine-disambiguation.
The `for_each_path` function in GCC's driver now passes a boolean flag to its callback, indicating whether the current directory in the search path is machine-…
This change modifies the for_each_path function in GCC’s driver to include a new boolean argument in its callback. This argument signifies whether the directory being processed is machine-disambiguated, meaning it’s intended for a specific target architecture. This added context allows subsequent logic, such as find_a_program, to make more informed decisions about which filenames to search for, paving the way for improved tool discovery in cross-compilation scenarios.
In Details
The for_each_path function, residing in gcc.cc, is a core utility for iterating over various search paths used by the GCC driver. This commit extends its callback signature to include an additional bool parameter, machine_disambiguated. This flag indicates if the currently iterated directory in the search path (e.g., path/x86_64-linux-gnu/) was specifically constructed to resolve machine-specific tool needs. While this change itself doesn't alter search behavior, it provides critical information to callers like find_a_program (as demonstrated in the subsequent patch) to dynamicall…
For Context
When GCC needs to find a tool, it searches through a list of directories, similar to how your operating system finds programs. The for_each_path function helps GCC go through these directories one by one. This update adds a small but important piece of information: for each directory, it now tells the calling code whether that directory is considered 'machine-specific.' This means if a folder is explicitly designed for tools of a particular computer architecture (like an ARM processor), for_each_path now communicates that. This allows other parts of GCC to be smarter when looking for tools; for instance, if it's in a machine-specific directory, it might look for tool names that are also specific to that machine, making the overall tool-finding process more accurate.