[clang] [Driver] Add ExclusiveGroup feature to multilib.yaml. (PR #69447)

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 25 00:35:43 PDT 2023


================
@@ -0,0 +1,69 @@
+# REQUIRES: shell
+# 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=TESTDIR1_NON_EXCLUSIVE
+# RUN: FileCheck -DSYSROOT=%t/baremetal_multilib %s < %t.err --check-prefix=TESTDIR2_NON_EXCLUSIVE
+# RUN: FileCheck -DSYSROOT=%t/baremetal_multilib %s < %t.err --check-prefix=TESTDIR1_EXCLUSIVE
+# RUN: FileCheck -DSYSROOT=%t/baremetal_multilib %s < %t.err --check-prefix=TESTDIR2_EXCLUSIVE
+# RUN: FileCheck -DSYSROOT=%t/baremetal_multilib %s < %t.err --check-prefix=TESTDIR1_OWN_GROUP
+# RUN: FileCheck -DSYSROOT=%t/baremetal_multilib %s < %t.err --check-prefix=TESTDIR2_OWN_GROUP
+
+# 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 two "exclusive", which
+# have the _same_ ExclusiveGroup value, should not: the second one wins. So we
+# expect five of these six directories to show up in the clang-cc1 command
+# line, but not testdir1_exclusive.
+
+# TESTDIR1_NON_EXCLUSIVE: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir1_non_exclusive/include/c++/v1"
+# TESTDIR2_NON_EXCLUSIVE: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir2_non_exclusive/include/c++/v1"
+# TESTDIR2_EXCLUSIVE: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir2_exclusive/include/c++/v1"
+# TESTDIR1_OWN_GROUP: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir1_own_group/include/c++/v1"
+# TESTDIR2_OWN_GROUP: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/testdir2_own_group/include/c++/v1"
----------------
petrhosek wrote:

This comment is unrelated to this change, but the fact that we end up with `[[SYSROOT]]/bin/../lib/clang-runtimes/<name>/include/c++/v1` is suboptimal.

libc++ headers are designed to be target agnostic with the exception of `__config_site` to avoid having to distribute multiple copies of headers, one for each target or multilib.

Ideally, what we should end up with is something like this:
```
-internal-isystem [[SYSROOT]]/bin/../include/thumbv7m-none-unknown-eabi/testdir1_non_exclusive/include/c++/v1
-internal-isystem [[SYSROOT]]/bin/../include/thumbv7m-none-unknown-eabi/testdir2_non_exclusive/include/c++/v1
-internal-isystem [[SYSROOT]]/bin/../include/thumbv7m-none-unknown-eabi/testdir2_exclusive/include/c++/v1
-internal-isystem [[SYSROOT]]/bin/../include/thumbv7m-none-unknown-eabi/testdir1_own_group/include/c++/v1
-internal-isystem [[SYSROOT]]/bin/../include/thumbv7m-none-unknown-eabi/testdir2_own_group/include/c++/v1
-internal-isystem [[SYSROOT]]/bin/../include/c++/v1
```
I have filed https://github.com/llvm/llvm-project/issues/70172 to track this.

https://github.com/llvm/llvm-project/pull/69447


More information about the cfe-commits mailing list