[all-commits] [llvm/llvm-project] 798783: [Clang][Driver] Final phase also determined by inp...
Michael Kruse via All-commits
all-commits at lists.llvm.org
Mon Sep 7 06:35:02 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7987830e776411a0de84c0c75e9f1059acadceb5
https://github.com/llvm/llvm-project/commit/7987830e776411a0de84c0c75e9f1059acadceb5
Author: Michael Kruse <llvm-project at meinersbur.de>
Date: 2026-09-07 (Mon, 07 Sep 2026)
Changed paths:
M clang/include/clang/Driver/Driver.h
M clang/include/clang/Driver/Types.h
M clang/lib/Driver/Driver.cpp
M clang/lib/Driver/Types.cpp
A clang/test/Driver/Inputs/object0.o
M clang/test/Driver/aix-ld.c
A clang/test/Driver/pch-inputs.h
Log Message:
-----------
[Clang][Driver] Final phase also determined by input (#218802)
Before this PR, `getFinalPhase` assumed that when no option is give then
the final phase will a linking step. This is objectively wrong: For
instance passing a header file as input (`-x c-header` or `-x
c++-header`) triggers precompilation, not linking. Other inputs that do
not have a link phase as specified by `Types.def`
are `.dxo`, `.ifs`, and `.hlsl` files.
Instead of defaulting to link in the absence of any action flag, this PR
uses the last phase that `Types.def` specifies for the given input
files. The effect of this is relevant when handling linking options
which are categorized as "input" like any other file.
Usually these should be filtered out if
there is no linking step. But, since `getFinalPhase` says there is a
linking flag, those are forwarded to the precompile handling which gets
confused with such "inputs". An accurate determination of the final
phase filters out those non-applicable linker options.
Note that the second condition of
`clang::diag::warn_drv_input_file_unused` was inverted: It would print
> clang: warning: -lfoo: 'linker' input unused when '' is present
[-Wunused-command-line-argument]
when passing a linker option to a non-link command that is not the
result of an action command flag. Inversely, when a non-link action flag
was used, it wasn't mentioned in the diagnostic message.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list