-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Driver] Add exclusive-group feature to multilib.yaml. (#69447)
This allows a YAML-based multilib configuration to specify explicitly that a subset of its library directories are alternatives to each other, i.e. at most one of that subset should be selected. So if you have multiple sysroots each including a full set of headers and libraries, you can mark them as members of the same mutually exclusive group, and then you'll be sure that only one of them is selected, even if two or more are compatible with the compile options. This is particularly important in multilib setups including the libc++ headers, where selecting the include directories from two different sysroots can cause an actual build failure. This occurs when including <stdio.h>, for example: libc++'s stdio.h is included first, and will try to use `#include_next` to fetch the underlying libc's version. But if there are two include directories from separate multilibs, then both of their C++ include directories will end up on the include path first, followed by both the C directories. So the `#include_next` from the first libc++ stdio.h will include the second libc++ stdio.h, which will do nothing because it has the same include guard macro, and the libc header won't ever be included at all. If more than one of the options in an exclusive group matches the given flags, the last one wins. The syntax for specifying this in multilib.yaml is to define a Groups section in which you specify your group names, and for each one, declare it to have Type: Exclusive. (This reserves space in the syntax for maybe adding other group types later, such as a group of mutually _dependent_ things that you must have all or none of.) Then each Variant record that's a member of a group has a Group: property giving that group's name.
- Loading branch information
1 parent
6902082
commit 8727982
Showing
4 changed files
with
218 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# UNSUPPORTED: system-windows | ||
|
||
# RUN: rm -rf %t | ||
|
||
# RUN: mkdir -p %t/baremetal_multilib/bin | ||
# RUN: ln -s %clang %t/baremetal_multilib/bin/clang | ||
|
||
# RUN: mkdir -p %t/baremetal_multilib/lib/clang-runtimes | ||
# RUN: ln -s %s %t/baremetal_multilib/lib/clang-runtimes/multilib.yaml | ||
|
||
# RUN: %t/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out --target=thumbv7em-none-unknown-eabi --sysroot= 2>%t.err | ||
|
||
# RUN: FileCheck -DSYSROOT=%t/baremetal_multilib %s < %t.err --check-prefix=POS | ||
# RUN: FileCheck -DSYSROOT=%t/baremetal_multilib %s < %t.err --check-prefix=NEG | ||
|
||
# Expected results: | ||
# | ||
# Due to the Mappings section, all six of these library directories should | ||
# match the command-line flag --target=thumbv7em-none-unknown-eabi. | ||
# | ||
# The two "non_exclusive" directories, which don't have an ExclusiveGroup at | ||
# all, should both be selected. So should the two "own_group", each of which | ||
# specifies a different value of ExclusiveGroup. But the three "exclusive", | ||
# which have the _same_ ExclusiveGroup value, should not: the third one wins. | ||
# So we expect five of these seven directories to show up in the clang-cc1 | ||
# command line, but not testdir1_exclusive or testdir2_exclusive. | ||
|
||
# POS-DAG: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir1_non_exclusive/include/c++/v1" | ||
# POS-DAG: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir2_non_exclusive/include/c++/v1" | ||
# POS-DAG: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir3_exclusive/include/c++/v1" | ||
# POS-DAG: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir1_own_group/include/c++/v1" | ||
# POS-DAG: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir2_own_group/include/c++/v1" | ||
|
||
# NEG-NOT: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir1_exclusive/include/c++/v1" | ||
# NEG-NOT: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir2_exclusive/include/c++/v1" | ||
|
||
--- | ||
MultilibVersion: 1.0 | ||
|
||
Groups: | ||
- Name: actually_exclude_something | ||
Type: Exclusive | ||
|
||
- Name: foo | ||
Type: Exclusive | ||
|
||
- Name: bar | ||
Type: Exclusive | ||
|
||
Variants: | ||
- Dir: testdir1_non_exclusive | ||
Flags: [--target=thumbv7m-none-unknown-eabi] | ||
|
||
- Dir: testdir2_non_exclusive | ||
Flags: [--target=thumbv7em-none-unknown-eabi] | ||
|
||
- Dir: testdir1_exclusive | ||
Flags: [--target=thumbv7m-none-unknown-eabi] | ||
Group: actually_exclude_something | ||
|
||
- Dir: testdir2_exclusive | ||
Flags: [--target=thumbv7em-none-unknown-eabi] | ||
Group: actually_exclude_something | ||
|
||
- Dir: testdir3_exclusive | ||
Flags: [--target=thumbv7em-none-unknown-eabi] | ||
Group: actually_exclude_something | ||
|
||
- Dir: testdir1_own_group | ||
Flags: [--target=thumbv7m-none-unknown-eabi] | ||
Group: foo | ||
|
||
- Dir: testdir2_own_group | ||
Flags: [--target=thumbv7em-none-unknown-eabi] | ||
Group: bar | ||
|
||
Mappings: | ||
- Match: --target=thumbv7em-none-unknown-eabi | ||
Flags: [--target=thumbv7m-none-unknown-eabi] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# UNSUPPORTED: system-windows | ||
|
||
# RUN: rm -rf %t | ||
|
||
# RUN: mkdir -p %t/baremetal_multilib/bin | ||
# RUN: ln -s %clang %t/baremetal_multilib/bin/clang | ||
|
||
# RUN: mkdir -p %t/baremetal_multilib/lib/clang-runtimes | ||
# RUN: ln -s %s %t/baremetal_multilib/lib/clang-runtimes/multilib.yaml | ||
|
||
# RUN: %t/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out --target=thumbv7em-none-unknown-eabi --sysroot= 2>%t.err | ||
# RUN: FileCheck %s < %t.err | ||
|
||
--- | ||
MultilibVersion: 1.0 | ||
|
||
Groups: | ||
- Name: group1 | ||
Type: Nonsense | ||
|
||
Variants: | ||
- Dir: testdir1 | ||
Flags: [--target=thumbv7m-none-unknown-eabi] | ||
Group: nonexistent_group_name | ||
|
||
# CHECK: error: unknown enumerated scalar | ||
# CHECK: error: multilib "testdir1" specifies undefined group name "nonexistent_group_name" |