Skip to content

Commit

Permalink
[clang][Fuchsia] Introduce compat multilibs
Browse files Browse the repository at this point in the history
These are GCC-compatible multilibs that use the generic Itanium C++ ABI
instead of the Fuchsia C++ ABI.

Differential Revision: https://reviews.llvm.org/D102030
  • Loading branch information
PiJoules committed May 11, 2021
1 parent 40e3aa3 commit 5cb1772
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clang/lib/Driver/ToolChains/Fuchsia.cpp
Expand Up @@ -242,6 +242,8 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
.flag("+fsanitize=hwaddress")
.flag("-fexceptions")
.flag("+fno-exceptions"));
// Use Itanium C++ ABI for the compat multilib.
Multilibs.push_back(Multilib("compat", {}, {}, 12).flag("+fc++-abi=itanium"));

Multilibs.FilterOut([&](const Multilib &M) {
std::vector<std::string> RD = FilePaths(M);
Expand All @@ -263,6 +265,8 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
options::OPT_fno_experimental_relative_cxx_abi_vtables,
/*default=*/false),
"fexperimental-relative-c++-abi-vtables", Flags);
addMultilibFlag(Args.getLastArgValue(options::OPT_fcxx_abi_EQ) == "itanium",
"fc++-abi=itanium", Flags);

Multilibs.setFilePathsCallback(FilePaths);

Expand Down
Empty file.
18 changes: 18 additions & 0 deletions clang/test/Driver/fuchsia.cpp
Expand Up @@ -144,6 +144,23 @@
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: -fuse-ld=lld 2>&1\
// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-NOEXCEPT-X86

// Test compat multilibs.
// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -fc++-abi=itanium \
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: -fuse-ld=lld 2>&1\
// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-COMPAT-X86
// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -fc++-abi=itanium -fc++-abi=fuchsia \
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: -fuse-ld=lld 2>&1\
// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86
// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -fc++-abi=fuchsia -fc++-abi=itanium \
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
// RUN: -fuse-ld=lld 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: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}noexcept"
Expand All @@ -156,4 +173,5 @@
// CHECK-MULTILIB-HWASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}hwasan+noexcept"
// CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}relative-vtables+hwasan"
// CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}relative-vtables+hwasan+noexcept"
// CHECK-MULTILIB-COMPAT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}compat"
// CHECK-MULTILIB-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia"

0 comments on commit 5cb1772

Please sign in to comment.