This is an archive of the discontinued LLVM Phabricator instance.

[clang][Driver] allow tilde in user config dir
ClosedPublic

Authored by paperchalice on Oct 28 2022, 4:15 AM.

Details

Summary

This patch allows users to configure clang with option e.g. -DCLANG_CONFIG_FILE_USER_DIR=~/.config/clang or invoke clang with --config-user-dir=~/.config/clang.

Diff Detail

Event Timeline

paperchalice created this revision.Oct 28 2022, 4:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 28 2022, 4:15 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
paperchalice requested review of this revision.Oct 28 2022, 4:15 AM
MaskRay accepted this revision.Oct 28 2022, 3:45 PM

clang/test/Driver/config-file3.c tests --config-user-dir= but I cannot think of a portable way testing this.
RUN: echo ~; %clang -### --config-user-dir=~ ... doesn't work as the selected directory is not dumped.

This revision is now accepted and ready to land.Oct 28 2022, 3:45 PM

clang/test/Driver/config-file3.c tests --config-user-dir= but I cannot think of a portable way testing this.
RUN: echo ~; %clang -### --config-user-dir=~ ... doesn't work as the selected directory is not dumped.

I can dump user configuration file directory via clang --config-user-dir=<some directory> -v, but
RUN: { echo tilde: ~; %clang -v --config-user-dir=~ 2>&1; } | FileCheck %s -check-prefix CHECK-TILDE doesn't work on Windows.

I would appreciate if someone can commit this change.

mgorny requested changes to this revision.Oct 28 2022, 10:05 PM

I think you should be able to test it via overriding HOME envvar. I suppose you can limit the test to Unix.

This revision now requires changes to proceed.Oct 28 2022, 10:05 PM

Add test on Unix.

mgorny accepted this revision.Oct 28 2022, 10:57 PM

Thanks. I haven't tested it but if it works for you and the test passes, LGTM.

@MaskRay, would you be able to test and push it? I don't have a recent clang build tree handy.

This revision is now accepted and ready to land.Oct 28 2022, 10:57 PM

Ah, I'm sorry for the delay. I have time right now, so I'll test and push it.

This revision was automatically updated to reflect the committed changes.
MaskRay added inline comments.Feb 28 2023, 12:17 PM
clang/test/Driver/config-file3.c
227

-### is missing. I fixed it in 37216b4b3aaab1fb293b7f628f8dd4999c0abb80