Page MenuHomePhabricator

Driver tests: set `--sysroot=""` to support clang with `DEFAULT_SYSROOT`
ClosedPublic

Authored by broadwaylamb on Aug 27 2019, 3:07 PM.

Details

Summary

When testing clang that has been compiled with -DDEFAULT_SYSROOT set to some path,
some tests would fail. Override sysroot to be empty string for the tests to succeed when clang is configured with DEFAULT_SYSROOT.

Diff Detail

Repository
rL LLVM

Event Timeline

broadwaylamb created this revision.Aug 27 2019, 3:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 27 2019, 3:07 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Add --sysroot="" to some driver regression tests

These tests otherwise fail if clang is configured with DEFAULT_SYSROOT.

broadwaylamb retitled this revision from Driver tests: set `--sysroot` to "" to support toolchains with default sysroot to Driver tests: set `--sysroot=""` to support clang with `DEFAULT_SYSROOT`.
broadwaylamb edited the summary of this revision. (Show Details)

Remove unrelated change

I think that this is pretty easy to forget. Fortunately, last argument wins. Why not sink this into the %clang substitution in lit? That ensures that we run with an empty sysroot and then when the test needs to adjust the sysroot, it can do so explicitly.

I think that this is pretty easy to forget. Fortunately, last argument wins. Why not sink this into the %clang substitution in lit? That ensures that we run with an empty sysroot and then when the test needs to adjust the sysroot, it can do so explicitly.

This totally makes sense.

I've just tried to do it, but unfortunately some tests are failing, for example, Driver/cc1-response-files.c. The problem is that %clang is expanded to /path/to/clang --sysroot=, but the succeeding flags (such as -cc1) may be incompatible with --sysroot.

Or am I missing something?

I think that this is pretty easy to forget. Fortunately, last argument wins. Why not sink this into the %clang substitution in lit? That ensures that we run with an empty sysroot and then when the test needs to adjust the sysroot, it can do so explicitly.

I've just tried to do it, but unfortunately some tests are failing, for example, Driver/cc1-response-files.c. The problem is that %clang is expanded to /path/to/clang --sysroot=, but the succeeding flags (such as -cc1) may be incompatible with --sysroot.

Does the issue manifests itself with -cc1 only? We usually use %clang_cc1 in such cases, so probably those tests require update.

I think that this is pretty easy to forget. Fortunately, last argument wins. Why not sink this into the %clang substitution in lit? That ensures that we run with an empty sysroot and then when the test needs to adjust the sysroot, it can do so explicitly.

I've just tried to do it, but unfortunately some tests are failing, for example, Driver/cc1-response-files.c. The problem is that %clang is expanded to /path/to/clang --sysroot=, but the succeeding flags (such as -cc1) may be incompatible with --sysroot.

Does the issue manifests itself with -cc1 only? We usually use %clang_cc1 in such cases, so probably those tests require update.

Some Driver tests take a list of arguments from a file (for example clang/test/Driver/cc1-response-files.c), so we probably cannot use %clang_cc1 there

sepavloff accepted this revision.Sep 27 2019, 7:47 AM

I think that this is pretty easy to forget. Fortunately, last argument wins. Why not sink this into the %clang substitution in lit? That ensures that we run with an empty sysroot and then when the test needs to adjust the sysroot, it can do so explicitly.

I've just tried to do it, but unfortunately some tests are failing, for example, Driver/cc1-response-files.c. The problem is that %clang is expanded to /path/to/clang --sysroot=, but the succeeding flags (such as -cc1) may be incompatible with --sysroot.

Does the issue manifests itself with -cc1 only? We usually use %clang_cc1 in such cases, so probably those tests require update.

Some Driver tests take a list of arguments from a file (for example clang/test/Driver/cc1-response-files.c), so we probably cannot use %clang_cc1 there

The obvious solution in this case is to implement support of an environment variable, say SYSROOT or CLANG_SYSROOT, which would override hard-coded path (but not that specified by --sysroot option). Unfortunately some developers don't like use of environment variables, as it creates 'secret' control channel, and such patch would have high chance to be rejected. So probably this is all we can do here.

This patch looks good for me.

This revision is now accepted and ready to land.Sep 27 2019, 7:47 AM

Can someone please commit this?

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2019, 5:20 AM