https://github.com/ributzka created https://github.com/llvm/llvm-project/pull/77120
- [clang][modules] Remove no longer needed autolink test for TBD files. - [clang][modules] Remove `_Private` suffix from framework auto-link hints. >From 166bc82a6bd7fa2dff6fb405aadcf6c2a9d48f51 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka <juer...@ributzka.de> Date: Thu, 14 Dec 2023 16:07:33 -0800 Subject: [PATCH 1/2] [clang][modules] Remove no longer needed autolink test for TBD files. The autolink feature no longer checks for the existence of a binary or TBD file. Hence, the autolink TBD test can be removed. --- .../Inputs/AutolinkTBD.framework/AutolinkTBD.tbd | 1 - .../AutolinkTBD.framework/Headers/AutolinkTBD.h | 1 - clang/test/Modules/autolinkTBD.m | 16 ---------------- 3 files changed, 18 deletions(-) delete mode 100644 clang/test/Modules/Inputs/AutolinkTBD.framework/AutolinkTBD.tbd delete mode 100644 clang/test/Modules/Inputs/AutolinkTBD.framework/Headers/AutolinkTBD.h delete mode 100644 clang/test/Modules/autolinkTBD.m diff --git a/clang/test/Modules/Inputs/AutolinkTBD.framework/AutolinkTBD.tbd b/clang/test/Modules/Inputs/AutolinkTBD.framework/AutolinkTBD.tbd deleted file mode 100644 index 4aa0f85d0d56aa..00000000000000 --- a/clang/test/Modules/Inputs/AutolinkTBD.framework/AutolinkTBD.tbd +++ /dev/null @@ -1 +0,0 @@ -empty file - clang only needs to check if it exists. diff --git a/clang/test/Modules/Inputs/AutolinkTBD.framework/Headers/AutolinkTBD.h b/clang/test/Modules/Inputs/AutolinkTBD.framework/Headers/AutolinkTBD.h deleted file mode 100644 index 914983c49636c2..00000000000000 --- a/clang/test/Modules/Inputs/AutolinkTBD.framework/Headers/AutolinkTBD.h +++ /dev/null @@ -1 +0,0 @@ -extern int foo(void); diff --git a/clang/test/Modules/autolinkTBD.m b/clang/test/Modules/autolinkTBD.m deleted file mode 100644 index 69253294f7b816..00000000000000 --- a/clang/test/Modules/autolinkTBD.m +++ /dev/null @@ -1,16 +0,0 @@ -// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}} -// RUN: rm -rf %t -// RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s | FileCheck %s -// RUN: %clang_cc1 -emit-llvm -fno-autolink -o - -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s | FileCheck --check-prefix=CHECK-AUTOLINK-DISABLED %s - -@import AutolinkTBD; - -int f(void) { - return foo(); -} - -// CHECK: !llvm.linker.options = !{![[AUTOLINK_FRAMEWORK:[0-9]+]]} -// CHECK: ![[AUTOLINK_FRAMEWORK]] = !{!"-framework", !"AutolinkTBD"} - -// CHECK-AUTOLINK-DISABLED: !llvm.module.flags -// CHECK-AUTOLINK-DISABLED-NOT: !llvm.linker.options >From 9537441fcf2e7e2f0c33f0076d9901f3e67577fe Mon Sep 17 00:00:00 2001 From: Juergen Ributzka <juer...@ributzka.de> Date: Thu, 4 Jan 2024 15:58:51 -0800 Subject: [PATCH 2/2] [clang][modules] Remove `_Private` suffix from framework auto-link hints. The auto-link hint for a framework is generated from the module name. For a given framework <name>, the public module name is <name>, while the private module name is <name>_Private. This change removes the `_Private` suffix from the module name to get the actual framework name for the auto-link hint. --- clang/lib/Lex/ModuleMap.cpp | 4 +++- clang/test/Modules/autolink_private_module.m | 25 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 clang/test/Modules/autolink_private_module.m diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index ea5d13deb11470..42d55d09ea5a13 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -984,7 +984,9 @@ static void inferFrameworkLink(Module *Mod) { assert(!Mod->isSubFramework() && "Can only infer linking for top-level frameworks"); - Mod->LinkLibraries.push_back(Module::LinkLibrary(Mod->Name, + StringRef FrameworkName(Mod->Name); + FrameworkName.consume_back("_Private"); + Mod->LinkLibraries.push_back(Module::LinkLibrary(FrameworkName.str(), /*IsFramework=*/true)); } diff --git a/clang/test/Modules/autolink_private_module.m b/clang/test/Modules/autolink_private_module.m new file mode 100644 index 00000000000000..54bebc3a587b1b --- /dev/null +++ b/clang/test/Modules/autolink_private_module.m @@ -0,0 +1,25 @@ +// Test that autolink hints for frameworks don't use the private module name. +// RUN: rm -rf %t && mkdir %t +// RUN: split-file %s %t + +// RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t/ModuleCache -fmodules -fimplicit-module-maps -F %t/Frameworks %t/test.m | FileCheck %s + +// CHECK: !{!"-framework", !"Autolink"} +// CHECK-NOT: !{!"-framework", !"Autolink_Private"} + +//--- test.m +#include <Autolink/Autolink.h> +#include <Autolink/Autolink_Private.h> + +//--- Frameworks/Autolink.framework/Headers/Autolink.h +void public(); + +//--- Frameworks/Autolink.framework/PrivateHeaders/Autolink_Private.h +void private(); + +//--- Frameworks/Autolink.framework/Modules/module.modulemap +framework module Autolink { header "Autolink.h"} + +//--- Frameworks/Autolink.framework/Modules/module.private.modulemap +framework module Autolink_Private { header "Autolink_Private.h"} + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits