[clang] [Driver][Fuchsia] Support multilib for C++ include dir (PR #95815)
Petr Hosek via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 17 10:46:59 PDT 2024
https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/95815
We generate a separate `__config_site` for each multilib and thus need to add the additional include dir if it exists.
>From cbd278fe0e49e5297f3d48d5e14f012a81fce570 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 11 Jun 2024 06:21:44 +0000
Subject: [PATCH] [Driver][Fuchsia] Support multilib for C++ include dir
We generate a separate `__config_site` for each multilib and thus need
to add the additional include dir if it exists.
---
clang/lib/Driver/ToolChains/Fuchsia.cpp | 14 ++++++++++++--
.../asan+noexcept/c++/v1/.keep | 0
.../aarch64-unknown-fuchsia/asan/c++/v1/.keep | 0
.../aarch64-unknown-fuchsia/compat/c++/v1/.keep | 0
.../hwasan+noexcept/c++/v1/.keep | 0
.../aarch64-unknown-fuchsia/hwasan/c++/v1/.keep | 0
.../noexcept/c++/v1/.keep | 0
.../asan+noexcept/c++/v1/.keep | 0
.../riscv64-unknown-fuchsia/asan/c++/v1/.keep | 0
.../riscv64-unknown-fuchsia/compat/c++/v1/.keep | 0
.../hwasan+noexcept/c++/v1/.keep | 0
.../riscv64-unknown-fuchsia/hwasan/c++/v1/.keep | 0
.../noexcept/c++/v1/.keep | 0
.../asan+noexcept/c++/v1/.keep | 0
.../x86_64-unknown-fuchsia/asan/c++/v1/.keep | 0
.../x86_64-unknown-fuchsia/compat/c++/v1/.keep | 0
.../hwasan+noexcept/c++/v1/.keep | 0
.../x86_64-unknown-fuchsia/hwasan/c++/v1/.keep | 0
.../noexcept/c++/v1/.keep | 0
.../ubsan+noexcept/libc++.so | 0
.../lib/aarch64-unknown-fuchsia/ubsan/libc++.so | 0
.../ubsan+noexcept/libc++.so | 0
.../lib/x86_64-unknown-fuchsia/ubsan/libc++.so | 0
clang/test/Driver/fuchsia.cpp | 17 ++++++++++++-----
24 files changed, 24 insertions(+), 7 deletions(-)
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/asan+noexcept/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/asan/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/compat/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/hwasan+noexcept/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/hwasan/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/noexcept/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/asan+noexcept/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/asan/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/compat/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/hwasan+noexcept/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/hwasan/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/noexcept/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/asan+noexcept/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/asan/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/compat/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/hwasan+noexcept/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/hwasan/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/noexcept/c++/v1/.keep
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-unknown-fuchsia/ubsan+noexcept/libc++.so
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-unknown-fuchsia/ubsan/libc++.so
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-unknown-fuchsia/ubsan+noexcept/libc++.so
create mode 100644 clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-unknown-fuchsia/ubsan/libc++.so
diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 598289f48ff43..6daa73c7a54c8 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -433,13 +433,23 @@ void Fuchsia::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
if (Version.empty())
return;
- // First add the per-target include path.
+ // First add the per-target multilib include dir.
+ if (!SelectedMultilibs.empty() && !SelectedMultilibs.back().isDefault()) {
+ const Multilib &M = SelectedMultilibs.back();
+ SmallString<128> TargetDir(Path);
+ llvm::sys::path::append(TargetDir, Target, M.gccSuffix(), "c++", Version);
+ if (getVFS().exists(TargetDir)) {
+ addSystemInclude(DriverArgs, CC1Args, TargetDir);
+ }
+ }
+
+ // Second add the per-target include dir.
SmallString<128> TargetDir(Path);
llvm::sys::path::append(TargetDir, Target, "c++", Version);
if (getVFS().exists(TargetDir))
addSystemInclude(DriverArgs, CC1Args, TargetDir);
- // Second add the generic one.
+ // Third the generic one.
SmallString<128> Dir(Path);
llvm::sys::path::append(Dir, "c++", Version);
addSystemInclude(DriverArgs, CC1Args, Dir);
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/asan+noexcept/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/asan+noexcept/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/asan/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/asan/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/compat/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/compat/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/hwasan+noexcept/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/hwasan+noexcept/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/hwasan/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/hwasan/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/noexcept/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/aarch64-unknown-fuchsia/noexcept/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/asan+noexcept/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/asan+noexcept/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/asan/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/asan/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/compat/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/compat/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/hwasan+noexcept/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/hwasan+noexcept/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/hwasan/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/hwasan/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/noexcept/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/riscv64-unknown-fuchsia/noexcept/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/asan+noexcept/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/asan+noexcept/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/asan/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/asan/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/compat/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/compat/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/hwasan+noexcept/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/hwasan+noexcept/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/hwasan/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/hwasan/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/noexcept/c++/v1/.keep b/clang/test/Driver/Inputs/basic_fuchsia_tree/include/x86_64-unknown-fuchsia/noexcept/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-unknown-fuchsia/ubsan+noexcept/libc++.so b/clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-unknown-fuchsia/ubsan+noexcept/libc++.so
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-unknown-fuchsia/ubsan/libc++.so b/clang/test/Driver/Inputs/basic_fuchsia_tree/lib/aarch64-unknown-fuchsia/ubsan/libc++.so
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-unknown-fuchsia/ubsan+noexcept/libc++.so b/clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-unknown-fuchsia/ubsan+noexcept/libc++.so
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-unknown-fuchsia/ubsan/libc++.so b/clang/test/Driver/Inputs/basic_fuchsia_tree/lib/x86_64-unknown-fuchsia/ubsan/libc++.so
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/fuchsia.cpp b/clang/test/Driver/fuchsia.cpp
index 69d5cb19041a7..540c1e655a3be 100644
--- a/clang/test/Driver/fuchsia.cpp
+++ b/clang/test/Driver/fuchsia.cpp
@@ -88,16 +88,16 @@
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: -fuse-ld=ld 2>&1\
// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86
-// RUN: %clangxx -### %s --target=x86_64-unknown-fuchsia -fsanitize=address \
+// RUN: %clangxx -### %s --target=x86_64-unknown-fuchsia -fno-exceptions \
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: -fuse-ld=ld 2>&1\
-// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-ASAN-X86
-// RUN: %clangxx -### %s --target=x86_64-unknown-fuchsia -fno-exceptions \
+// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-NOEXCEPT-X86
+// RUN: %clangxx -### %s --target=x86_64-unknown-fuchsia -fsanitize=address \
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: -fuse-ld=ld 2>&1\
-// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-NOEXCEPT-X86
+// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-ASAN-X86
// RUN: %clangxx -### %s --target=x86_64-unknown-fuchsia -fsanitize=address -fno-exceptions \
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
@@ -131,8 +131,15 @@
// RUN: -fuse-ld=ld 2>&1\
// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-COMPAT-X86
// CHECK-MULTILIB-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK-MULTILIB-ASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}asan"
+// CHECK-MULTILIB-NOEXCEPT-X86: "-internal-isystem" "{{.*[/\\]}}include{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}noexcept{{/|\\\\}}c++{{/|\\\\}}v1"
+// CHECK-MULTILIB-ASAN-X86: "-internal-isystem" "{{.*[/\\]}}include{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}asan{{/|\\\\}}c++{{/|\\\\}}v1"
+// CHECK-MULTILIB-ASAN-NOEXCEPT-X86: "-internal-isystem" "{{.*[/\\]}}include{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}asan+noexcept{{/|\\\\}}c++{{/|\\\\}}v1"
+// CHECK-MULTILIB-HWASAN-X86: "-internal-isystem" "{{.*[/\\]}}include{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}hwasan{{/|\\\\}}c++{{/|\\\\}}v1"
+// CHECK-MULTILIB-HWASAN-NOEXCEPT-X86: "-internal-isystem" "{{.*[/\\]}}include{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}hwasan+noexcept{{/|\\\\}}c++{{/|\\\\}}v1"
+// CHECK-MULTILIB-COMPAT-X86: "-internal-isystem" "{{.*[/\\]}}include{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}compat{{/|\\\\}}c++{{/|\\\\}}v1"
+// CHECK-MULTILIB-X86: "-internal-isystem" "{{.*[/\\]}}include{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}c++{{/|\\\\}}v1"
// CHECK-MULTILIB-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}noexcept"
+// CHECK-MULTILIB-ASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}asan"
// CHECK-MULTILIB-ASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}asan+noexcept"
// CHECK-MULTILIB-HWASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}hwasan"
// CHECK-MULTILIB-HWASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}hwasan+noexcept"
More information about the cfe-commits
mailing list