Skip to content

[clangd] Forward --target to system include extraction #65824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2023

Conversation

mincrmatt12
Copy link
Contributor

Some clang multilib configurations (such as the one currently used in the beta ARM LLVM toolchain) wind up only reporting the C++ include paths properly if they get passed the correct target. This patch ensures the --target (or -target) arguments are correctly sent to the queried driver.

@mincrmatt12 mincrmatt12 requested a review from a team as a code owner September 9, 2023 00:10
@github-actions github-actions bot added the clangd label Sep 9, 2023
Copy link
Collaborator

@HighCommander4 HighCommander4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch!

There is some prior work on this which I've looked over and will summarize:

  • This change was previously proposed in D138546
  • During its review, we discovered that clangd would run a processing step on the compile command that sometimes adds a -target flag, inferred from the compiler name, to the command, before running SystemIncludeExtractor, and propagating -target to the extraction command then caused an error if the compiler was a gcc (since gcc does not support -target).
    • The patch was updated to fix this (by moving that processing step to happen after SystemIncludeExtractor). That change was since independently made and merged in D143436.
  • We also discovered that SystemIncludeExtractor was failing to include arguments like --sysroot in the key under which it caches its results (and adding -target would have compounded that problem).
    • That has since been fixed in D146941.

Activity on D138546 has since stalled, but the next step would have been to rebase it on top of D143436 and D146941... which is basically what this patch does!

So, I think this patch should be good to go (modulo a small bug I commented on inline).

cc @cpsauer (author of D138546) as an FYI

Some clang multilib configurations (such as the one currently used in
the beta ARM LLVM toolchain) wind up only reporting the C++ include paths
properly if they get passed the correct target.
@cpsauer
Copy link

cpsauer commented Sep 10, 2023

Thanks so much for carrying this forward, Nathan.

@HighCommander4 HighCommander4 merged commit 4af340a into llvm:main Sep 11, 2023
@cpsauer
Copy link

cpsauer commented Sep 11, 2023

🎉

ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this pull request Sep 19, 2023
Some clang multilib configurations (such as the one currently used in
the [beta ARM LLVM
toolchain](https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm))
wind up only reporting the C++ include paths properly if they get passed
the correct target. This patch ensures the `--target` (or `-target`)
arguments are correctly sent to the queried driver.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants