[clang] [clang] Remove 'PCH' from more diagnostics that were wrong or misleading NFC (PR #110724)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/110724 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Remove 'PCH' from more diagnostics that were wrong or misleading NFC (PR #110724)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/110724 None >From b78a9a6649adaa1b0f7252733995ece7d1cebee0 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Mon, 30 Sep 2024 17:07:06 -0700 Subject: [PATCH] [clang] Remove 'PCH' from more diagnostics that were wrong or misleading NFC --- clang/include/clang/Basic/DiagnosticSerializationKinds.td | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/clang/include/clang/Basic/DiagnosticSerializationKinds.td index 253a955431997b..3914d3930bec79 100644 --- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td +++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td @@ -51,9 +51,9 @@ def note_pch_vfsoverlay_files : Note<"%select{PCH|current translation unit}0 has def note_pch_vfsoverlay_empty : Note<"%select{PCH|current translation unit}0 has no VFS overlays">; def err_ast_file_version_too_old : Error< -"%select{PCH|module|AST}0 file '%1' uses an older PCH format that is no longer supported">; +"%select{PCH|module|AST}0 file '%1' uses an older format that is no longer supported">; def err_ast_file_version_too_new : Error< -"%select{PCH|module|AST}0 file '%1' uses a newer PCH format that cannot be read">; +"%select{PCH|module|AST}0 file '%1' uses a newer format that cannot be read">; def err_ast_file_different_branch : Error< "%select{PCH|module|AST}0 file '%1' built from a different branch (%2) than the compiler (%3)">; def err_ast_file_with_compiler_errors : Error< ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [docs] Document the missing availability platforms and environments (PR #104653)
@@ -1637,31 +1637,42 @@ specifies availability for the current target platform, the availability attributes are ignored. Supported platforms are: ``ios`` +``ios_app_extension`` cyndyishida wrote: I do think it's still useful to define what those platforms' values are, for the most part, it is an easy search away though. https://github.com/llvm/llvm-project/pull/104653 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [docs] Document the missing availability platforms and environments (PR #104653)
@@ -1592,6 +1592,12 @@ succeeds but Clang emits a warning specifying that the function is deprecated. Finally, if Clang is instructed to compile code for macOS 10.7, the call fails because ``f()`` is no longer available. +Clang is instructed to compile code for a particular OS version using the cyndyishida wrote: ```suggestion Clang is instructed to compile code for a minimum deployment version using the ``` https://github.com/llvm/llvm-project/pull/104653 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [docs] Document the missing availability platforms and environments (PR #104653)
@@ -1592,6 +1592,12 @@ succeeds but Clang emits a warning specifying that the function is deprecated. Finally, if Clang is instructed to compile code for macOS 10.7, the call fails because ``f()`` is no longer available. +Clang is instructed to compile code for a particular OS version using the +``-target`` or ``-mtargetos`` flags. For example, macOS 10.7 would be cyndyishida wrote: ```suggestion ``-target`` or ``-mtargetos`` command line arguments. For example, macOS 10.7 would be ``` https://github.com/llvm/llvm-project/pull/104653 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [docs] Document the missing availability platforms and environments (PR #104653)
https://github.com/cyndyishida approved this pull request. https://github.com/llvm/llvm-project/pull/104653 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][modules] Built-in modules are not correctly enabled for Mac Catalyst (PR #104872)
@@ -2953,7 +2953,15 @@ static bool sdkSupportsBuiltinModules( case Darwin::MacOS: return SDKVersion >= VersionTuple(15U); cyndyishida wrote: The extra test coverage is more for future-proofing. There is a decent amount of `TargetVariantTriple` logic happening in this file. https://github.com/llvm/llvm-project/pull/104872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [docs] Document the missing Apple availability platforms (PR #104653)
@@ -1637,31 +1637,42 @@ specifies availability for the current target platform, the availability attributes are ignored. Supported platforms are: ``ios`` +``ios_app_extension`` Apple's iOS operating system. The minimum deployment target is specified as part of the ``-target *arch*-apple-ios*version*`` command line argument. Alternatively, it can be specified by the ``-mtargetos=ios*version*`` command-line argument. +``maccatalyst`` +``maccatalyst_app_extension`` + Apple's Mac Catalyst development environment for its macOS operating system. + The minimum deployment target is specified as part of the + ``-target *arch*-apple-ios*version*-macabi`` command line argument. cyndyishida wrote: its basically same as the platform portion of the target triple https://github.com/llvm/llvm-project/blob/main/clang/test/Driver/mtargetos-darwin.c#L4 https://github.com/llvm/llvm-project/pull/104653 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [docs] Document the missing Apple availability platforms (PR #104653)
@@ -1637,31 +1637,42 @@ specifies availability for the current target platform, the availability attributes are ignored. Supported platforms are: ``ios`` +``ios_app_extension`` Apple's iOS operating system. The minimum deployment target is specified as part of the ``-target *arch*-apple-ios*version*`` command line argument. Alternatively, it can be specified by the ``-mtargetos=ios*version*`` command-line argument. +``maccatalyst`` +``maccatalyst_app_extension`` + Apple's Mac Catalyst development environment for its macOS operating system. + The minimum deployment target is specified as part of the + ``-target *arch*-apple-ios*version*-macabi`` command line argument. cyndyishida wrote: All of the other descriptions include `-mtargetos`, why not here? https://github.com/llvm/llvm-project/pull/104653 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [docs] Document the missing Apple availability platforms (PR #104653)
@@ -1637,31 +1637,42 @@ specifies availability for the current target platform, the availability attributes are ignored. Supported platforms are: ``ios`` +``ios_app_extension`` cyndyishida wrote: The description only describes the platform. Can you also include an explanation for app_extension? https://github.com/llvm/llvm-project/pull/104653 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Compute inherited availability information (PR #103040)
https://github.com/cyndyishida approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Compute inherited availability information (PR #103040)
https://github.com/cyndyishida edited https://github.com/llvm/llvm-project/pull/103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Compute inherited availability information (PR #103040)
@@ -16,33 +16,101 @@ #include "clang/AST/Decl.h" #include "clang/Basic/TargetInfo.h" -namespace clang { +namespace { + +struct AvailabilitySet { + llvm::SmallVector Availabilities; cyndyishida wrote: Can you mark this private, its not clear otherwise that one should be going through `insert` https://github.com/llvm/llvm-project/pull/103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Compute inherited availability information (PR #103040)
@@ -16,33 +16,101 @@ #include "clang/AST/Decl.h" #include "clang/Basic/TargetInfo.h" -namespace clang { +namespace { + +struct AvailabilitySet { + llvm::SmallVector Availabilities; + bool UnconditionallyDeprecated = false; + bool UnconditionallyUnavailable = false; -AvailabilityInfo AvailabilityInfo::createFromDecl(const Decl *Decl) { - ASTContext &Context = Decl->getASTContext(); - StringRef PlatformName = Context.getTargetInfo().getPlatformName(); - AvailabilityInfo Availability; + void insert(clang::AvailabilityInfo &&Availability) { +auto *Found = getForPlatform(Availability.Domain); +if (Found) + Found->mergeWith(std::move(Availability)); +else + Availabilities.emplace_back(std::move(Availability)); + } + + clang::AvailabilityInfo *getForPlatform(llvm::StringRef Domain) { +auto *It = llvm::find_if(Availabilities, + [Domain](const clang::AvailabilityInfo &Info) { + return Domain.compare(Info.Domain) == 0; + }); +return It == Availabilities.end() ? nullptr : It; + } +}; +static void createInfoForDecl(const clang::Decl *Decl, + AvailabilitySet &Availabilities) { // Collect availability attributes from all redeclarations. for (const auto *RD : Decl->redecls()) { -for (const auto *A : RD->specific_attrs()) { - if (A->getPlatform()->getName() != PlatformName) -continue; - Availability = AvailabilityInfo( +for (const auto *A : RD->specific_attrs()) { + Availabilities.insert(clang::AvailabilityInfo( A->getPlatform()->getName(), A->getIntroduced(), A->getDeprecated(), - A->getObsoleted(), A->getUnavailable(), false, false); - break; + A->getObsoleted(), A->getUnavailable(), false, false)); } -if (const auto *A = RD->getAttr()) +if (const auto *A = RD->getAttr()) if (!A->isImplicit()) -Availability.UnconditionallyUnavailable = true; +Availabilities.UnconditionallyUnavailable = true; -if (const auto *A = RD->getAttr()) +if (const auto *A = RD->getAttr()) if (!A->isImplicit()) -Availability.UnconditionallyDeprecated = true; +Availabilities.UnconditionallyDeprecated = true; + } +} + +} // namespace + +namespace clang { + +void AvailabilityInfo::mergeWith(AvailabilityInfo Other) { + if (isDefault() && Other.isDefault()) +return; + + if (Domain.empty()) +Domain = Other.Domain; + + UnconditionallyUnavailable |= Other.UnconditionallyUnavailable; + UnconditionallyDeprecated |= Other.UnconditionallyDeprecated; + Unavailable |= Other.Unavailable; + + Introduced = std::max(Introduced, Other.Introduced); + + // Default VersionTuple is 0.0.0 so if both are non default let's pick the + // smallest version number, otherwise select the one that is non-zero if there + // is one. + if (!Deprecated.empty() && !Other.Deprecated.empty()) +Deprecated = std::min(Deprecated, Other.Deprecated); + else +Deprecated = std::max(Deprecated, Other.Deprecated); + + if (!Obsoleted.empty() && !Other.Obsoleted.empty()) +Obsoleted = std::min(Obsoleted, Other.Obsoleted); + else +Obsoleted = std::max(Obsoleted, Other.Obsoleted); +} + +AvailabilityInfo AvailabilityInfo::createFromDecl(const Decl *D) { + AvailabilitySet Availabilities; + createInfoForDecl(D, Availabilities); + // Traverse cyndyishida wrote: nit: I think this can be removed https://github.com/llvm/llvm-project/pull/103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Compute inherited availability information (PR #103040)
https://github.com/cyndyishida commented: > Additionally this computes availability information for all platforms ahead Can you add a test for this? https://github.com/llvm/llvm-project/pull/103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Compute inherited availability information (PR #103040)
@@ -0,0 +1,149 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -extract-api --pretty-sgf --emit-sgf-symbol-labels-for-testing -triple arm64-apple-macosx \ +// RUN: -x objective-c-header %s -o %t/output.symbols.json -verify + + +// RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix A +__attribute__((availability(macos, introduced=9.0, deprecated=12.0, obsoleted=20.0))) +@interface A cyndyishida wrote: What's the expected availability information emitted when the enclosing entity doesn't have one defined? ``` @interface A @property int moreRestrictive __attribute__((availability(macos, introduced=10.0, deprecated=11.0, obsoleted=19.0))); @end ``` https://github.com/llvm/llvm-project/pull/103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Compute inherited availability information (PR #103040)
@@ -16,33 +16,101 @@ #include "clang/AST/Decl.h" #include "clang/Basic/TargetInfo.h" -namespace clang { +namespace { + +struct AvailabilitySet { + llvm::SmallVector Availabilities; + bool UnconditionallyDeprecated = false; + bool UnconditionallyUnavailable = false; -AvailabilityInfo AvailabilityInfo::createFromDecl(const Decl *Decl) { - ASTContext &Context = Decl->getASTContext(); - StringRef PlatformName = Context.getTargetInfo().getPlatformName(); - AvailabilityInfo Availability; + void insert(clang::AvailabilityInfo &&Availability) { +auto *Found = getForPlatform(Availability.Domain); +if (Found) + Found->mergeWith(std::move(Availability)); +else + Availabilities.emplace_back(std::move(Availability)); + } + + clang::AvailabilityInfo *getForPlatform(llvm::StringRef Domain) { cyndyishida wrote: nit: why not `std::optional`? https://github.com/llvm/llvm-project/pull/103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Compute inherited availability information (PR #103040)
@@ -16,33 +16,101 @@ #include "clang/AST/Decl.h" #include "clang/Basic/TargetInfo.h" -namespace clang { +namespace { + +struct AvailabilitySet { cyndyishida wrote: Can you add a doc string or change the type name to match closer to what this captures? IIUC it's for member attributes' availability https://github.com/llvm/llvm-project/pull/103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Compute inherited availability information (PR #103040)
https://github.com/cyndyishida edited https://github.com/llvm/llvm-project/pull/103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][modules] Enable built-in modules for the upcoming Apple releases (PR #102239)
https://github.com/cyndyishida approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/102239 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Fix early return for scanning sub-directories (PR #100636)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/100636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)
@@ -0,0 +1,300 @@ +//===- DirectoryScanner.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "clang/InstallAPI/DirectoryScanner.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringSwitch.h" +#include "llvm/TextAPI/DylibReader.h" + +using namespace llvm; +using namespace llvm::MachO; + +namespace clang::installapi { + +HeaderSeq DirectoryScanner::getHeaders(ArrayRef Libraries) { + HeaderSeq Headers; + for (const Library &Lib : Libraries) +llvm::append_range(Headers, Lib.Headers); + return Headers; +} + +llvm::Error DirectoryScanner::scan(StringRef Directory) { + if (Mode == ScanMode::ScanFrameworks) +return scanForFrameworks(Directory); + + return scanForUnwrappedLibraries(Directory); +} + +llvm::Error DirectoryScanner::scanForUnwrappedLibraries(StringRef Directory) { + // Check some known sub-directory locations. + auto GetDirectory = [&](const char *Sub) -> OptionalDirectoryEntryRef { +SmallString Path(Directory); +sys::path::append(Path, Sub); +return FM.getOptionalDirectoryRef(Path); + }; + + auto DirPublic = GetDirectory("usr/include"); + auto DirPrivate = GetDirectory("usr/local/include"); + if (!DirPublic && !DirPrivate) { +std::error_code ec = std::make_error_code(std::errc::not_a_directory); +return createStringError(ec, + "cannot find any public (usr/include) or private " + "(usr/local/include) header directory"); + } + + Library &Lib = getOrCreateLibrary(Directory, Libraries); + Lib.IsUnwrappedDylib = true; + + if (DirPublic) +if (Error Err = scanHeaders(DirPublic->getName(), Lib, HeaderType::Public, +Directory)) + return Err; + + if (DirPrivate) +if (Error Err = scanHeaders(DirPrivate->getName(), Lib, HeaderType::Private, +Directory)) + return Err; + + return Error::success(); +} + +static bool isFramework(StringRef Path) { + while (Path.back() == '/') +Path = Path.slice(0, Path.size() - 1); + + return llvm::StringSwitch(llvm::sys::path::extension(Path)) + .Case(".framework", true) + .Default(false); +} + +Library & +DirectoryScanner::getOrCreateLibrary(StringRef Path, + std::vector &Libs) const { + if (Path.consume_front(RootPath) && Path.empty()) +Path = "/"; + + auto LibIt = + find_if(Libs, [Path](const Library &L) { return L.getPath() == Path; }); + if (LibIt != Libs.end()) +return *LibIt; + + Libs.emplace_back(Path); + return Libs.back(); +} + +Error DirectoryScanner::scanHeaders(StringRef Path, Library &Lib, +HeaderType Type, StringRef BasePath, +StringRef ParentPath) const { + std::error_code ec; + auto &FS = FM.getVirtualFileSystem(); + PathSeq SubDirectories; + for (vfs::directory_iterator i = FS.dir_begin(Path, ec), ie; i != ie; + i.increment(ec)) { +StringRef HeaderPath = i->path(); +if (ec) + return createStringError(ec, "unable to read: " + HeaderPath); + +if (sys::fs::is_symlink_file(HeaderPath)) + continue; + +// Ignore tmp files from unifdef. +const StringRef Filename = sys::path::filename(HeaderPath); +if (Filename.starts_with(".")) + continue; + +// If it is a directory, remember the subdirectory. +if (FM.getOptionalDirectoryRef(HeaderPath)) + SubDirectories.push_back(HeaderPath.str()); + +if (!isHeaderFile(HeaderPath)) + continue; + +// Skip files that do not exist. This usually happens for broken symlinks. +if (FS.status(HeaderPath) == std::errc::no_such_file_or_directory) + continue; + +auto IncludeName = createIncludeHeaderName(HeaderPath); +Lib.addHeaderFile(HeaderPath, Type, + IncludeName.has_value() ? IncludeName.value() : ""); + } + + // Go through the subdirectories. + // Sort the sub-directory first since different file systems might have + // different traverse order. + llvm::sort(SubDirectories); + if (ParentPath.empty()) +ParentPath = Path; + for (const StringRef Dir : SubDirectories) +return scanHeaders(Dir, Lib, Type, BasePath, ParentPath); cyndyishida wrote: Thanks for reporting! fixed in: https://github.com/llvm/llvm-project/pull/100636 https://github.com/llvm/llvm-project/pull/94508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Fix early return for scanning sub-directories (PR #100636)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/100636 None >From f96d9b79d7efb744182a5016295e6dd305564968 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 25 Jul 2024 12:15:45 -0700 Subject: [PATCH] [InstallAPI] Fix early return for scanning sub directories --- clang/lib/InstallAPI/DirectoryScanner.cpp | 3 +- .../directory-scanning-subdirectories.test| 61 +++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 clang/test/InstallAPI/directory-scanning-subdirectories.test diff --git a/clang/lib/InstallAPI/DirectoryScanner.cpp b/clang/lib/InstallAPI/DirectoryScanner.cpp index 8984758e7b446..03a8208c7364e 100644 --- a/clang/lib/InstallAPI/DirectoryScanner.cpp +++ b/clang/lib/InstallAPI/DirectoryScanner.cpp @@ -130,7 +130,8 @@ Error DirectoryScanner::scanHeaders(StringRef Path, Library &Lib, if (ParentPath.empty()) ParentPath = Path; for (const StringRef Dir : SubDirectories) -return scanHeaders(Dir, Lib, Type, BasePath, ParentPath); +if (Error Err = scanHeaders(Dir, Lib, Type, BasePath, ParentPath)) + return Err; return Error::success(); } diff --git a/clang/test/InstallAPI/directory-scanning-subdirectories.test b/clang/test/InstallAPI/directory-scanning-subdirectories.test new file mode 100644 index 0..3eac90440fa1e --- /dev/null +++ b/clang/test/InstallAPI/directory-scanning-subdirectories.test @@ -0,0 +1,61 @@ +; RUN: rm -rf %t +; RUN: split-file %s %t +; RUN: mkdir -p %t/DstRoot/ +; RUN: cp -r %S/Inputs/LibFoo/* %t/DstRoot/ + +; RUN: clang-installapi \ +; RUN: -target arm64-apple-macos12 -install_name @rpath/libfoo.dylib \ +; RUN: -current_version 1 -compatibility_version 1 \ +; RUN: -I%t/DstRoot/usr/include -dynamiclib \ +; RUN: -exclude-public-header %t/DstRoot/usr/include/public.h \ +; RUN: %t/DstRoot -o %t/output.tbd 2>&1 | FileCheck %s --allow-empty \ +; RUN: --implicit-check-not=error --implicit-check-not=warning +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd + + +;--- DstRoot/usr/include/extra/extra.h +int extra(void); + +;--- DstRoot/usr/include/extra/additional/additional.h +int additional(void); + +;--- DstRoot/usr/include/more/more.h +int more(void); + +;--- DstRoot/usr/include/another/another.h +int another(void); + +;--- expected.tbd +{ + "main_library": { +"exported_symbols": [ + { +"text": { + "global": [ +"_foo", "_additional", "_more", +"_another", "_extra" + ] +} + } +], +"flags": [ + { +"attributes": [ + "not_app_extension_safe" +] + } +], +"install_names": [ + { +"name": "@rpath/libfoo.dylib" + } +], +"target_info": [ + { +"min_deployment": "12", +"target": "arm64-macos" + } +] + }, + "tapi_tbd_version": 5 +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang/Lex/DependencyDirectivesScanner] Ignore import/include directives with missing filenames without failing the scan (PR #100126)
https://github.com/cyndyishida approved this pull request. https://github.com/llvm/llvm-project/pull/100126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-scan-deps] Ignore import/include directives with missing filenames (PR #99520)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/99520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-scan-deps] Ignore import/include directives with missing filenames (PR #99520)
cyndyishida wrote: > > I switched to the unit test, though I didn't figure out how to capture the > > same sort of round-trip testing as with the lit test. > > Are you not seeing the same "infinite calls append the same token into > CurDirTokens" issue via the unit test? Oh yeah, that part is sufficiently exercised in the unit test. https://github.com/llvm/llvm-project/pull/99520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-scan-deps] Ignore import/include directives with missing filenames (PR #99520)
cyndyishida wrote: > This is similar feedback that I gave for #97654, could you test the change > with a unit test in `DependencyDirectivesScannerTest.cpp` instead? It's much > simpler to set up and execution-wise it's orders of magnitude more > lightweight than a whole new lit test. > > For reference see the test change in that PR. I switched to the unit test, though I didn't figure out how to capture the same sort of round-trip testing as with the lit test. It seems expected that the wrapper function `minimizeSourceToDependencyDirectives` returns all directives without actually evaluating them so it would always fail on an invalid one, even if it's macro guarded. https://github.com/llvm/llvm-project/pull/99520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-scan-deps] Ignore import/include directives with missing filenames (PR #99520)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/99520 >From bcddefdce00a1e15f29181bc92eab86098a8b328 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 18 Jul 2024 08:56:24 -0700 Subject: [PATCH 1/2] [clang-scan-deps] Ignore import/include directives with missing filenames Previously source input like `#import ` resulted in infinite calls append the same token into `CurDirTokens`. This patch now ignores those directive lines if they won't actually end up being compiled. (e.g. macro guarded) --- clang/lib/Lex/DependencyDirectivesScanner.cpp | 12 ++- .../ClangScanDeps/missing-import-filenames.m | 98 +++ 2 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 clang/test/ClangScanDeps/missing-import-filenames.m diff --git a/clang/lib/Lex/DependencyDirectivesScanner.cpp b/clang/lib/Lex/DependencyDirectivesScanner.cpp index 57652be8244b4..4bb57a0751d42 100644 --- a/clang/lib/Lex/DependencyDirectivesScanner.cpp +++ b/clang/lib/Lex/DependencyDirectivesScanner.cpp @@ -88,8 +88,8 @@ struct Scanner { [[nodiscard]] dependency_directives_scan::Token & lexToken(const char *&First, const char *const End); - dependency_directives_scan::Token &lexIncludeFilename(const char *&First, -const char *const End); + [[nodiscard]] dependency_directives_scan::Token & + lexIncludeFilename(const char *&First, const char *const End); void skipLine(const char *&First, const char *const End); void skipDirective(StringRef Name, const char *&First, const char *const End); @@ -544,7 +544,7 @@ Scanner::lexIncludeFilename(const char *&First, const char *const End) { void Scanner::lexPPDirectiveBody(const char *&First, const char *const End) { while (true) { const dependency_directives_scan::Token &Tok = lexToken(First, End); -if (Tok.is(tok::eod)) +if (Tok.is(tok::eod) || Tok.is(tok::eof)) break; } } @@ -901,7 +901,11 @@ bool Scanner::lexPPLine(const char *&First, const char *const End) { case pp___include_macros: case pp_include_next: case pp_import: -lexIncludeFilename(First, End); +// Ignore missing filenames in include or import directives. +if (lexIncludeFilename(First, End).is(tok::eod)) { + skipDirective(Id, First, End); + return true; +} break; default: break; diff --git a/clang/test/ClangScanDeps/missing-import-filenames.m b/clang/test/ClangScanDeps/missing-import-filenames.m new file mode 100644 index 0..169060614af80 --- /dev/null +++ b/clang/test/ClangScanDeps/missing-import-filenames.m @@ -0,0 +1,98 @@ +// This test checks that import directives with missing filenames are ignored when scanning but will result +// in compile time errors if they need to be parsed. + +// RUN: rm -rf %t +// RUN: split-file %s %t + +//--- tu.m +#import "zeroth.h" + +//--- zeroth/module.modulemap +module zeroth { header "zeroth.h" } +//--- zeroth/zeroth.h +#ifdef BAD_IMPORT +@import; +#import +#endif +@import first; + +//--- first/module.modulemap +module first { header "first.h" } +//--- first/first.h + +// RUN: clang-scan-deps -format experimental-full -o %t/result.json \ +// RUN: -- %clang -fmodules -fmodules-cache-path=%t/cache -I %t/zeroth -I %t/first -I %t/second -c %t/tu.m -o %t/tu.o +// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t + +// CHECK: { +// CHECK-NEXT: "modules": [ +// CHECK-NEXT: { +// CHECK-NEXT: "clang-module-deps": [], +// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/first/module.modulemap", +// CHECK-NEXT: "command-line": [ +// CHECK:], +// CHECK-NEXT: "context-hash": "{{.*}}", +// CHECK-NEXT: "file-deps": [ +// CHECK-NEXT: "[[PREFIX]]/first/first.h", +// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap" +// CHECK-NEXT: ], +// CHECK-NEXT: "link-libraries": [], +// CHECK-NEXT: "name": "first" +// CHECK-NEXT: }, +// CHECK-NEXT: { +// CHECK-NEXT: "clang-module-deps": [ +// CHECK-NEXT: { +// CHECK-NEXT: "context-hash": "{{.*}}", +// CHECK-NEXT: "module-name": "first" +// CHECK-NEXT: } +// CHECK-NEXT: ], +// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/zeroth/module.modulemap", +// CHECK-NEXT: "command-line": [ +// CHECK:], +// CHECK-NEXT: "context-hash": "{{.*}}", +// CHECK-NEXT: "file-deps": [ +// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap", +// CHECK-NEXT: "[[PREFIX]]/zeroth/module.modulemap", +// CHECK-NEXT: "[[PREFIX]]/zeroth/zeroth.h" +// CHECK-NEXT: ], +// CHECK-NEXT: "link-libraries": [], +// CHECK-NEXT: "name": "zeroth" +// CHECK-NEXT: } +// CHECK-NEXT: ], +// CHECK-NEXT: "translation-units": [ +// CHECK-NEXT: { +// CHECK-NEXT: "commands": [ +// CHECK-NEXT: { +// CHECK-NEXT: "clang-contex
[clang] [clang-scan-deps] Ignore import/include directives with missing filenames (PR #99520)
@@ -544,7 +544,7 @@ Scanner::lexIncludeFilename(const char *&First, const char *const End) { void Scanner::lexPPDirectiveBody(const char *&First, const char *const End) { while (true) { const dependency_directives_scan::Token &Tok = lexToken(First, End); -if (Tok.is(tok::eod)) +if (Tok.is(tok::eod) || Tok.is(tok::eof)) cyndyishida wrote: If I understand you correctly, that's actually what happened before I added the `skipDirective` on [line 905](https://github.com/llvm/llvm-project/pull/99520/files#diff-ee296172b8a9dd81c5185e78a512c2fc89f7abfe5b2d035e96537fce7dbbbc9cR905) Previously, input that was macro or header-guarded would fail with ``` error: unterminated conditional directive ``` because the directive line for the `include` absorbed up the `#endif`. https://github.com/llvm/llvm-project/pull/99520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix diagnostics-dsym.test on mac-arm64 (PR #99399)
https://github.com/cyndyishida approved this pull request. Thank you for looking into & resolving this again! https://github.com/llvm/llvm-project/pull/99399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1c55586 - [clang] Fix typo in comments
Author: Cyndy Ishida Date: 2024-07-18T10:12:36-07:00 New Revision: 1c55586e9a475a09b7d769e7fc9a254e7150c972 URL: https://github.com/llvm/llvm-project/commit/1c55586e9a475a09b7d769e7fc9a254e7150c972 DIFF: https://github.com/llvm/llvm-project/commit/1c55586e9a475a09b7d769e7fc9a254e7150c972.diff LOG: [clang] Fix typo in comments Added: Modified: clang/lib/Lex/Preprocessor.cpp Removed: diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 44b69a58f3411..63e27e62cffc8 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -988,7 +988,7 @@ void Preprocessor::LexTokensUntilEOF(std::vector *Tokens) { } /// Lex a header-name token (including one formed from header-name-tokens if -/// \p AllowConcatenation is \c true). +/// \p AllowMacroExpansion is \c true). /// /// \param FilenameTok Filled in with the next token. On success, this will ///be either a header_name token. On failure, it will be whatever other ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-scan-deps] Ignore import/include directives with missing filenames (PR #99520)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/99520 Previously source input like `#import ` resulted in infinite calls append the same token into `CurDirTokens`. This patch now ignores those directive lines if they won't actually end up being compiled. (e.g. macro guarded) resolves: rdar://121247565 >From bcddefdce00a1e15f29181bc92eab86098a8b328 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 18 Jul 2024 08:56:24 -0700 Subject: [PATCH] [clang-scan-deps] Ignore import/include directives with missing filenames Previously source input like `#import ` resulted in infinite calls append the same token into `CurDirTokens`. This patch now ignores those directive lines if they won't actually end up being compiled. (e.g. macro guarded) --- clang/lib/Lex/DependencyDirectivesScanner.cpp | 12 ++- .../ClangScanDeps/missing-import-filenames.m | 98 +++ 2 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 clang/test/ClangScanDeps/missing-import-filenames.m diff --git a/clang/lib/Lex/DependencyDirectivesScanner.cpp b/clang/lib/Lex/DependencyDirectivesScanner.cpp index 57652be8244b4..4bb57a0751d42 100644 --- a/clang/lib/Lex/DependencyDirectivesScanner.cpp +++ b/clang/lib/Lex/DependencyDirectivesScanner.cpp @@ -88,8 +88,8 @@ struct Scanner { [[nodiscard]] dependency_directives_scan::Token & lexToken(const char *&First, const char *const End); - dependency_directives_scan::Token &lexIncludeFilename(const char *&First, -const char *const End); + [[nodiscard]] dependency_directives_scan::Token & + lexIncludeFilename(const char *&First, const char *const End); void skipLine(const char *&First, const char *const End); void skipDirective(StringRef Name, const char *&First, const char *const End); @@ -544,7 +544,7 @@ Scanner::lexIncludeFilename(const char *&First, const char *const End) { void Scanner::lexPPDirectiveBody(const char *&First, const char *const End) { while (true) { const dependency_directives_scan::Token &Tok = lexToken(First, End); -if (Tok.is(tok::eod)) +if (Tok.is(tok::eod) || Tok.is(tok::eof)) break; } } @@ -901,7 +901,11 @@ bool Scanner::lexPPLine(const char *&First, const char *const End) { case pp___include_macros: case pp_include_next: case pp_import: -lexIncludeFilename(First, End); +// Ignore missing filenames in include or import directives. +if (lexIncludeFilename(First, End).is(tok::eod)) { + skipDirective(Id, First, End); + return true; +} break; default: break; diff --git a/clang/test/ClangScanDeps/missing-import-filenames.m b/clang/test/ClangScanDeps/missing-import-filenames.m new file mode 100644 index 0..169060614af80 --- /dev/null +++ b/clang/test/ClangScanDeps/missing-import-filenames.m @@ -0,0 +1,98 @@ +// This test checks that import directives with missing filenames are ignored when scanning but will result +// in compile time errors if they need to be parsed. + +// RUN: rm -rf %t +// RUN: split-file %s %t + +//--- tu.m +#import "zeroth.h" + +//--- zeroth/module.modulemap +module zeroth { header "zeroth.h" } +//--- zeroth/zeroth.h +#ifdef BAD_IMPORT +@import; +#import +#endif +@import first; + +//--- first/module.modulemap +module first { header "first.h" } +//--- first/first.h + +// RUN: clang-scan-deps -format experimental-full -o %t/result.json \ +// RUN: -- %clang -fmodules -fmodules-cache-path=%t/cache -I %t/zeroth -I %t/first -I %t/second -c %t/tu.m -o %t/tu.o +// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t + +// CHECK: { +// CHECK-NEXT: "modules": [ +// CHECK-NEXT: { +// CHECK-NEXT: "clang-module-deps": [], +// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/first/module.modulemap", +// CHECK-NEXT: "command-line": [ +// CHECK:], +// CHECK-NEXT: "context-hash": "{{.*}}", +// CHECK-NEXT: "file-deps": [ +// CHECK-NEXT: "[[PREFIX]]/first/first.h", +// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap" +// CHECK-NEXT: ], +// CHECK-NEXT: "link-libraries": [], +// CHECK-NEXT: "name": "first" +// CHECK-NEXT: }, +// CHECK-NEXT: { +// CHECK-NEXT: "clang-module-deps": [ +// CHECK-NEXT: { +// CHECK-NEXT: "context-hash": "{{.*}}", +// CHECK-NEXT: "module-name": "first" +// CHECK-NEXT: } +// CHECK-NEXT: ], +// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/zeroth/module.modulemap", +// CHECK-NEXT: "command-line": [ +// CHECK:], +// CHECK-NEXT: "context-hash": "{{.*}}", +// CHECK-NEXT: "file-deps": [ +// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap", +// CHECK-NEXT: "[[PREFIX]]/zeroth/module.modulemap", +// CHECK-NEXT: "[[PREFIX]]/zeroth/zeroth.h" +// CHECK-NEXT: ], +// CHECK-NEXT: "link-libraries":
[clang] Fix diagnostics-dsym.test on mac-arm64 (PR #99399)
cyndyishida wrote: Thank you @zeroomega ! I am also running on arm64-mac and that test is passing. What is your `cmake` invocation? I'd like to dig into the underlying cause of non-stable ordering. It looks like the darwin-aarch64 is passing the test as well https://lab.llvm.org/buildbot/#/builders/190 In general, though, I'm not too worried about the ordering of diagnostics so maybe a `CHECK-DAG` would make the test resilient https://github.com/llvm/llvm-project/pull/99399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Don't look for linker directive symbols in reexports (PR #98171)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/98171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Don't look for linker directive symbols in reexports (PR #98171)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/98171 >From 03ee88e0b208d42a675dbbcf89ace869d193023b Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Tue, 9 Jul 2024 08:22:53 -0700 Subject: [PATCH] [InstallAPI] Don't look for linker directive symbols in reexports `$ld$previous` symbols need to be exported for it to be seen by clients. TAPI cannot omit them in tbd files, so account for this in installapi verification when handling reexport verification. Reviewed internally by Zixu Wang. resolves: rdar://131317591 --- clang/lib/InstallAPI/DylibVerifier.cpp| 8 +- .../reexport-with-linker-symbols.test | 304 ++ 2 files changed, 310 insertions(+), 2 deletions(-) create mode 100644 clang/test/InstallAPI/reexport-with-linker-symbols.test diff --git a/clang/lib/InstallAPI/DylibVerifier.cpp b/clang/lib/InstallAPI/DylibVerifier.cpp index 216b5eb799cb3..d5d760767b41f 100644 --- a/clang/lib/InstallAPI/DylibVerifier.cpp +++ b/clang/lib/InstallAPI/DylibVerifier.cpp @@ -187,14 +187,18 @@ bool DylibVerifier::shouldIgnoreObsolete(const Record *R, SymbolContext &SymCtx, bool DylibVerifier::shouldIgnoreReexport(const Record *R, SymbolContext &SymCtx) const { + StringRef SymName = SymCtx.SymbolName; + // Linker directive symbols can never be ignored. + if (SymName.starts_with("$ld$")) +return false; + if (Reexports.empty()) return false; for (const InterfaceFile &Lib : Reexports) { if (!Lib.hasTarget(Ctx.Target)) continue; -if (auto Sym = -Lib.getSymbol(SymCtx.Kind, SymCtx.SymbolName, SymCtx.ObjCIFKind)) +if (auto Sym = Lib.getSymbol(SymCtx.Kind, SymName, SymCtx.ObjCIFKind)) if ((*Sym)->hasTarget(Ctx.Target)) return true; } diff --git a/clang/test/InstallAPI/reexport-with-linker-symbols.test b/clang/test/InstallAPI/reexport-with-linker-symbols.test new file mode 100644 index 0..ab7ac65af82e2 --- /dev/null +++ b/clang/test/InstallAPI/reexport-with-linker-symbols.test @@ -0,0 +1,304 @@ +; RUN: rm -rf %t +; RUN: split-file %s %t + +; RUN: yaml2obj %t/umbrella.yaml -o %t/System/Library/Frameworks/Umbrella.framework/Umbrella + +; RUN: clang-installapi -target arm64-apple-macosx14 -install_name \ +; RUN: /System/Library/Frameworks/Umbrella.framework/Versions/A/Umbrella \ +; RUN: --verify-against=%t/System/Library/Frameworks/Umbrella.framework/Umbrella \ +; RUN: -L%t/usr/lib -F%t/System/Library/Frameworks \ +; RUN: %t/System/Library/Frameworks/Umbrella.framework --verify-mode=Pedantic -reexport-lBar \ +; RUN: -o %t/Umbrella.tbd 2>&1 | FileCheck -allow-empty %s +; RUN: llvm-readtapi -compare %t/Umbrella.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +; CHECK-NOT: error +; CHECK-NOT: warning + +;--- System/Library/Frameworks/Umbrella.framework/Headers/Umbrella.h +extern const char ld_previous __asm("$ld$previous$/usr/lib/libLdPreviousBindPrevious.1.dylib$$1$11.0$16.0$_function$"); +extern void function(); + +;--- umbrella.yaml +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x10C + cpusubtype: 0x0 + filetype:0x6 + ncmds: 16 + sizeofcmds: 856 + flags: 0x85 + reserved:0x0 +LoadCommands: + - cmd: LC_SEGMENT_64 +cmdsize: 312 +segname: __TEXT +vmaddr: 0 +vmsize: 16384 +fileoff: 0 +filesize:16384 +maxprot: 5 +initprot:5 +nsects: 3 +flags: 0 +Sections: + - sectname:__text +segname: __TEXT +addr:0x3FB0 +size:4 +offset: 0x3FB0 +align: 2 +reloff: 0x0 +nreloc: 0 +flags: 0x8400 +reserved1: 0x0 +reserved2: 0x0 +reserved3: 0x0 +content: C0035FD6 + - sectname:__const +segname: __TEXT +addr:0x3FB4 +size:1 +offset: 0x3FB4 +align: 0 +reloff: 0x0 +nreloc: 0 +flags: 0x0 +reserved1: 0x0 +reserved2: 0x0 +reserved3: 0x0 +content: '00' + - sectname:__unwind_info +segname: __TEXT +addr:0x3FB8 +size:72 +offset: 0x3FB8 +align: 2 +reloff: 0x0 +nreloc: 0 +flags: 0x0 +reserved1: 0x0 +reserved2: 0x0 +reserved3: 0x0 +content: 01001C001C001C000200B03F34003400B53F340003000C0001001102 + - cmd:
[clang] [InstallAPI] Don't look for linker directive symbols in reexports (PR #98171)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/98171 `$ld$previous` symbols need to be exported for them to be seen by clients. TAPI cannot omit them in tbd files, so account for this in installapi verification when handling reexport verification. Reviewed internally by Zixu Wang resolves: rdar://131317591 >From ff849af4d41f57aaf59bd6ed490b5faff9124884 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Tue, 9 Jul 2024 08:22:53 -0700 Subject: [PATCH] [InstallAPI] Don't look for linker directive symbols in reexports `$ld$previous` symbols need to be exported for it to be seen by clients. TAPI cannot omit them in tbd files, so account for this in installapi verification when handling reexport verification. Reviewed internally by Zixu Wang. resolves: rdar://131317591 --- clang/lib/InstallAPI/DylibVerifier.cpp| 8 +- .../reexport-with-linker-symbols.test | 304 ++ 2 files changed, 310 insertions(+), 2 deletions(-) create mode 100644 clang/test/InstallAPI/reexport-with-linker-symbols.test diff --git a/clang/lib/InstallAPI/DylibVerifier.cpp b/clang/lib/InstallAPI/DylibVerifier.cpp index 216b5eb799cb3..d5d760767b41f 100644 --- a/clang/lib/InstallAPI/DylibVerifier.cpp +++ b/clang/lib/InstallAPI/DylibVerifier.cpp @@ -187,14 +187,18 @@ bool DylibVerifier::shouldIgnoreObsolete(const Record *R, SymbolContext &SymCtx, bool DylibVerifier::shouldIgnoreReexport(const Record *R, SymbolContext &SymCtx) const { + StringRef SymName = SymCtx.SymbolName; + // Linker directive symbols can never be ignored. + if (SymName.starts_with("$ld$")) +return false; + if (Reexports.empty()) return false; for (const InterfaceFile &Lib : Reexports) { if (!Lib.hasTarget(Ctx.Target)) continue; -if (auto Sym = -Lib.getSymbol(SymCtx.Kind, SymCtx.SymbolName, SymCtx.ObjCIFKind)) +if (auto Sym = Lib.getSymbol(SymCtx.Kind, SymName, SymCtx.ObjCIFKind)) if ((*Sym)->hasTarget(Ctx.Target)) return true; } diff --git a/clang/test/InstallAPI/reexport-with-linker-symbols.test b/clang/test/InstallAPI/reexport-with-linker-symbols.test new file mode 100644 index 0..ab7ac65af82e2 --- /dev/null +++ b/clang/test/InstallAPI/reexport-with-linker-symbols.test @@ -0,0 +1,304 @@ +; RUN: rm -rf %t +; RUN: split-file %s %t + +; RUN: yaml2obj %t/umbrella.yaml -o %t/System/Library/Frameworks/Umbrella.framework/Umbrella + +; RUN: clang-installapi -target arm64-apple-macosx14 -install_name \ +; RUN: /System/Library/Frameworks/Umbrella.framework/Versions/A/Umbrella \ +; RUN: --verify-against=%t/System/Library/Frameworks/Umbrella.framework/Umbrella \ +; RUN: -L%t/usr/lib -F%t/System/Library/Frameworks \ +; RUN: %t/System/Library/Frameworks/Umbrella.framework --verify-mode=Pedantic -reexport-lBar \ +; RUN: -o %t/Umbrella.tbd 2>&1 | FileCheck -allow-empty %s +; RUN: llvm-readtapi -compare %t/Umbrella.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +; CHECK-NOT: error +; CHECK-NOT: warning + +;--- System/Library/Frameworks/Umbrella.framework/Headers/Umbrella.h +extern const char ld_previous __asm("$ld$previous$/usr/lib/libLdPreviousBindPrevious.1.dylib$$1$11.0$16.0$_function$"); +extern void function(); + +;--- umbrella.yaml +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x10C + cpusubtype: 0x0 + filetype:0x6 + ncmds: 16 + sizeofcmds: 856 + flags: 0x85 + reserved:0x0 +LoadCommands: + - cmd: LC_SEGMENT_64 +cmdsize: 312 +segname: __TEXT +vmaddr: 0 +vmsize: 16384 +fileoff: 0 +filesize:16384 +maxprot: 5 +initprot:5 +nsects: 3 +flags: 0 +Sections: + - sectname:__text +segname: __TEXT +addr:0x3FB0 +size:4 +offset: 0x3FB0 +align: 2 +reloff: 0x0 +nreloc: 0 +flags: 0x8400 +reserved1: 0x0 +reserved2: 0x0 +reserved3: 0x0 +content: C0035FD6 + - sectname:__const +segname: __TEXT +addr:0x3FB4 +size:1 +offset: 0x3FB4 +align: 0 +reloff: 0x0 +nreloc: 0 +flags: 0x0 +reserved1: 0x0 +reserved2: 0x0 +reserved3: 0x0 +content: '00' + - sectname:__unwind_info +segname: __TEXT +addr:0x3FB8 +size:72 +offset: 0x3FB8 +align: 2 +reloff: 0x0 +nreloc: 0 +flags: 0x0 +reserved1:
[clang] [clang-installapi] ] Fix potential null pointer dereference in file enumeration (PR #97900)
@@ -51,8 +51,14 @@ llvm::Expected enumerateFiles(FileManager &FM, StringRef Directory) { if (EC) return errorCodeToError(EC); +// Ensure the iterator is valid before dereferencing. +if (i == ie) + break; + // Skip files that do not exist. This usually happens for broken symlinks. -if (FS.status(i->path()) == std::errc::no_such_file_or_directory) +auto StatusOrErr = FS.status(i->path()); +if (!StatusOrErr || cyndyishida wrote: I'm not sure about this either. Where is the possible null pointer access? I also think `!StatusOrErr` is now too strict that we'd skip over other paths that may have other errors that we may want to still store. https://github.com/llvm/llvm-project/pull/97900 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-installapi] ] Fix potential null pointer dereference in file enumeration (PR #97900)
@@ -51,8 +51,14 @@ llvm::Expected enumerateFiles(FileManager &FM, StringRef Directory) { if (EC) return errorCodeToError(EC); +// Ensure the iterator is valid before dereferencing. +if (i == ie) cyndyishida wrote: Why does this make a difference? The same check happens at each iteration of the loop on line 50. There's no mutations on `i` or `ie` between there and this check. https://github.com/llvm/llvm-project/pull/97900 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/94508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)
cyndyishida wrote: ping https://github.com/llvm/llvm-project/pull/94508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/94508 >From 95cc0c9a2b135706e80a5e73ef5e4257aa89984c Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Fri, 10 May 2024 09:19:22 -0700 Subject: [PATCH] [InstallAPI] Pick up input headers by directory traversal Match TAPI behavior and allow input headers to be resolved via a passed directory, which is expected to be a library sitting in a build directory. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 2 + .../clang/InstallAPI/DirectoryScanner.h | 81 + clang/include/clang/InstallAPI/HeaderFile.h | 13 + clang/include/clang/InstallAPI/Library.h | 65 clang/include/clang/InstallAPI/MachO.h| 1 + clang/lib/InstallAPI/CMakeLists.txt | 2 + clang/lib/InstallAPI/DirectoryScanner.cpp | 300 ++ clang/lib/InstallAPI/Library.cpp | 40 +++ clang/test/InstallAPI/asm.test| 2 +- clang/test/InstallAPI/basic.test | 4 +- clang/test/InstallAPI/binary-attributes.test | 6 +- clang/test/InstallAPI/cpp.test| 4 +- clang/test/InstallAPI/diagnostics-dsym.test | 4 +- .../InstallAPI/directory-scanning-dylib.test | 57 .../directory-scanning-frameworks.test| 88 + clang/test/InstallAPI/functions.test | 2 +- clang/test/InstallAPI/variables.test | 2 +- clang/tools/clang-installapi/Options.cpp | 51 ++- clang/tools/clang-installapi/Options.h| 3 + 19 files changed, 703 insertions(+), 24 deletions(-) create mode 100644 clang/include/clang/InstallAPI/DirectoryScanner.h create mode 100644 clang/include/clang/InstallAPI/Library.h create mode 100644 clang/lib/InstallAPI/DirectoryScanner.cpp create mode 100644 clang/lib/InstallAPI/Library.cpp create mode 100644 clang/test/InstallAPI/directory-scanning-dylib.test create mode 100644 clang/test/InstallAPI/directory-scanning-frameworks.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index cdf27247602f2..e10fa71011f30 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -26,6 +26,8 @@ def err_unsupported_environment : Error<"environment '%0' is not supported: '%1' def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; def err_cannot_read_input_list : Error<"could not read %0 input list '%1': %2">; def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X">; +def err_directory_scanning: Error<"could not read directory '%0': %1">; +def err_more_than_one_library: Error<"more than one framework/dynamic library found">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/InstallAPI/DirectoryScanner.h b/clang/include/clang/InstallAPI/DirectoryScanner.h new file mode 100644 index 0..803328982ec87 --- /dev/null +++ b/clang/include/clang/InstallAPI/DirectoryScanner.h @@ -0,0 +1,81 @@ +//===- InstallAPI/DirectoryScanner.h *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +/// +/// The DirectoryScanner for collecting library files on the file system. +/// +//===--===// +#ifndef LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H +#define LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H + +#include "clang/Basic/FileManager.h" +#include "clang/InstallAPI/Library.h" + +namespace clang::installapi { + +enum ScanMode { + /// Scanning Framework directory. + ScanFrameworks, + /// Scanning Dylib directory. + ScanDylibs, +}; + +class DirectoryScanner { +public: + DirectoryScanner(FileManager &FM, ScanMode Mode = ScanMode::ScanFrameworks) + : FM(FM), Mode(Mode) {} + + /// Scan for all input files throughout directory. + /// + /// \param Directory Path of input directory. + llvm::Error scan(StringRef Directory); + + /// Take over ownership of stored libraries. + std::vector takeLibraries() { return std::move(Libraries); }; + + /// Get all the header files in libraries. + /// + /// \param Libraries Reference of collection of libraries. + static HeaderSeq getHeaders(ArrayRef Libraries); + +private: + /// Collect files for dylibs in usr/(local)/lib within directory. + llvm::Error scanForUnwrappedLibraries(StringRef Directory); + + /// Collect files for any frameworks within directory. + llvm::Error scanForFrameworks(StringRef Directory); + + /// Get a library from the libraries collection. + Library &getOrCreateLibrary(StringRef Path, std::vector &Libs) const; + + /// Collect multiple f
[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)
@@ -97,6 +97,14 @@ class HeaderFile { Other.Excluded, Other.Extra, Other.Umbrella); } + + bool operator<(const HeaderFile &Other) const { cyndyishida wrote: I could infer, but I don't actually know @ributzka do you remember? https://github.com/llvm/llvm-project/pull/94508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/94508 >From c547d990aca29ecfe6f51d37c5c3f8712dfc5e44 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Fri, 10 May 2024 09:19:22 -0700 Subject: [PATCH 1/2] [InstallAPI] Pick up input headers by directory traversal Match TAPI behavior and allow input headers to be resolved via a passed directory, which is expected to be a library sitting in a build directory. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 2 + .../clang/InstallAPI/DirectoryScanner.h | 81 + clang/include/clang/InstallAPI/HeaderFile.h | 8 + clang/include/clang/InstallAPI/Library.h | 65 clang/include/clang/InstallAPI/MachO.h| 1 + clang/lib/InstallAPI/CMakeLists.txt | 2 + clang/lib/InstallAPI/DirectoryScanner.cpp | 300 ++ clang/lib/InstallAPI/Library.cpp | 40 +++ clang/test/InstallAPI/asm.test| 2 +- clang/test/InstallAPI/basic.test | 4 +- clang/test/InstallAPI/binary-attributes.test | 6 +- clang/test/InstallAPI/cpp.test| 4 +- clang/test/InstallAPI/diagnostics-dsym.test | 4 +- .../InstallAPI/directory-scanning-dylib.test | 57 .../directory-scanning-frameworks.test| 89 ++ clang/test/InstallAPI/functions.test | 2 +- clang/test/InstallAPI/variables.test | 2 +- clang/tools/clang-installapi/Options.cpp | 51 ++- clang/tools/clang-installapi/Options.h| 3 + 19 files changed, 699 insertions(+), 24 deletions(-) create mode 100644 clang/include/clang/InstallAPI/DirectoryScanner.h create mode 100644 clang/include/clang/InstallAPI/Library.h create mode 100644 clang/lib/InstallAPI/DirectoryScanner.cpp create mode 100644 clang/lib/InstallAPI/Library.cpp create mode 100644 clang/test/InstallAPI/directory-scanning-dylib.test create mode 100644 clang/test/InstallAPI/directory-scanning-frameworks.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index cdf27247602f2..e10fa71011f30 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -26,6 +26,8 @@ def err_unsupported_environment : Error<"environment '%0' is not supported: '%1' def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; def err_cannot_read_input_list : Error<"could not read %0 input list '%1': %2">; def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X">; +def err_directory_scanning: Error<"could not read directory '%0': %1">; +def err_more_than_one_library: Error<"more than one framework/dynamic library found">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/InstallAPI/DirectoryScanner.h b/clang/include/clang/InstallAPI/DirectoryScanner.h new file mode 100644 index 0..803328982ec87 --- /dev/null +++ b/clang/include/clang/InstallAPI/DirectoryScanner.h @@ -0,0 +1,81 @@ +//===- InstallAPI/DirectoryScanner.h *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +/// +/// The DirectoryScanner for collecting library files on the file system. +/// +//===--===// +#ifndef LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H +#define LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H + +#include "clang/Basic/FileManager.h" +#include "clang/InstallAPI/Library.h" + +namespace clang::installapi { + +enum ScanMode { + /// Scanning Framework directory. + ScanFrameworks, + /// Scanning Dylib directory. + ScanDylibs, +}; + +class DirectoryScanner { +public: + DirectoryScanner(FileManager &FM, ScanMode Mode = ScanMode::ScanFrameworks) + : FM(FM), Mode(Mode) {} + + /// Scan for all input files throughout directory. + /// + /// \param Directory Path of input directory. + llvm::Error scan(StringRef Directory); + + /// Take over ownership of stored libraries. + std::vector takeLibraries() { return std::move(Libraries); }; + + /// Get all the header files in libraries. + /// + /// \param Libraries Reference of collection of libraries. + static HeaderSeq getHeaders(ArrayRef Libraries); + +private: + /// Collect files for dylibs in usr/(local)/lib within directory. + llvm::Error scanForUnwrappedLibraries(StringRef Directory); + + /// Collect files for any frameworks within directory. + llvm::Error scanForFrameworks(StringRef Directory); + + /// Get a library from the libraries collection. + Library &getOrCreateLibrary(StringRef Path, std::vector &Libs) const; + + /// Collect multi
[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/94508 Match TAPI behavior and allow input headers to be resolved via a passed directory, which is expected to be a library sitting in a build directory. >From c547d990aca29ecfe6f51d37c5c3f8712dfc5e44 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Fri, 10 May 2024 09:19:22 -0700 Subject: [PATCH] [InstallAPI] Pick up input headers by directory traversal Match TAPI behavior and allow input headers to be resolved via a passed directory, which is expected to be a library sitting in a build directory. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 2 + .../clang/InstallAPI/DirectoryScanner.h | 81 + clang/include/clang/InstallAPI/HeaderFile.h | 8 + clang/include/clang/InstallAPI/Library.h | 65 clang/include/clang/InstallAPI/MachO.h| 1 + clang/lib/InstallAPI/CMakeLists.txt | 2 + clang/lib/InstallAPI/DirectoryScanner.cpp | 300 ++ clang/lib/InstallAPI/Library.cpp | 40 +++ clang/test/InstallAPI/asm.test| 2 +- clang/test/InstallAPI/basic.test | 4 +- clang/test/InstallAPI/binary-attributes.test | 6 +- clang/test/InstallAPI/cpp.test| 4 +- clang/test/InstallAPI/diagnostics-dsym.test | 4 +- .../InstallAPI/directory-scanning-dylib.test | 57 .../directory-scanning-frameworks.test| 89 ++ clang/test/InstallAPI/functions.test | 2 +- clang/test/InstallAPI/variables.test | 2 +- clang/tools/clang-installapi/Options.cpp | 51 ++- clang/tools/clang-installapi/Options.h| 3 + 19 files changed, 699 insertions(+), 24 deletions(-) create mode 100644 clang/include/clang/InstallAPI/DirectoryScanner.h create mode 100644 clang/include/clang/InstallAPI/Library.h create mode 100644 clang/lib/InstallAPI/DirectoryScanner.cpp create mode 100644 clang/lib/InstallAPI/Library.cpp create mode 100644 clang/test/InstallAPI/directory-scanning-dylib.test create mode 100644 clang/test/InstallAPI/directory-scanning-frameworks.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index cdf27247602f2..e10fa71011f30 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -26,6 +26,8 @@ def err_unsupported_environment : Error<"environment '%0' is not supported: '%1' def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; def err_cannot_read_input_list : Error<"could not read %0 input list '%1': %2">; def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X">; +def err_directory_scanning: Error<"could not read directory '%0': %1">; +def err_more_than_one_library: Error<"more than one framework/dynamic library found">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/InstallAPI/DirectoryScanner.h b/clang/include/clang/InstallAPI/DirectoryScanner.h new file mode 100644 index 0..803328982ec87 --- /dev/null +++ b/clang/include/clang/InstallAPI/DirectoryScanner.h @@ -0,0 +1,81 @@ +//===- InstallAPI/DirectoryScanner.h *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +/// +/// The DirectoryScanner for collecting library files on the file system. +/// +//===--===// +#ifndef LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H +#define LLVM_CLANG_INSTALLAPI_DIRECTORYSCANNER_H + +#include "clang/Basic/FileManager.h" +#include "clang/InstallAPI/Library.h" + +namespace clang::installapi { + +enum ScanMode { + /// Scanning Framework directory. + ScanFrameworks, + /// Scanning Dylib directory. + ScanDylibs, +}; + +class DirectoryScanner { +public: + DirectoryScanner(FileManager &FM, ScanMode Mode = ScanMode::ScanFrameworks) + : FM(FM), Mode(Mode) {} + + /// Scan for all input files throughout directory. + /// + /// \param Directory Path of input directory. + llvm::Error scan(StringRef Directory); + + /// Take over ownership of stored libraries. + std::vector takeLibraries() { return std::move(Libraries); }; + + /// Get all the header files in libraries. + /// + /// \param Libraries Reference of collection of libraries. + static HeaderSeq getHeaders(ArrayRef Libraries); + +private: + /// Collect files for dylibs in usr/(local)/lib within directory. + llvm::Error scanForUnwrappedLibraries(StringRef Directory); + + /// Collect files for any frameworks within directory. + llvm::Error scanForFrameworks(StringRef Directory); + +
[clang] [flang] Fix more diagnostic wording for style; NFC (PR #93190)
https://github.com/cyndyishida approved this pull request. the InstallAPI changes LGTM, thanks! https://github.com/llvm/llvm-project/pull/93190 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] add JSON option to pass X arguments (PR #91770)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/91770 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] add JSON option to pass X arguments (PR #91770)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/91770 >From 291412a203ea60465d4ecae9317f3490c59bfb50 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 2 May 2024 19:53:07 -0700 Subject: [PATCH 1/3] [InstallAPI] add JSON option to pass X arguments --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 2 +- clang/test/InstallAPI/alias_list.test | 2 +- clang/test/InstallAPI/exclusive-passes-2.test | 9 ++ clang/test/InstallAPI/exclusive-passes-3.test | 86 +++ clang/test/InstallAPI/exclusive-passes.test | 15 .../InstallAPI/invalid-exclusive-passes.test | 33 +++ .../tools/clang-installapi/InstallAPIOpts.td | 3 + clang/tools/clang-installapi/Options.cpp | 74 +++- clang/tools/clang-installapi/Options.h| 2 + 9 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 clang/test/InstallAPI/exclusive-passes-3.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 674742431dcb2..944b2a38b6e96 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; -def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">; +def err_cannot_read_input_list : Error<"could not read %0 input list '%1': %2">; def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X">; } // end of command line category. diff --git a/clang/test/InstallAPI/alias_list.test b/clang/test/InstallAPI/alias_list.test index 3e12221e088c4..aba7e395cca95 100644 --- a/clang/test/InstallAPI/alias_list.test +++ b/clang/test/InstallAPI/alias_list.test @@ -23,7 +23,7 @@ ; RUN: -o %t/AliasList.tbd 2>&1 | FileCheck -allow-empty %s \ ; RUN: --check-prefix=INVALID -; INVALID: error: could not read alias list {{.*}} missing alias for: _hidden +; INVALID: error: could not read symbol alias input list {{.*}}invalid.txt': invalid input format: missing alias for: _hidden ;--- Frameworks/AliasList.framework/Headers/AliasList.h // simple alias from one symbol to another. diff --git a/clang/test/InstallAPI/exclusive-passes-2.test b/clang/test/InstallAPI/exclusive-passes-2.test index 3e7a6d777d5af..132b27df383c4 100644 --- a/clang/test/InstallAPI/exclusive-passes-2.test +++ b/clang/test/InstallAPI/exclusive-passes-2.test @@ -11,6 +11,15 @@ ; RUN: -DFoo -XApple -DDarwin=1 -XElf -DNONDarwin=1 2>&1 | FileCheck -allow-empty %s ; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib \ +; RUN: -current_version 1 -compatibility_version 1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include -dynamiclib \ +; RUN: -extra-public-header %S/Inputs/LibFoo/usr/include/foo.h \ +; RUN: -o %t/output2.tbd \ +; RUN: -DFoo -optionlist %t/options.json 2>&1 | FileCheck -allow-empty %s +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + ; CHECK-NOT: error ; CHECK-NOT: warning diff --git a/clang/test/InstallAPI/exclusive-passes-3.test b/clang/test/InstallAPI/exclusive-passes-3.test new file mode 100644 index 0..3a9b64c9f7b86 --- /dev/null +++ b/clang/test/InstallAPI/exclusive-passes-3.test @@ -0,0 +1,86 @@ +; RUN: rm -rf %t +; RUN: split-file %s %t + +// "Apple" label has split options between the optionlist & command line. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +// Validate duplicated options give same result. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -XApple -DDarwin -XElf -DNONDarwin \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output2.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output2.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +; CHECK-NOT: error +; CHECK-NOT: warning + +;--- u
[clang] [InstallAPI] add JSON option to pass X arguments (PR #91770)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/91770 >From 291412a203ea60465d4ecae9317f3490c59bfb50 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 2 May 2024 19:53:07 -0700 Subject: [PATCH 1/2] [InstallAPI] add JSON option to pass X arguments --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 2 +- clang/test/InstallAPI/alias_list.test | 2 +- clang/test/InstallAPI/exclusive-passes-2.test | 9 ++ clang/test/InstallAPI/exclusive-passes-3.test | 86 +++ clang/test/InstallAPI/exclusive-passes.test | 15 .../InstallAPI/invalid-exclusive-passes.test | 33 +++ .../tools/clang-installapi/InstallAPIOpts.td | 3 + clang/tools/clang-installapi/Options.cpp | 74 +++- clang/tools/clang-installapi/Options.h| 2 + 9 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 clang/test/InstallAPI/exclusive-passes-3.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 674742431dcb2..944b2a38b6e96 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; -def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">; +def err_cannot_read_input_list : Error<"could not read %0 input list '%1': %2">; def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X">; } // end of command line category. diff --git a/clang/test/InstallAPI/alias_list.test b/clang/test/InstallAPI/alias_list.test index 3e12221e088c4..aba7e395cca95 100644 --- a/clang/test/InstallAPI/alias_list.test +++ b/clang/test/InstallAPI/alias_list.test @@ -23,7 +23,7 @@ ; RUN: -o %t/AliasList.tbd 2>&1 | FileCheck -allow-empty %s \ ; RUN: --check-prefix=INVALID -; INVALID: error: could not read alias list {{.*}} missing alias for: _hidden +; INVALID: error: could not read symbol alias input list {{.*}}invalid.txt': invalid input format: missing alias for: _hidden ;--- Frameworks/AliasList.framework/Headers/AliasList.h // simple alias from one symbol to another. diff --git a/clang/test/InstallAPI/exclusive-passes-2.test b/clang/test/InstallAPI/exclusive-passes-2.test index 3e7a6d777d5af..132b27df383c4 100644 --- a/clang/test/InstallAPI/exclusive-passes-2.test +++ b/clang/test/InstallAPI/exclusive-passes-2.test @@ -11,6 +11,15 @@ ; RUN: -DFoo -XApple -DDarwin=1 -XElf -DNONDarwin=1 2>&1 | FileCheck -allow-empty %s ; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib \ +; RUN: -current_version 1 -compatibility_version 1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include -dynamiclib \ +; RUN: -extra-public-header %S/Inputs/LibFoo/usr/include/foo.h \ +; RUN: -o %t/output2.tbd \ +; RUN: -DFoo -optionlist %t/options.json 2>&1 | FileCheck -allow-empty %s +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + ; CHECK-NOT: error ; CHECK-NOT: warning diff --git a/clang/test/InstallAPI/exclusive-passes-3.test b/clang/test/InstallAPI/exclusive-passes-3.test new file mode 100644 index 0..3a9b64c9f7b86 --- /dev/null +++ b/clang/test/InstallAPI/exclusive-passes-3.test @@ -0,0 +1,86 @@ +; RUN: rm -rf %t +; RUN: split-file %s %t + +// "Apple" label has split options between the optionlist & command line. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +// Validate duplicated options give same result. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -XApple -DDarwin -XElf -DNONDarwin \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output2.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output2.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +; CHECK-NOT: error +; CHECK-NOT: warning + +;--- u
[clang] 504cf55 - [InstallAPI] Pass explicit module cache to avoid permissions issues.
Author: Cyndy Ishida Date: 2024-05-10T17:17:38-07:00 New Revision: 504cf554639360525c3f746e7296a242350b2af9 URL: https://github.com/llvm/llvm-project/commit/504cf554639360525c3f746e7296a242350b2af9 DIFF: https://github.com/llvm/llvm-project/commit/504cf554639360525c3f746e7296a242350b2af9.diff LOG: [InstallAPI] Pass explicit module cache to avoid permissions issues. Fixes: https://lab.llvm.org/buildbot/#/builders/192/builds/9313 Added: Modified: clang/test/InstallAPI/project-header-only-args.test clang/tools/clang-installapi/Options.cpp Removed: diff --git a/clang/test/InstallAPI/project-header-only-args.test b/clang/test/InstallAPI/project-header-only-args.test index 7147c83b0f5d4..76fecce5b4a26 100644 --- a/clang/test/InstallAPI/project-header-only-args.test +++ b/clang/test/InstallAPI/project-header-only-args.test @@ -1,11 +1,13 @@ ; RUN: rm -rf %t ; RUN: split-file %s %t ; RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json +; RUN: mkdir -p %t/modules.cache ; RUN: clang-installapi \ ; RUN: -target arm64-apple-macos12 -install_name @rpath/libfoo.dylib \ ; RUN: -current_version 1 -compatibility_version 1 \ ; RUN: -Xproject -fmodules -I%t/usr/include \ +; RUN: -Xproject -fmodules-cache-path=%t/modules.cache \ ; RUN: -F %S/Inputs/Foundation/ \ ; RUN: -exclude-public-header %t/usr/include/public.h \ ; RUN: -extra-project-header %t/project.h -I%t -dynamiclib \ @@ -17,6 +19,7 @@ ; RUN: -target arm64-apple-macos12 -install_name @rpath/libfoo.dylib \ ; RUN: -current_version 1 -compatibility_version 1 \ ; RUN: -Xproject -fmodules -I%t/usr/include \ +; RUN: -Xproject -fmodules-cache-path=%t/modules.cache \ ; RUN: -extra-project-header %t/project.h \ ; RUN: -F %S/Inputs/Foundation/ \ ; RUN: %t/inputs.json \ diff --git a/clang/tools/clang-installapi/Options.cpp b/clang/tools/clang-installapi/Options.cpp index 5396ad23620b9..53340da704fc0 100644 --- a/clang/tools/clang-installapi/Options.cpp +++ b/clang/tools/clang-installapi/Options.cpp @@ -299,8 +299,11 @@ bool Options::processXprojectOption(InputArgList &Args, arg_iterator Curr) { return false; } - ProjectLevelArgs.push_back(NextA->getSpelling().str()); - llvm::copy(NextA->getValues(), std::back_inserter(ProjectLevelArgs)); + std::string ArgString = NextA->getSpelling().str(); + for (const StringRef Val : NextA->getValues()) +ArgString += Val.str(); + + ProjectLevelArgs.push_back(ArgString); A->claim(); NextA->claim(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] add JSON option to pass X arguments (PR #91770)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/91770 None >From 480f1a6dd0c78c8018ac08259b4d3cba64c25165 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 2 May 2024 19:53:07 -0700 Subject: [PATCH] [InstallAPI] add JSON option to pass X arguments --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 2 +- clang/test/InstallAPI/alias_list.test | 2 +- clang/test/InstallAPI/exclusive-passes-2.test | 9 ++ clang/test/InstallAPI/exclusive-passes-3.test | 86 +++ clang/test/InstallAPI/exclusive-passes.test | 15 .../InstallAPI/invalid-exclusive-passes.test | 33 +++ .../tools/clang-installapi/InstallAPIOpts.td | 3 + clang/tools/clang-installapi/Options.cpp | 74 +++- clang/tools/clang-installapi/Options.h| 2 + 9 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 clang/test/InstallAPI/exclusive-passes-3.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 674742431dcb2..944b2a38b6e96 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; -def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">; +def err_cannot_read_input_list : Error<"could not read %0 input list '%1': %2">; def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X">; } // end of command line category. diff --git a/clang/test/InstallAPI/alias_list.test b/clang/test/InstallAPI/alias_list.test index 3e12221e088c4..aba7e395cca95 100644 --- a/clang/test/InstallAPI/alias_list.test +++ b/clang/test/InstallAPI/alias_list.test @@ -23,7 +23,7 @@ ; RUN: -o %t/AliasList.tbd 2>&1 | FileCheck -allow-empty %s \ ; RUN: --check-prefix=INVALID -; INVALID: error: could not read alias list {{.*}} missing alias for: _hidden +; INVALID: error: could not read symbol alias input list {{.*}}invalid.txt': invalid input format: missing alias for: _hidden ;--- Frameworks/AliasList.framework/Headers/AliasList.h // simple alias from one symbol to another. diff --git a/clang/test/InstallAPI/exclusive-passes-2.test b/clang/test/InstallAPI/exclusive-passes-2.test index 3e7a6d777d5af..132b27df383c4 100644 --- a/clang/test/InstallAPI/exclusive-passes-2.test +++ b/clang/test/InstallAPI/exclusive-passes-2.test @@ -11,6 +11,15 @@ ; RUN: -DFoo -XApple -DDarwin=1 -XElf -DNONDarwin=1 2>&1 | FileCheck -allow-empty %s ; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib \ +; RUN: -current_version 1 -compatibility_version 1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include -dynamiclib \ +; RUN: -extra-public-header %S/Inputs/LibFoo/usr/include/foo.h \ +; RUN: -o %t/output2.tbd \ +; RUN: -DFoo -optionlist %t/options.json 2>&1 | FileCheck -allow-empty %s +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + ; CHECK-NOT: error ; CHECK-NOT: warning diff --git a/clang/test/InstallAPI/exclusive-passes-3.test b/clang/test/InstallAPI/exclusive-passes-3.test new file mode 100644 index 0..3a9b64c9f7b86 --- /dev/null +++ b/clang/test/InstallAPI/exclusive-passes-3.test @@ -0,0 +1,86 @@ +; RUN: rm -rf %t +; RUN: split-file %s %t + +// "Apple" label has split options between the optionlist & command line. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +// Validate duplicated options give same result. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -XApple -DDarwin -XElf -DNONDarwin \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output2.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output2.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +; CHECK-NOT: error +; CHECK-NOT: warning + +;---
[clang] [llvm] [InstallAPI] Support mutually exclusive parse options (PR #90686)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/90686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstallAPI] Support mutually exclusive parse options (PR #90686)
cyndyishida wrote: ping https://github.com/llvm/llvm-project/pull/90686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstallAPI] Support mutually exclusive parse options (PR #90686)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/90686 >From faabe7752dbb596f13e0e676b5c8db9fb8ad9258 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 18 Apr 2024 07:28:44 -0700 Subject: [PATCH] [InstallAPI] Support mutually exclusive parse options Projects like libc use mutually exclusive macros to compile files multiple times then merge the result into the final library. For installapi to accept these, we'd need to parse the same declarations in different ways. This patch add the basic pipelining for installapi to create the correct TBD file. * -Xproject allows: -fmodules, -fobjc-arc, fvisibility=hidden, prefix headers * -Xlabel allows: -D and -U settings * Error on 'private' and 'public' labels -X * Xplatform allows: -iframework This is to support the case where zippered frameworks want to pass in iOSSupport search path. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 1 + clang/include/clang/InstallAPI/MachO.h| 2 + .../Modules/module.modulemap | 3 + .../Inputs/LibFoo/usr/include/foo.h | 15 + .../Inputs/LibFoo/usr/include/macro_defs.h| 15 + .../Inputs/LibFoo/usr/include/public.h| 9 + .../Zippered.framework/Headers/Zippered.h | 20 + .../PrivateHeaders/Zippered_Private.h | 9 + .../InstallAPI/Inputs/Zippered/Zippered.tbd | 47 +++ .../InstallAPI/Inputs/Zippered/Zippered.yaml | 383 ++ clang/test/InstallAPI/exclusive-passes-2.test | 58 +++ .../InstallAPI/exclusive-passes-platform.test | 286 + .../InstallAPI/exclusive-passes-zippered.test | 56 +++ clang/test/InstallAPI/exclusive-passes.test | 54 +++ .../InstallAPI/invalid-exclusive-passes.test | 37 ++ .../InstallAPI/project-header-only-args.test | 81 .../clang-installapi/ClangInstallAPI.cpp | 22 +- .../tools/clang-installapi/InstallAPIOpts.td | 30 ++ clang/tools/clang-installapi/Options.cpp | 187 +++-- clang/tools/clang-installapi/Options.h| 13 +- llvm/include/llvm/TextAPI/Utils.h | 9 + llvm/lib/TextAPI/Utils.cpp| 10 + 22 files changed, 1316 insertions(+), 31 deletions(-) create mode 100644 clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/foo.h create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/macro_defs.h create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/public.h create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/Headers/Zippered.h create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/PrivateHeaders/Zippered_Private.h create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.tbd create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.yaml create mode 100644 clang/test/InstallAPI/exclusive-passes-2.test create mode 100644 clang/test/InstallAPI/exclusive-passes-platform.test create mode 100644 clang/test/InstallAPI/exclusive-passes-zippered.test create mode 100644 clang/test/InstallAPI/exclusive-passes.test create mode 100644 clang/test/InstallAPI/invalid-exclusive-passes.test create mode 100644 clang/test/InstallAPI/project-header-only-args.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 6896e0f5aa593c..674742431dcb2d 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -25,6 +25,7 @@ def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">; +def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/InstallAPI/MachO.h b/clang/include/clang/InstallAPI/MachO.h index 9da91a62e23311..1ea544412f4cd8 100644 --- a/clang/include/clang/InstallAPI/MachO.h +++ b/clang/include/clang/InstallAPI/MachO.h @@ -45,6 +45,8 @@ using SimpleSymbol = llvm::MachO::SimpleSymbol; using FileType = llvm::MachO::FileType; using PackedVersion = llvm::MachO::PackedVersion; using PathSeq = llvm::MachO::PathSeq; +using PlatformType = llvm::MachO::PlatformType; +using PathToPlatformSeq = llvm::MachO::PathToPlatformSeq; using Target = llvm::MachO::Target; using TargetList = llvm::MachO::TargetList; diff --git a/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap b/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap new file mode 100644 index 00..2bb688da1fa4b0 ---
[clang] [llvm] [InstallAPI] Support mutually exclusive parse options (PR #90686)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/90686 >From c4fec501607059b1030b7c53794ad271194d Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 18 Apr 2024 07:28:44 -0700 Subject: [PATCH 1/2] [InstallAPI] Support mutually exclusive parse options Projects like libc use mutually exclusive macros to compile files multiple times then merge the result into the final library. For installapi to accept these, we'd need to parse the same declarations in different ways. This patch add the basic pipelining for installapi to create the correct TBD file. * -Xproject allows: -fmodules, -fobjc-arc, fvisibility=hidden, prefix headers * -Xlabel allows: -D and -U settings * Error on 'private' and 'public' labels -X * Xplatform allows: -iframework This is to support the case where zippered frameworks want to pass in iOSSupport search path. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 1 + clang/include/clang/InstallAPI/MachO.h| 2 + .../Modules/module.modulemap | 3 + .../Inputs/LibFoo/usr/include/foo.h | 20 + .../Inputs/LibFoo/usr/include/public.h| 14 + .../Zippered.framework/Headers/Zippered.h | 20 + .../PrivateHeaders/Zippered_Private.h | 9 + .../InstallAPI/Inputs/Zippered/Zippered.tbd | 47 +++ .../InstallAPI/Inputs/Zippered/Zippered.yaml | 383 ++ clang/test/InstallAPI/exclusive-passes-2.test | 58 +++ .../InstallAPI/exclusive-passes-platform.test | 277 + .../InstallAPI/exclusive-passes-zippered.test | 56 +++ clang/test/InstallAPI/exclusive-passes.test | 54 +++ .../InstallAPI/invalid-exclusive-passes.test | 37 ++ .../InstallAPI/project-header-only-args.test | 81 .../clang-installapi/ClangInstallAPI.cpp | 20 +- .../tools/clang-installapi/InstallAPIOpts.td | 30 ++ clang/tools/clang-installapi/Options.cpp | 187 +++-- clang/tools/clang-installapi/Options.h| 13 +- llvm/include/llvm/TextAPI/Utils.h | 9 + llvm/lib/TextAPI/Utils.cpp| 10 + 21 files changed, 1301 insertions(+), 30 deletions(-) create mode 100644 clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/foo.h create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/public.h create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/Headers/Zippered.h create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/PrivateHeaders/Zippered_Private.h create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.tbd create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.yaml create mode 100644 clang/test/InstallAPI/exclusive-passes-2.test create mode 100644 clang/test/InstallAPI/exclusive-passes-platform.test create mode 100644 clang/test/InstallAPI/exclusive-passes-zippered.test create mode 100644 clang/test/InstallAPI/exclusive-passes.test create mode 100644 clang/test/InstallAPI/invalid-exclusive-passes.test create mode 100644 clang/test/InstallAPI/project-header-only-args.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 6896e0f5aa593c..674742431dcb2d 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -25,6 +25,7 @@ def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">; +def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/InstallAPI/MachO.h b/clang/include/clang/InstallAPI/MachO.h index 9da91a62e23311..1ea544412f4cd8 100644 --- a/clang/include/clang/InstallAPI/MachO.h +++ b/clang/include/clang/InstallAPI/MachO.h @@ -45,6 +45,8 @@ using SimpleSymbol = llvm::MachO::SimpleSymbol; using FileType = llvm::MachO::FileType; using PackedVersion = llvm::MachO::PackedVersion; using PathSeq = llvm::MachO::PathSeq; +using PlatformType = llvm::MachO::PlatformType; +using PathToPlatformSeq = llvm::MachO::PathToPlatformSeq; using Target = llvm::MachO::Target; using TargetList = llvm::MachO::TargetList; diff --git a/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap b/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap new file mode 100644 index 00..2bb688da1fa4b0 --- /dev/null +++ b/clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap @@ -0,0 +1,3 @@ +framework m
[clang] [llvm] [InstallAPI] Support mutually exclusive parse options (PR #90686)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/90686 Projects like libc use mutually exclusive macros to compile files multiple times and then merge the result into the final library. For installapi to accept these, we'd need to parse the same declarations in different ways. This patch adds the basic pipelining for installapi to create the correct TBD file. * -Xproject allows: -fmodules, -fobjc-arc, fvisibility=hidden, prefix headers * -Xlabel allows: -D and -U settings * Error on 'private' and 'public' labels -X * Xplatform allows: -iframework This is to support the case where zippered frameworks want to pass in iOSSupport search path. >From c4fec501607059b1030b7c53794ad271194d Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 18 Apr 2024 07:28:44 -0700 Subject: [PATCH] [InstallAPI] Support mutually exclusive parse options Projects like libc use mutually exclusive macros to compile files multiple times then merge the result into the final library. For installapi to accept these, we'd need to parse the same declarations in different ways. This patch add the basic pipelining for installapi to create the correct TBD file. * -Xproject allows: -fmodules, -fobjc-arc, fvisibility=hidden, prefix headers * -Xlabel allows: -D and -U settings * Error on 'private' and 'public' labels -X * Xplatform allows: -iframework This is to support the case where zippered frameworks want to pass in iOSSupport search path. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 1 + clang/include/clang/InstallAPI/MachO.h| 2 + .../Modules/module.modulemap | 3 + .../Inputs/LibFoo/usr/include/foo.h | 20 + .../Inputs/LibFoo/usr/include/public.h| 14 + .../Zippered.framework/Headers/Zippered.h | 20 + .../PrivateHeaders/Zippered_Private.h | 9 + .../InstallAPI/Inputs/Zippered/Zippered.tbd | 47 +++ .../InstallAPI/Inputs/Zippered/Zippered.yaml | 383 ++ clang/test/InstallAPI/exclusive-passes-2.test | 58 +++ .../InstallAPI/exclusive-passes-platform.test | 277 + .../InstallAPI/exclusive-passes-zippered.test | 56 +++ clang/test/InstallAPI/exclusive-passes.test | 54 +++ .../InstallAPI/invalid-exclusive-passes.test | 37 ++ .../InstallAPI/project-header-only-args.test | 81 .../clang-installapi/ClangInstallAPI.cpp | 20 +- .../tools/clang-installapi/InstallAPIOpts.td | 30 ++ clang/tools/clang-installapi/Options.cpp | 187 +++-- clang/tools/clang-installapi/Options.h| 13 +- llvm/include/llvm/TextAPI/Utils.h | 9 + llvm/lib/TextAPI/Utils.cpp| 10 + 21 files changed, 1301 insertions(+), 30 deletions(-) create mode 100644 clang/test/InstallAPI/Inputs/Foundation/Foundation.framework/Modules/module.modulemap create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/foo.h create mode 100644 clang/test/InstallAPI/Inputs/LibFoo/usr/include/public.h create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/Headers/Zippered.h create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.framework/PrivateHeaders/Zippered_Private.h create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.tbd create mode 100644 clang/test/InstallAPI/Inputs/Zippered/Zippered.yaml create mode 100644 clang/test/InstallAPI/exclusive-passes-2.test create mode 100644 clang/test/InstallAPI/exclusive-passes-platform.test create mode 100644 clang/test/InstallAPI/exclusive-passes-zippered.test create mode 100644 clang/test/InstallAPI/exclusive-passes.test create mode 100644 clang/test/InstallAPI/invalid-exclusive-passes.test create mode 100644 clang/test/InstallAPI/project-header-only-args.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 6896e0f5aa593c..674742431dcb2d 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -25,6 +25,7 @@ def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">; +def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/InstallAPI/MachO.h b/clang/include/clang/InstallAPI/MachO.h index 9da91a62e23311..1ea544412f4cd8 100644 --- a/clang/include/clang/InstallAPI/MachO.h +++ b/clang/include/clang/InstallAPI/MachO.h @@ -45,6 +45,8 @@ using SimpleSymbol = llvm::MachO::SimpleSymbol; using FileType = llvm::MachO::FileType; using PackedVersion = llvm::MachO::PackedVersion; using PathSeq = ll
[clang] [InstallAPI] Cleanup I/O error handling for input lists (PR #90664)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/90664 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Cleanup I/O error handling for input lists (PR #90664)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/90664 Add validation in the FileList reader to check that the headers exist and use similar diagnostics in Options.cpp >From 42ad6921fdf179647f6529ddeb7d060e93e0f52f Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Tue, 30 Apr 2024 11:24:42 -0700 Subject: [PATCH] [InstallAPI] Cleanup I/O error handling for input lists Add validation in FileList reader to actually check that the files exist and refactor common code in Options.cpp --- clang/include/clang/Basic/DiagnosticInstallAPIKinds.td | 2 +- clang/include/clang/InstallAPI/FileList.h | 3 ++- clang/lib/InstallAPI/FileList.cpp | 10 +- clang/tools/clang-installapi/Options.cpp | 9 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 91a40cd589b385..6896e0f5aa593c 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; -def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">; +def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/InstallAPI/FileList.h b/clang/include/clang/InstallAPI/FileList.h index 460af003b6a0ac..913734b8dc7c88 100644 --- a/clang/include/clang/InstallAPI/FileList.h +++ b/clang/include/clang/InstallAPI/FileList.h @@ -29,9 +29,10 @@ class FileListReader { /// /// \param InputBuffer JSON input data. /// \param Destination Container to load headers into. + /// \param FM Optional File Manager to validate input files exist. static llvm::Error loadHeaders(std::unique_ptr InputBuffer, - HeaderSeq &Destination); + HeaderSeq &Destination, clang::FileManager *FM = nullptr); FileListReader() = delete; }; diff --git a/clang/lib/InstallAPI/FileList.cpp b/clang/lib/InstallAPI/FileList.cpp index 8a01248659b7d7..65610903840af7 100644 --- a/clang/lib/InstallAPI/FileList.cpp +++ b/clang/lib/InstallAPI/FileList.cpp @@ -51,6 +51,7 @@ class Implementation { public: std::unique_ptr InputBuffer; + clang::FileManager *FM; unsigned Version; HeaderSeq HeaderList; @@ -124,6 +125,12 @@ Error Implementation::parseHeaders(Array &Headers) { HeaderFile{PathStr, *Type, /*IncludeName=*/"", Language}); continue; } + +if (FM) + if (!FM->getOptionalFileRef(PathStr)) +return createFileError( +PathStr, make_error_code(std::errc::no_such_file_or_directory)); + auto IncludeName = createIncludeHeaderName(PathStr); HeaderList.emplace_back(PathStr, *Type, IncludeName.has_value() ? IncludeName.value() : "", @@ -170,9 +177,10 @@ Error Implementation::parse(StringRef Input) { llvm::Error FileListReader::loadHeaders(std::unique_ptr InputBuffer, -HeaderSeq &Destination) { +HeaderSeq &Destination, clang::FileManager *FM) { Implementation Impl; Impl.InputBuffer = std::move(InputBuffer); + Impl.FM = FM; if (llvm::Error Err = Impl.parse(Impl.InputBuffer->getBuffer())) return Err; diff --git a/clang/tools/clang-installapi/Options.cpp b/clang/tools/clang-installapi/Options.cpp index ae5b697b8eb9e0..21f04a291b2f1f 100644 --- a/clang/tools/clang-installapi/Options.cpp +++ b/clang/tools/clang-installapi/Options.cpp @@ -697,8 +697,8 @@ InstallAPIContext Options::createContext() { } Expected Result = parseAliasList(Buffer.get()); if (!Result) { - Diags->Report(diag::err_cannot_read_alias_list) - << ListPath << toString(Result.takeError()); + Diags->Report(diag::err_cannot_read_input_list) + << /*IsFileList=*/false << ListPath << toString(Result.takeError()); return Ctx; } Aliases.insert(Result.get().begin(), Result.get().end()); @@ -717,8 +717,9 @@ InstallAPIContext Options::createContext() { return Ctx; } if (auto Err = FileListReader::loadHeaders(std::move(Buffer.get()), - Ctx.InputHeaders)) { - Diags->Report(diag::err_cannot_open_file) << ListPath << std::move(Err); + Ctx.InputHeaders, FM)) { + Diags->Report(diag::err_cannot_read_input_list) + << /*IsFileList=*/true << ListPath << std::move(Err); return Ctx; } } ___
[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)
cyndyishida wrote: > Overall I really like the direction of this. I'm curious if any of the > maintainers from Apple have thoughts since they're the primary users of > availability annotations. While I like the approach of aligning availability parameters closer to `llvm::Triple`, I am concerned about how this will interact with existing precedent. There is a lot of code that passes in _platform_ values that aren't actually `OSType`. For example `__attribute__((availability(macCatalyst, ...))` aligns to `EnviornmentType::MacABI` and `__attribute__((availability(macOSApplicationExtension, ...)))` aligns to cli args `-mtargetos=macos -fapplication-extension`. It may become difficult to maintain the distinction between what is accepted as a `platform` vs a `environment`. And we can't realistically re-write client code relying on this. This attribute behavior also aligns very closely with Swift's `@available` Would it be possible to similarly treat the target shader stages & combinations as platform values as well? Or define a new attribute that does not conflict. https://github.com/llvm/llvm-project/pull/89809 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [mlir] [lldb][Core] Remove pointless condition (PR #89480)
cyndyishida wrote: It appears your PR branch is based on a stale version of the target `llvm/main` branch, resulting in more commits than what this PR intended for. Please merge in the target branch and resolve any conflicts. https://github.com/llvm/llvm-project/pull/89480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Apple][cmake] Disable plugin support at LLVM level (PR #89483)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/89483 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Apple][cmake] Disable plugin support at LLVM level (PR #89483)
https://github.com/cyndyishida edited https://github.com/llvm/llvm-project/pull/89483 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Apple][cmake] Disable plugin support at LLVM level (PR #89483)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/89483 Matches up with the clang tools >From 76ece379c8a8325b0f866a89e1de523cbeaa0c25 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Fri, 19 Apr 2024 19:34:14 -0700 Subject: [PATCH] [clang][darwin][cmake] Disable plugin support at LLVM level --- clang/cmake/caches/Apple-stage2.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/cmake/caches/Apple-stage2.cmake b/clang/cmake/caches/Apple-stage2.cmake index ede256a2da6b8f..e919c56739679e 100644 --- a/clang/cmake/caches/Apple-stage2.cmake +++ b/clang/cmake/caches/Apple-stage2.cmake @@ -16,6 +16,7 @@ set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") set(LLVM_ENABLE_MODULES ON CACHE BOOL "") set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "") set(LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES OFF CACHE BOOL "") +set(LLVM_PLUGIN_SUPPORT OFF CACHE BOOL "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") set(CLANG_SPAWN_CC1 ON CACHE BOOL "") set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "") ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI][Tests] Update tests to be resilient to reversion iteration config (PR #89270)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/89270 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI][Tests] Update tests to be resilient to reversion iteration config (PR #89270)
cyndyishida wrote: > How hard would it be to make the output here have a consistent order? I mean, > emitting diagnostics in a consistent order isn't nearly as important as > emitting consistent binaries, but it's still nice to have if we can get it > easily. I don't think it's too hard in general, but a little more effort to get it done in a performant fashion for the passing InstallAPI case. Something I'd want to profile before committing to. https://github.com/llvm/llvm-project/pull/89270 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)
cyndyishida wrote: > It looks like this is causing failures on the reverse-iteration buildbot > (https://lab.llvm.org/buildbot/#/builders/54/builds/9683) Thanks for the heads up, should be fixed by https://github.com/llvm/llvm-project/pull/89270 https://github.com/llvm/llvm-project/pull/87674 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI][Tests] Update tests to be resilient to reversion iteration config (PR #89270)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/89270 None >From efefd04b1545b62f3a22bc0ff53bfb0a2a512b1f Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 18 Apr 2024 10:24:35 -0700 Subject: [PATCH] [InstallAPI][Tests] Update tests to be resilient to reversion iteration config --- clang/test/InstallAPI/binary-attributes.test | 2 +- clang/test/InstallAPI/rpath.test | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/test/InstallAPI/binary-attributes.test b/clang/test/InstallAPI/binary-attributes.test index d97c7a14a98d78..b28e99f6445462 100644 --- a/clang/test/InstallAPI/binary-attributes.test +++ b/clang/test/InstallAPI/binary-attributes.test @@ -43,7 +43,7 @@ ; RUN: -current_version 1.2.3 -compatibility_version 1 \ ; RUN: -allowable_client Foo -allowable_client Bar \ ; RUN: -o tmp.tbd --verify-against=%t/Simple 2>&1 | FileCheck -check-prefix=ALLOWABLE %s -; ALLOWABLE: error: allowable client missing from binary file: 'Foo [ x86_64 ]' +; ALLOWABLE: error: allowable client missing from binary file: '{{Foo|Bar}} [ x86_64 ]' ; RUN: not clang-installapi -target x86_64-apple-macos10.12 \ ; RUN: -install_name /System/Library/Frameworks/Simple.framework/Versions/A/Simple \ diff --git a/clang/test/InstallAPI/rpath.test b/clang/test/InstallAPI/rpath.test index 083a15419abaab..ace9c47b6e686a 100644 --- a/clang/test/InstallAPI/rpath.test +++ b/clang/test/InstallAPI/rpath.test @@ -12,8 +12,8 @@ ; RUN: --verify-mode=Pedantic 2>&1 | FileCheck %s --check-prefix=MISSING ; RUN: llvm-readtapi --compare %t/RPath_warnings.tbd %t/expected_no_rpaths.tbd -; MISSING: warning: runpath search paths missing from installAPI option: '@loader_path/../../../SharedFrameworks/ [ x86_64 arm64 ]' -; MISSING: warning: runpath search paths missing from installAPI option: '@loader_path/../../PrivateFrameworks/ [ x86_64 arm64 ]' +; MISSING-DAG: warning: runpath search paths missing from installAPI option: '@loader_path/../../../SharedFrameworks/ [ x86_64 arm64 ]' +; MISSING-DAG: warning: runpath search paths missing from installAPI option: '@loader_path/../../PrivateFrameworks/ [ x86_64 arm64 ]' ; RUN: clang-installapi --filetype=tbd-v5 \ ; RUN: -target arm64-apple-macos13.0 -target x86_64-apple-macos13.0 \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/88750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)
@@ -259,7 +259,10 @@ bool Options::processLinkerOptions(InputArgList &Args) { if (auto *Arg = Args.getLastArg(drv::OPT_umbrella)) LinkerOpts.ParentUmbrella = Arg->getValue(); - LinkerOpts.IsDylib = Args.hasArg(drv::OPT_dynamiclib); cyndyishida wrote: nope, looks like I was missing some test coverage, added one implicitly here https://github.com/llvm/llvm-project/pull/88750/files#diff-0b1bbd3584706760de8a4030db1b04120c2c7c1f640681be80114f59278988bfR22 https://github.com/llvm/llvm-project/pull/88750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/88750 >From b2b54ad8ccf930a19327563a64c52c9f4013103f Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 11 Apr 2024 13:13:45 -0700 Subject: [PATCH 1/4] [InstallAPI] Add support for aliased exports Apple's ld supports alias_lists, described as ``` -alias_list filename The specified filename contains a list of aliases. The symbol name and its alias are on one line, separated by whitespace. Lines starting with # are ignored. ``` To handle this for installapi-produced TBD files, pass along the same input and account for it in verification. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 1 + clang/include/clang/Driver/Options.td | 1 + .../include/clang/InstallAPI/DylibVerifier.h | 15 +- clang/include/clang/InstallAPI/MachO.h| 1 + clang/lib/InstallAPI/DylibVerifier.cpp| 24 + clang/test/InstallAPI/alias_list.test | 461 ++ clang/tools/clang-installapi/Options.cpp | 24 +- clang/tools/clang-installapi/Options.h| 3 + llvm/include/llvm/TextAPI/Utils.h | 12 + llvm/lib/TextAPI/Utils.cpp| 34 ++ 10 files changed, 569 insertions(+), 7 deletions(-) create mode 100644 clang/test/InstallAPI/alias_list.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 396bff0146a373..91a40cd589b385 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; +def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e24626913add76..8c38acb72362c7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], "end-no-unused-arguments">, def interface_stub_version_EQ : JoinedOrSeparate<["-"], "interface-stub-version=">, Visibility<[ClangOption, CC1Option]>; def exported__symbols__list : Separate<["-"], "exported_symbols_list">; +def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>; def extract_api : Flag<["-"], "extract-api">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Extract API information">; diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h b/clang/include/clang/InstallAPI/DylibVerifier.h index 31de212fc423a5..f1a949d8f99394 100644 --- a/clang/include/clang/InstallAPI/DylibVerifier.h +++ b/clang/include/clang/InstallAPI/DylibVerifier.h @@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor { DylibVerifier() = default; DylibVerifier(llvm::MachO::Records &&Dylib, ReexportedInterfaces &&Reexports, -DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered, -bool Demangle, StringRef DSYMPath) - : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode), -Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath), +AliasMap Aliases, DiagnosticsEngine *Diag, +VerificationMode Mode, bool Zippered, bool Demangle, +StringRef DSYMPath) + : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), +Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered), +Demangle(Demangle), DSYMPath(DSYMPath), Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {} Result verify(GlobalRecord *R, const FrontendAttrs *FA); @@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor { void setTarget(const Target &T); /// Release ownership over exports. - std::unique_ptr getExports() { return std::move(Exports); } + std::unique_ptr getExports(); /// Get result of verification. Result getState() const { return Ctx.FrontendState; } @@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor { // Reexported interfaces apart of the library. ReexportedInterfaces Reexports; + // Symbol aliases. + AliasMap Aliases; + // Controls what class of violations to report. VerificationMode Mode = VerificationMode::Invalid; diff --git a/clang/include/clang/InstallAPI/MachO.h b/clang/include/clang/InstallAPI/MachO.h index 854399f54ba6c8..9da91a62e23311 100644 --- a/clang/include/clang/InstallAPI/MachO.h +++ b/clang/include/clang/InstallAPI/MachO.h @@ -23,6 +23,7 @@ #include "llvm/TextAPI/TextAPIWriter.h" #incl
[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)
cyndyishida wrote: ping, is there anything else needed to land this patch? https://github.com/llvm/llvm-project/pull/88750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/88750 >From b2b54ad8ccf930a19327563a64c52c9f4013103f Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 11 Apr 2024 13:13:45 -0700 Subject: [PATCH 1/3] [InstallAPI] Add support for aliased exports Apple's ld supports alias_lists, described as ``` -alias_list filename The specified filename contains a list of aliases. The symbol name and its alias are on one line, separated by whitespace. Lines starting with # are ignored. ``` To handle this for installapi-produced TBD files, pass along the same input and account for it in verification. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 1 + clang/include/clang/Driver/Options.td | 1 + .../include/clang/InstallAPI/DylibVerifier.h | 15 +- clang/include/clang/InstallAPI/MachO.h| 1 + clang/lib/InstallAPI/DylibVerifier.cpp| 24 + clang/test/InstallAPI/alias_list.test | 461 ++ clang/tools/clang-installapi/Options.cpp | 24 +- clang/tools/clang-installapi/Options.h| 3 + llvm/include/llvm/TextAPI/Utils.h | 12 + llvm/lib/TextAPI/Utils.cpp| 34 ++ 10 files changed, 569 insertions(+), 7 deletions(-) create mode 100644 clang/test/InstallAPI/alias_list.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 396bff0146a373..91a40cd589b385 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; +def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e24626913add76..8c38acb72362c7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], "end-no-unused-arguments">, def interface_stub_version_EQ : JoinedOrSeparate<["-"], "interface-stub-version=">, Visibility<[ClangOption, CC1Option]>; def exported__symbols__list : Separate<["-"], "exported_symbols_list">; +def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>; def extract_api : Flag<["-"], "extract-api">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Extract API information">; diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h b/clang/include/clang/InstallAPI/DylibVerifier.h index 31de212fc423a5..f1a949d8f99394 100644 --- a/clang/include/clang/InstallAPI/DylibVerifier.h +++ b/clang/include/clang/InstallAPI/DylibVerifier.h @@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor { DylibVerifier() = default; DylibVerifier(llvm::MachO::Records &&Dylib, ReexportedInterfaces &&Reexports, -DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered, -bool Demangle, StringRef DSYMPath) - : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode), -Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath), +AliasMap Aliases, DiagnosticsEngine *Diag, +VerificationMode Mode, bool Zippered, bool Demangle, +StringRef DSYMPath) + : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), +Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered), +Demangle(Demangle), DSYMPath(DSYMPath), Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {} Result verify(GlobalRecord *R, const FrontendAttrs *FA); @@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor { void setTarget(const Target &T); /// Release ownership over exports. - std::unique_ptr getExports() { return std::move(Exports); } + std::unique_ptr getExports(); /// Get result of verification. Result getState() const { return Ctx.FrontendState; } @@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor { // Reexported interfaces apart of the library. ReexportedInterfaces Reexports; + // Symbol aliases. + AliasMap Aliases; + // Controls what class of violations to report. VerificationMode Mode = VerificationMode::Invalid; diff --git a/clang/include/clang/InstallAPI/MachO.h b/clang/include/clang/InstallAPI/MachO.h index 854399f54ba6c8..9da91a62e23311 100644 --- a/clang/include/clang/InstallAPI/MachO.h +++ b/clang/include/clang/InstallAPI/MachO.h @@ -23,6 +23,7 @@ #include "llvm/TextAPI/TextAPIWriter.h" #incl
[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/88750 >From b2b54ad8ccf930a19327563a64c52c9f4013103f Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 11 Apr 2024 13:13:45 -0700 Subject: [PATCH 1/2] [InstallAPI] Add support for aliased exports Apple's ld supports alias_lists, described as ``` -alias_list filename The specified filename contains a list of aliases. The symbol name and its alias are on one line, separated by whitespace. Lines starting with # are ignored. ``` To handle this for installapi-produced TBD files, pass along the same input and account for it in verification. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 1 + clang/include/clang/Driver/Options.td | 1 + .../include/clang/InstallAPI/DylibVerifier.h | 15 +- clang/include/clang/InstallAPI/MachO.h| 1 + clang/lib/InstallAPI/DylibVerifier.cpp| 24 + clang/test/InstallAPI/alias_list.test | 461 ++ clang/tools/clang-installapi/Options.cpp | 24 +- clang/tools/clang-installapi/Options.h| 3 + llvm/include/llvm/TextAPI/Utils.h | 12 + llvm/lib/TextAPI/Utils.cpp| 34 ++ 10 files changed, 569 insertions(+), 7 deletions(-) create mode 100644 clang/test/InstallAPI/alias_list.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 396bff0146a373..91a40cd589b385 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; +def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e24626913add76..8c38acb72362c7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], "end-no-unused-arguments">, def interface_stub_version_EQ : JoinedOrSeparate<["-"], "interface-stub-version=">, Visibility<[ClangOption, CC1Option]>; def exported__symbols__list : Separate<["-"], "exported_symbols_list">; +def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>; def extract_api : Flag<["-"], "extract-api">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Extract API information">; diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h b/clang/include/clang/InstallAPI/DylibVerifier.h index 31de212fc423a5..f1a949d8f99394 100644 --- a/clang/include/clang/InstallAPI/DylibVerifier.h +++ b/clang/include/clang/InstallAPI/DylibVerifier.h @@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor { DylibVerifier() = default; DylibVerifier(llvm::MachO::Records &&Dylib, ReexportedInterfaces &&Reexports, -DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered, -bool Demangle, StringRef DSYMPath) - : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode), -Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath), +AliasMap Aliases, DiagnosticsEngine *Diag, +VerificationMode Mode, bool Zippered, bool Demangle, +StringRef DSYMPath) + : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), +Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered), +Demangle(Demangle), DSYMPath(DSYMPath), Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {} Result verify(GlobalRecord *R, const FrontendAttrs *FA); @@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor { void setTarget(const Target &T); /// Release ownership over exports. - std::unique_ptr getExports() { return std::move(Exports); } + std::unique_ptr getExports(); /// Get result of verification. Result getState() const { return Ctx.FrontendState; } @@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor { // Reexported interfaces apart of the library. ReexportedInterfaces Reexports; + // Symbol aliases. + AliasMap Aliases; + // Controls what class of violations to report. VerificationMode Mode = VerificationMode::Invalid; diff --git a/clang/include/clang/InstallAPI/MachO.h b/clang/include/clang/InstallAPI/MachO.h index 854399f54ba6c8..9da91a62e23311 100644 --- a/clang/include/clang/InstallAPI/MachO.h +++ b/clang/include/clang/InstallAPI/MachO.h @@ -23,6 +23,7 @@ #include "llvm/TextAPI/TextAPIWriter.h" #incl
[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)
@@ -973,5 +978,24 @@ bool DylibVerifier::verifyBinaryAttrs(const ArrayRef ProvidedTargets, return true; } +std::unique_ptr DylibVerifier::getExports() { + for (const auto &[Alias, Base] : Aliases) { cyndyishida wrote: `getExports()` only gets called once for the whole lifetime of InstallAPI as it releases ownership over the exports to forward along to write out the final TBD file. https://github.com/llvm/llvm-project/pull/88750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/88750 >From b2b54ad8ccf930a19327563a64c52c9f4013103f Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 11 Apr 2024 13:13:45 -0700 Subject: [PATCH] [InstallAPI] Add support for aliased exports Apple's ld supports alias_lists, described as ``` -alias_list filename The specified filename contains a list of aliases. The symbol name and its alias are on one line, separated by whitespace. Lines starting with # are ignored. ``` To handle this for installapi-produced TBD files, pass along the same input and account for it in verification. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 1 + clang/include/clang/Driver/Options.td | 1 + .../include/clang/InstallAPI/DylibVerifier.h | 15 +- clang/include/clang/InstallAPI/MachO.h| 1 + clang/lib/InstallAPI/DylibVerifier.cpp| 24 + clang/test/InstallAPI/alias_list.test | 461 ++ clang/tools/clang-installapi/Options.cpp | 24 +- clang/tools/clang-installapi/Options.h| 3 + llvm/include/llvm/TextAPI/Utils.h | 12 + llvm/lib/TextAPI/Utils.cpp| 34 ++ 10 files changed, 569 insertions(+), 7 deletions(-) create mode 100644 clang/test/InstallAPI/alias_list.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 396bff0146a373..91a40cd589b385 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; +def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e24626913add76..8c38acb72362c7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], "end-no-unused-arguments">, def interface_stub_version_EQ : JoinedOrSeparate<["-"], "interface-stub-version=">, Visibility<[ClangOption, CC1Option]>; def exported__symbols__list : Separate<["-"], "exported_symbols_list">; +def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>; def extract_api : Flag<["-"], "extract-api">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Extract API information">; diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h b/clang/include/clang/InstallAPI/DylibVerifier.h index 31de212fc423a5..f1a949d8f99394 100644 --- a/clang/include/clang/InstallAPI/DylibVerifier.h +++ b/clang/include/clang/InstallAPI/DylibVerifier.h @@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor { DylibVerifier() = default; DylibVerifier(llvm::MachO::Records &&Dylib, ReexportedInterfaces &&Reexports, -DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered, -bool Demangle, StringRef DSYMPath) - : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode), -Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath), +AliasMap Aliases, DiagnosticsEngine *Diag, +VerificationMode Mode, bool Zippered, bool Demangle, +StringRef DSYMPath) + : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), +Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered), +Demangle(Demangle), DSYMPath(DSYMPath), Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {} Result verify(GlobalRecord *R, const FrontendAttrs *FA); @@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor { void setTarget(const Target &T); /// Release ownership over exports. - std::unique_ptr getExports() { return std::move(Exports); } + std::unique_ptr getExports(); /// Get result of verification. Result getState() const { return Ctx.FrontendState; } @@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor { // Reexported interfaces apart of the library. ReexportedInterfaces Reexports; + // Symbol aliases. + AliasMap Aliases; + // Controls what class of violations to report. VerificationMode Mode = VerificationMode::Invalid; diff --git a/clang/include/clang/InstallAPI/MachO.h b/clang/include/clang/InstallAPI/MachO.h index 854399f54ba6c8..9da91a62e23311 100644 --- a/clang/include/clang/InstallAPI/MachO.h +++ b/clang/include/clang/InstallAPI/MachO.h @@ -23,6 +23,7 @@ #include "llvm/TextAPI/TextAPIWriter.h" #include
[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/88750 >From d7a4e72f80a9dcd18770dec1e06fd54518b60233 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 11 Apr 2024 13:13:45 -0700 Subject: [PATCH] [InstallAPI] Add support for aliased exports Apple's ld supports alias_lists, described as ``` -alias_list filename The specified filename contains a list of aliases. The symbol name and its alias are on one line, separated by whitespace. Lines starting with # are ignored. ``` To handle this for installapi-produced TBD files, pass along the same input and account for it in verification. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 1 + clang/include/clang/Driver/Options.td | 1 + .../include/clang/InstallAPI/DylibVerifier.h | 15 +- clang/include/clang/InstallAPI/MachO.h| 1 + clang/lib/InstallAPI/DylibVerifier.cpp| 24 + clang/test/InstallAPI/alias_list.test | 461 ++ clang/tools/clang-installapi/Options.cpp | 24 +- clang/tools/clang-installapi/Options.h| 3 + llvm/include/llvm/TextAPI/Utils.h | 12 + llvm/lib/TextAPI/Utils.cpp| 34 ++ 10 files changed, 569 insertions(+), 7 deletions(-) create mode 100644 clang/test/InstallAPI/alias_list.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 396bff0146a373..91a40cd589b385 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; +def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e24626913add76..8c38acb72362c7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], "end-no-unused-arguments">, def interface_stub_version_EQ : JoinedOrSeparate<["-"], "interface-stub-version=">, Visibility<[ClangOption, CC1Option]>; def exported__symbols__list : Separate<["-"], "exported_symbols_list">; +def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>; def extract_api : Flag<["-"], "extract-api">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Extract API information">; diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h b/clang/include/clang/InstallAPI/DylibVerifier.h index 31de212fc423a5..f1a949d8f99394 100644 --- a/clang/include/clang/InstallAPI/DylibVerifier.h +++ b/clang/include/clang/InstallAPI/DylibVerifier.h @@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor { DylibVerifier() = default; DylibVerifier(llvm::MachO::Records &&Dylib, ReexportedInterfaces &&Reexports, -DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered, -bool Demangle, StringRef DSYMPath) - : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode), -Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath), +AliasMap Aliases, DiagnosticsEngine *Diag, +VerificationMode Mode, bool Zippered, bool Demangle, +StringRef DSYMPath) + : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), +Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered), +Demangle(Demangle), DSYMPath(DSYMPath), Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {} Result verify(GlobalRecord *R, const FrontendAttrs *FA); @@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor { void setTarget(const Target &T); /// Release ownership over exports. - std::unique_ptr getExports() { return std::move(Exports); } + std::unique_ptr getExports(); /// Get result of verification. Result getState() const { return Ctx.FrontendState; } @@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor { // Reexported interfaces apart of the library. ReexportedInterfaces Reexports; + // Symbol aliases. + AliasMap Aliases; + // Controls what class of violations to report. VerificationMode Mode = VerificationMode::Invalid; diff --git a/clang/include/clang/InstallAPI/MachO.h b/clang/include/clang/InstallAPI/MachO.h index 854399f54ba6c8..9da91a62e23311 100644 --- a/clang/include/clang/InstallAPI/MachO.h +++ b/clang/include/clang/InstallAPI/MachO.h @@ -23,6 +23,7 @@ #include "llvm/TextAPI/TextAPIWriter.h" #include
[clang] [llvm] [InstallAPI] Add support for aliased exports (PR #88750)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/88750 Apple's ld supports alias_lists, described as ``` -alias_list filename The specified filename contains a list of aliases. The symbol name and its alias are on one line, separated by whitespace. Lines starting with # are ignored. ``` To handle this for installapi-produced TBD files, pass along the same input and account for it in verification. >From 3170f89b36ccf3ad6003f24decb282e23951d943 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 11 Apr 2024 13:13:45 -0700 Subject: [PATCH] [InstallAPI] Add support for aliased exports Apple's ld supports alias_lists, described as ``` -alias_list filename The specified filename contains a list of aliases. The symbol name and its alias are on one line, separated by whitespace. Lines starting with # are ignored. ``` To handle this for installapi-produced TBD files, pass along the same input and account for it in verification. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 1 + clang/include/clang/Driver/Options.td | 1 + .../include/clang/InstallAPI/DylibVerifier.h | 15 +- clang/include/clang/InstallAPI/MachO.h| 1 + clang/lib/InstallAPI/DylibVerifier.cpp| 24 + clang/test/InstallAPI/alias_list.test | 461 ++ clang/tools/clang-installapi/Options.cpp | 26 +- clang/tools/clang-installapi/Options.h| 3 + llvm/include/llvm/TextAPI/Utils.h | 11 + llvm/lib/TextAPI/Utils.cpp| 34 ++ 10 files changed, 570 insertions(+), 7 deletions(-) create mode 100644 clang/test/InstallAPI/alias_list.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 396bff0146a373..91a40cd589b385 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,6 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; +def err_cannot_read_alias_list : Error<"could not read alias list '%0': %1">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e24626913add76..8c38acb72362c7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1505,6 +1505,7 @@ def end_no_unused_arguments : Flag<["--"], "end-no-unused-arguments">, def interface_stub_version_EQ : JoinedOrSeparate<["-"], "interface-stub-version=">, Visibility<[ClangOption, CC1Option]>; def exported__symbols__list : Separate<["-"], "exported_symbols_list">; +def alias_list : Separate<["-"], "alias_list">, Flags<[LinkerInput]>; def extract_api : Flag<["-"], "extract-api">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Extract API information">; diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h b/clang/include/clang/InstallAPI/DylibVerifier.h index 31de212fc423a5..f1a949d8f99394 100644 --- a/clang/include/clang/InstallAPI/DylibVerifier.h +++ b/clang/include/clang/InstallAPI/DylibVerifier.h @@ -78,10 +78,12 @@ class DylibVerifier : llvm::MachO::RecordVisitor { DylibVerifier() = default; DylibVerifier(llvm::MachO::Records &&Dylib, ReexportedInterfaces &&Reexports, -DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered, -bool Demangle, StringRef DSYMPath) - : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode), -Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath), +AliasMap Aliases, DiagnosticsEngine *Diag, +VerificationMode Mode, bool Zippered, bool Demangle, +StringRef DSYMPath) + : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), +Aliases(std::move(Aliases)), Mode(Mode), Zippered(Zippered), +Demangle(Demangle), DSYMPath(DSYMPath), Exports(std::make_unique()), Ctx(VerifierContext{Diag}) {} Result verify(GlobalRecord *R, const FrontendAttrs *FA); @@ -104,7 +106,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor { void setTarget(const Target &T); /// Release ownership over exports. - std::unique_ptr getExports() { return std::move(Exports); } + std::unique_ptr getExports(); /// Get result of verification. Result getState() const { return Ctx.FrontendState; } @@ -189,6 +191,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor { // Reexported interfaces apart of the library. ReexportedInterfaces Reexports; + // Symbol aliases. + AliasMap Aliases; + // Controls what clas
[clang] 79dca25 - [InstallAPI] Replace std::string -> StringRef
Author: Cyndy Ishida Date: 2024-04-12T22:05:12-07:00 New Revision: 79dca25f4a0fefd47e9e37d9ce47d84dc0b3bedb URL: https://github.com/llvm/llvm-project/commit/79dca25f4a0fefd47e9e37d9ce47d84dc0b3bedb DIFF: https://github.com/llvm/llvm-project/commit/79dca25f4a0fefd47e9e37d9ce47d84dc0b3bedb.diff LOG: [InstallAPI] Replace std::string -> StringRef Added: Modified: clang/tools/clang-installapi/Options.cpp Removed: diff --git a/clang/tools/clang-installapi/Options.cpp b/clang/tools/clang-installapi/Options.cpp index 120ff3da899868..3dc61476ce09d9 100644 --- a/clang/tools/clang-installapi/Options.cpp +++ b/clang/tools/clang-installapi/Options.cpp @@ -372,7 +372,7 @@ bool Options::addFilePaths(InputArgList &Args, PathSeq &Headers, } // Sort headers to ensure deterministic behavior. sort(*InputHeadersOrErr); - for (std::string &H : *InputHeadersOrErr) + for (StringRef H : *InputHeadersOrErr) Headers.emplace_back(std::move(H)); } else Headers.emplace_back(Path); @@ -690,7 +690,7 @@ InstallAPIContext Options::createContext() { FrameworkName = getFrameworkNameFromInstallName(LinkerOpts.InstallName); // Process inputs. - for (const std::string &ListPath : DriverOpts.FileLists) { + for (const StringRef ListPath : DriverOpts.FileLists) { auto Buffer = FM->getBufferForFile(ListPath); if (auto Err = Buffer.getError()) { Diags->Report(diag::err_cannot_open_file) << ListPath << Err.message(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Handle zippered frameworks (PR #88205)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/88205 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][docs] Modernize attribute docs for darwin specifics (PR #88448)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/88448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][docs] Modernize attribute docs for darwin specifics (PR #88448)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/88448 >From 0039cbc0d53a4ff8530b78657f8365229162516b Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 11 Apr 2024 14:10:15 -0700 Subject: [PATCH 1/2] [clang][docs] Modernize attribute docs for darwin specifics * Generally recommend target triples. But replace `m*version-min` with `mtargetos`. * Also include test coverage for -mtargetos=visionos. --- clang/include/clang/Basic/AttrDocs.td | 30 +-- clang/test/Driver/mtargetos-darwin.c | 2 ++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 0ca4ea377fc36a..a37e9f97a19ccd 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -1604,23 +1604,31 @@ specifies availability for the current target platform, the availability attributes are ignored. Supported platforms are: ``ios`` - Apple's iOS operating system. The minimum deployment target is specified by - the ``-mios-version-min=*version*`` or ``-miphoneos-version-min=*version*`` - command-line arguments. + Apple's iOS operating system. The minimum deployment target is specified + as part of the triple. Alternatively, it can be specified by the + ``-mtargetos=ios*version*`` command-line argument. ``macos`` - Apple's macOS operating system. The minimum deployment target is - specified by the ``-mmacosx-version-min=*version*`` command-line argument. - ``macosx`` is supported for backward-compatibility reasons, but it is - deprecated. + Apple's macOS operating system. The minimum deployment target is specified + as part of the triple. Alternatively, it can be specified by the + ``-mtargetos=macos*version*`` or ``-mtargetos=macosx*version*`` + command-line arguments. ``macosx`` is supported for backward-compatibility + reasons, but it is deprecated. ``tvos`` - Apple's tvOS operating system. The minimum deployment target is specified by - the ``-mtvos-version-min=*version*`` command-line argument. + Apple's tvOS operating system. The minimum deployment target is specified + as part of the triple. Alternatively, it can be specified by the + the ``-mtargetos=tvos*version*`` command-line argument. ``watchos`` - Apple's watchOS operating system. The minimum deployment target is specified by - the ``-mwatchos-version-min=*version*`` command-line argument. + Apple's watchOS operating system. The minimum deployment target is specified + as part of the triple. Alternatively, it can be specified by the + the ``-mtargetos=watchos*version*`` command-line argument. + +``visionos`` + Apple's visionOS operating system. The minimum deployment target is specified + as part of the triple. Alternatively, it can be specified by the + the ``-mtargetos=visionos*version*`` command-line argument. ``driverkit`` Apple's DriverKit userspace kernel extensions. The minimum deployment target diff --git a/clang/test/Driver/mtargetos-darwin.c b/clang/test/Driver/mtargetos-darwin.c index e706be37a371f4..7e86ab15279b9a 100644 --- a/clang/test/Driver/mtargetos-darwin.c +++ b/clang/test/Driver/mtargetos-darwin.c @@ -4,6 +4,7 @@ // RUN: %clang -mtargetos=ios14-macabi -arch arm64 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=MACCATALYST %s // RUN: %clang -mtargetos=tvos14 -arch arm64 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=TVOS %s // RUN: %clang -mtargetos=watchos7.1 -arch arm64 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=WATCHOS %s +// RUN: %clang -mtargetos=visionos1 -arch arm64 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=VISIONOS %s // RUN: not %clang -target arm64-apple-ios14 -mtargetos=ios14 -arch arm64 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=NOMIX1 %s // RUN: not %clang -mtargetos=ios14 -arch arm64 -miphoneos-version-min=14 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=NOMIX2 %s @@ -19,6 +20,7 @@ // MACCATALYST: "-cc1" "-triple" "arm64-apple-ios14.0.0-macabi" // TVOS: "-cc1" "-triple" "arm64-apple-tvos14.0.0" // WATCHOS: "-cc1" "-triple" "arm64-apple-watchos7.1.0" +// VISIONOS: "-cc1" "-triple" "arm64-apple-xros1.0.0" // NOMIX1: error: cannot specify '-mtargetos=ios14' along with '-target arm64-apple-ios14' // NOMIX2: error: cannot specify '-miphoneos-version-min=14' along with '-mtargetos=ios14' >From 5577083efc7e642f23c961b80cb2aa33acb6f14d Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 11 Apr 2024 15:49:13 -0700 Subject: [PATCH 2/2] Address review comments --- clang/include/clang/Basic/AttrDocs.td | 31 --- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index a37e9f97a19ccd..8687c4f57d3f83 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -1605,34 +1605,39 @@ attributes are ignored.
[clang] [clang][docs] Modernize attribute docs for darwin specifics (PR #88448)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/88448 * Generally recommend target triples. But replace `m*version-min` with `mtargetos`. * Also include test coverage for -mtargetos=visionos >From 0039cbc0d53a4ff8530b78657f8365229162516b Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 11 Apr 2024 14:10:15 -0700 Subject: [PATCH] [clang][docs] Modernize attribute docs for darwin specifics * Generally recommend target triples. But replace `m*version-min` with `mtargetos`. * Also include test coverage for -mtargetos=visionos. --- clang/include/clang/Basic/AttrDocs.td | 30 +-- clang/test/Driver/mtargetos-darwin.c | 2 ++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 0ca4ea377fc36a..a37e9f97a19ccd 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -1604,23 +1604,31 @@ specifies availability for the current target platform, the availability attributes are ignored. Supported platforms are: ``ios`` - Apple's iOS operating system. The minimum deployment target is specified by - the ``-mios-version-min=*version*`` or ``-miphoneos-version-min=*version*`` - command-line arguments. + Apple's iOS operating system. The minimum deployment target is specified + as part of the triple. Alternatively, it can be specified by the + ``-mtargetos=ios*version*`` command-line argument. ``macos`` - Apple's macOS operating system. The minimum deployment target is - specified by the ``-mmacosx-version-min=*version*`` command-line argument. - ``macosx`` is supported for backward-compatibility reasons, but it is - deprecated. + Apple's macOS operating system. The minimum deployment target is specified + as part of the triple. Alternatively, it can be specified by the + ``-mtargetos=macos*version*`` or ``-mtargetos=macosx*version*`` + command-line arguments. ``macosx`` is supported for backward-compatibility + reasons, but it is deprecated. ``tvos`` - Apple's tvOS operating system. The minimum deployment target is specified by - the ``-mtvos-version-min=*version*`` command-line argument. + Apple's tvOS operating system. The minimum deployment target is specified + as part of the triple. Alternatively, it can be specified by the + the ``-mtargetos=tvos*version*`` command-line argument. ``watchos`` - Apple's watchOS operating system. The minimum deployment target is specified by - the ``-mwatchos-version-min=*version*`` command-line argument. + Apple's watchOS operating system. The minimum deployment target is specified + as part of the triple. Alternatively, it can be specified by the + the ``-mtargetos=watchos*version*`` command-line argument. + +``visionos`` + Apple's visionOS operating system. The minimum deployment target is specified + as part of the triple. Alternatively, it can be specified by the + the ``-mtargetos=visionos*version*`` command-line argument. ``driverkit`` Apple's DriverKit userspace kernel extensions. The minimum deployment target diff --git a/clang/test/Driver/mtargetos-darwin.c b/clang/test/Driver/mtargetos-darwin.c index e706be37a371f4..7e86ab15279b9a 100644 --- a/clang/test/Driver/mtargetos-darwin.c +++ b/clang/test/Driver/mtargetos-darwin.c @@ -4,6 +4,7 @@ // RUN: %clang -mtargetos=ios14-macabi -arch arm64 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=MACCATALYST %s // RUN: %clang -mtargetos=tvos14 -arch arm64 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=TVOS %s // RUN: %clang -mtargetos=watchos7.1 -arch arm64 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=WATCHOS %s +// RUN: %clang -mtargetos=visionos1 -arch arm64 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=VISIONOS %s // RUN: not %clang -target arm64-apple-ios14 -mtargetos=ios14 -arch arm64 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=NOMIX1 %s // RUN: not %clang -mtargetos=ios14 -arch arm64 -miphoneos-version-min=14 -c %s -o %t.o -### 2>&1 | FileCheck --check-prefix=NOMIX2 %s @@ -19,6 +20,7 @@ // MACCATALYST: "-cc1" "-triple" "arm64-apple-ios14.0.0-macabi" // TVOS: "-cc1" "-triple" "arm64-apple-tvos14.0.0" // WATCHOS: "-cc1" "-triple" "arm64-apple-watchos7.1.0" +// VISIONOS: "-cc1" "-triple" "arm64-apple-xros1.0.0" // NOMIX1: error: cannot specify '-mtargetos=ios14' along with '-target arm64-apple-ios14' // NOMIX2: error: cannot specify '-miphoneos-version-min=14' along with '-mtargetos=ios14' ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Handle zippered frameworks (PR #88205)
@@ -588,13 +622,58 @@ void DylibVerifier::visitSymbolInDylib(const Record &R, SymbolContext &SymCtx) { } } + const bool IsLinkerSymbol = SymbolName.starts_with("$ld$"); + + if (R.isVerified()) { +// Check for unavailable symbols. +// This should only occur in the zippered case where we ignored +// availability until all headers have been parsed. +auto It = DeferredZipperedSymbols.find(SymCtx.SymbolName); +if (It == DeferredZipperedSymbols.end()) { + updateState(Result::Valid); + return; +} + +ZipperedDeclSources Locs; +for (const ZipperedDeclSource &ZSource : It->second) { + if (ZSource.FA->Avail.isObsoleted()) { +updateState(Result::Ignore); +return; + } + if (ZSource.T.Arch != Ctx.Target.Arch) +continue; + Locs.emplace_back(ZSource); +} +assert(Locs.size() == 2 && "Expected two decls for zippered symbol"); cyndyishida wrote: Ah, so that errors out differently with ``` error: no declaration found for exported symbol '_unavailableSymbol' in a dynamic library ``` in clang-installapi & tapi. That should be improved to also show the source location, can do in a separate patch. https://github.com/llvm/llvm-project/pull/88205 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Handle zippered frameworks (PR #88205)
@@ -588,13 +622,58 @@ void DylibVerifier::visitSymbolInDylib(const Record &R, SymbolContext &SymCtx) { } } + const bool IsLinkerSymbol = SymbolName.starts_with("$ld$"); + + if (R.isVerified()) { +// Check for unavailable symbols. +// This should only occur in the zippered case where we ignored +// availability until all headers have been parsed. +auto It = DeferredZipperedSymbols.find(SymCtx.SymbolName); +if (It == DeferredZipperedSymbols.end()) { + updateState(Result::Valid); + return; +} + +ZipperedDeclSources Locs; +for (const ZipperedDeclSource &ZSource : It->second) { + if (ZSource.FA->Avail.isObsoleted()) { +updateState(Result::Ignore); +return; + } + if (ZSource.T.Arch != Ctx.Target.Arch) +continue; + Locs.emplace_back(ZSource); +} +assert(Locs.size() == 2 && "Expected two decls for zippered symbol"); cyndyishida wrote: My thinking at this point is that the only kind of error is when every version of the decl look unavailable (no decl at all/only one available decl are handled separately). Because this check is handled after all CC1 invocations have finished, any macro-guarded declarations should have been resolved and show 2. e.g. ``` #if defined(TARGET_OS_OSX) && TARGET_OS_OSX extern int unavailableSymbol API_UNAVAILABLE(macos) ; #else extern int unavailableSymbol API_UNAVAILABLE(macCatalyst); #endif ``` results in ``` warning: violations found for arm64-apple-macos13 /Users/cishida/Builds/llvm-build/tools/clang/test/InstallAPI/Output/diagnostics-zippered.test.tmp/System/Library/Frameworks/Mismatch.framework/Headers/Mismatch.h:16:5: error: declaration 'unavailableSymbol' is marked unavailable, but symbol is exported in dynamic library 16 | int unavailableSymbol API_UNAVAILABLE(macos) ; | ^ warning: violations found for arm64-apple-ios16.0-macabi /Users/cishida/Builds/llvm-build/tools/clang/test/InstallAPI/Output/diagnostics-zippered.test.tmp/System/Library/Frameworks/Mismatch.framework/Headers/Mismatch.h:18:5: error: declaration 'unavailableSymbol' is marked unavailable, but symbol is exported in dynamic library 18 | int unavailableSymbol API_UNAVAILABLE(macCatalyst); | ^ ``` Were you thinking of a different example? https://github.com/llvm/llvm-project/pull/88205 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Handle zippered frameworks (PR #88205)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/88205 A zippered framework is a single framework that can be loaded in both macOS and macatalyst processes. Broadly to InstallAPI, it means the same interface can represent two separate platforms. A dylib's symbol table does not distinguish between macOS/macCatalyst. `InstallAPI` provides the ability for the tbd file to distinct symbols between them. The verifier handles this special logic by tracking all unavailable and obsoleted APIs in this context and checking against those when determining dylib symbols with no matching declaration. * If there exists an available decl for either platform, do not warn. * If there is no available decl, emit a diagnostic and print the source location for both decls. >From cf8e63e06d8ed8ee626aab4fdf5ec499ed476b51 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Tue, 9 Apr 2024 14:14:10 -0700 Subject: [PATCH] [InstallAPI] Handle zippered frameworks A zippered framework is a single framework that can be loaded in both macOS and macatalyst processes. Broadly to InstallAPI, it means the same interface can represent two seperate platforms. A dylib's symbol table does not distinct between macOS/macCatalyst. `InstallAPI` provides ability for the tbd file to distinct symbols between them. The verifier handles this special logic by tracking all unavailable and obsoleted APIs in this context and check against those when determining dylib symbols with no matching declaration. * If there exists an available decl for either platform, do not warn. * If there is no available decl, emit an diagnostic and print the source location for both decls. --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 4 + .../include/clang/InstallAPI/DylibVerifier.h | 32 +- clang/lib/InstallAPI/DylibVerifier.cpp| 98 ++- .../Inputs/MacOSX13.0.sdk/SDKSettings.json| 19 + .../test/InstallAPI/diagnostics-zippered.test | 765 ++ .../InstallAPI/driver-invalid-options.test| 7 + clang/tools/clang-installapi/Options.cpp | 52 +- clang/tools/clang-installapi/Options.h| 3 + 8 files changed, 964 insertions(+), 16 deletions(-) create mode 100644 clang/test/InstallAPI/Inputs/MacOSX13.0.sdk/SDKSettings.json create mode 100644 clang/test/InstallAPI/diagnostics-zippered.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 0a477da7186b09..396bff0146a373 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -20,6 +20,10 @@ def warn_no_such_excluded_header_file : Warning<"no such excluded %select{public def warn_glob_did_not_match: Warning<"glob '%0' did not match any header file">, InGroup; def err_no_such_umbrella_header_file : Error<"%select{public|private|project}1 umbrella header file not found in input: '%0'">; def err_cannot_find_reexport : Error<"cannot find re-exported %select{framework|library}0: '%1'">; +def err_no_matching_target : Error<"no matching target found for target variant '%0'">; +def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; +def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; +def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; } // end of command line category. let CategoryName = "Verification" in { diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h b/clang/include/clang/InstallAPI/DylibVerifier.h index a3df25f10de4b1..31de212fc423a5 100644 --- a/clang/include/clang/InstallAPI/DylibVerifier.h +++ b/clang/include/clang/InstallAPI/DylibVerifier.h @@ -28,6 +28,16 @@ enum class VerificationMode { using LibAttrs = llvm::StringMap; using ReexportedInterfaces = llvm::SmallVector; +// Pointers to information about a zippered declaration used for +// querying and reporting violations against different +// declarations that all map to the same symbol. +struct ZipperedDeclSource { + const FrontendAttrs *FA; + clang::SourceManager *SrcMgr; + Target T; +}; +using ZipperedDeclSources = std::vector; + /// Service responsible to tracking state of verification across the /// lifetime of InstallAPI. /// As declarations are collected during AST traversal, they are @@ -68,10 +78,10 @@ class DylibVerifier : llvm::MachO::RecordVisitor { DylibVerifier() = default; DylibVerifier(llvm::MachO::Records &&Dylib, ReexportedInterfaces &&Reexports, -DiagnosticsEngine *Diag, VerificationMode Mode, bool Demangle, -StringRef DSYMPath) +DiagnosticsEngine *Diag, VerificationMode Mode, bool Zippered, +bool Demangle, StringRef DSYMPath) : Dylib(std::move(Dylib)), Reexports(std::move(Reexports)), Mode(Mode), -Demangle(Demangle), DSYMPath(DSYMPath), +Zippered(Zippered), Demangle(Demangle), DSYMPath(DSYMPath), Exp
[clang] [InstallAPI] Tie lifetime of FE objects to DylibVerifier (PR #88189)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/88189 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Tie lifetime of FE objects to DylibVerifier (PR #88189)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/88189 >From a7894f987b80f1916195c3ab15da5c33ab69ab00 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Tue, 9 Apr 2024 13:04:18 -0700 Subject: [PATCH] [InstallAPI] Tie lifetime of FE objects to DylibVerifier A few verification checks need to happen until all AST's have been traversed, specifically for zippered framework checking. To keep source location until that time valid, hold onto to references of FrontendRecords + SourceManager. --- .../include/clang/InstallAPI/DylibVerifier.h | 10 ++-- clang/include/clang/InstallAPI/Frontend.h | 2 +- .../clang/InstallAPI/FrontendRecords.h| 1 + clang/lib/InstallAPI/DylibVerifier.cpp| 47 +-- clang/lib/InstallAPI/Frontend.cpp | 15 +++--- .../clang-installapi/ClangInstallAPI.cpp | 2 + 6 files changed, 40 insertions(+), 37 deletions(-) diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h b/clang/include/clang/InstallAPI/DylibVerifier.h index 07dbd3bf5f2b10..a3df25f10de4b1 100644 --- a/clang/include/clang/InstallAPI/DylibVerifier.h +++ b/clang/include/clang/InstallAPI/DylibVerifier.h @@ -10,6 +10,7 @@ #define LLVM_CLANG_INSTALLAPI_DYLIBVERIFIER_H #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/SourceManager.h" #include "clang/InstallAPI/MachO.h" namespace clang { @@ -99,11 +100,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor { Result getState() const { return Ctx.FrontendState; } /// Set different source managers to the same diagnostics engine. - void setSourceManager(SourceManager &SourceMgr) const { -if (!Ctx.Diag) - return; -Ctx.Diag->setSourceManager(&SourceMgr); - } + void setSourceManager(IntrusiveRefCntPtr SourceMgr); private: /// Determine whether to compare declaration to symbol in binary. @@ -190,6 +187,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor { // Track DWARF provided source location for dylibs. DWARFContext *DWARFCtx = nullptr; + + // Source manager for each unique compiler instance. + llvm::SmallVector, 12> SourceManagers; }; } // namespace installapi diff --git a/clang/include/clang/InstallAPI/Frontend.h b/clang/include/clang/InstallAPI/Frontend.h index 5cccd891c58093..bc4e77de2b7256 100644 --- a/clang/include/clang/InstallAPI/Frontend.h +++ b/clang/include/clang/InstallAPI/Frontend.h @@ -36,7 +36,7 @@ class InstallAPIAction : public ASTFrontendAction { std::unique_ptr CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override { Ctx.Diags->getClient()->BeginSourceFile(CI.getLangOpts()); -Ctx.Verifier->setSourceManager(CI.getSourceManager()); +Ctx.Verifier->setSourceManager(CI.getSourceManagerPtr()); return std::make_unique( CI.getASTContext(), Ctx, CI.getSourceManager(), CI.getPreprocessor()); } diff --git a/clang/include/clang/InstallAPI/FrontendRecords.h b/clang/include/clang/InstallAPI/FrontendRecords.h index 59271e81e230c2..ef82398addd7ac 100644 --- a/clang/include/clang/InstallAPI/FrontendRecords.h +++ b/clang/include/clang/InstallAPI/FrontendRecords.h @@ -21,6 +21,7 @@ namespace installapi { struct FrontendAttrs { const AvailabilityInfo Avail; const Decl *D; + const SourceLocation Loc; const HeaderType Access; }; diff --git a/clang/lib/InstallAPI/DylibVerifier.cpp b/clang/lib/InstallAPI/DylibVerifier.cpp index 2387ee0e78ad56..4fa2d4e9292c72 100644 --- a/clang/lib/InstallAPI/DylibVerifier.cpp +++ b/clang/lib/InstallAPI/DylibVerifier.cpp @@ -214,16 +214,16 @@ bool DylibVerifier::compareObjCInterfaceSymbols(const Record *R, StringRef SymName, bool PrintAsWarning = false) { if (SymLinkage == RecordLinkage::Unknown) Ctx.emitDiag([&]() { -Ctx.Diag->Report(SymCtx.FA->D->getLocation(), - PrintAsWarning ? diag::warn_library_missing_symbol -: diag::err_library_missing_symbol) +Ctx.Diag->Report(SymCtx.FA->Loc, PrintAsWarning + ? diag::warn_library_missing_symbol + : diag::err_library_missing_symbol) << SymName; }); else Ctx.emitDiag([&]() { -Ctx.Diag->Report(SymCtx.FA->D->getLocation(), - PrintAsWarning ? diag::warn_library_hidden_symbol -: diag::err_library_hidden_symbol) +Ctx.Diag->Report(SymCtx.FA->Loc, PrintAsWarning + ? diag::warn_library_hidden_symbol + : diag::err_library_hidden_symbol) << SymName; }); }; @@ -270,16 +270,14 @@ DylibVerifier::Result DylibVerifier::compareVisibility(const Record *R, if (R->isExported()) { if (!DR) { Ctx.emitDiag([&]() { -Ctx.Diag->
[clang] [InstallAPI] Tie lifetime of FE objects to DylibVerifier (PR #88189)
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/88189 A few verification checks need to happen until all AST's have been traversed, specifically for zippered framework checking. To keep source location until that time valid, hold onto to references of FrontendRecords + SourceManager. >From d74c47dcadaa83422637de6ab6b1d0852b07817c Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Tue, 9 Apr 2024 13:04:18 -0700 Subject: [PATCH] [InstallAPI] Tie lifetime of FE objects to DylibVerifier A few verification checks need to happen until all AST's have been traversed, specifically for zippered framework checking. To keep source location until that time valid, hold onto to references of FrontendRecords + SourceManager. --- .../include/clang/InstallAPI/DylibVerifier.h | 10 ++-- clang/include/clang/InstallAPI/Frontend.h | 2 +- .../clang/InstallAPI/FrontendRecords.h| 1 + clang/lib/InstallAPI/DylibVerifier.cpp| 47 +-- clang/lib/InstallAPI/Frontend.cpp | 15 +++--- .../clang-installapi/ClangInstallAPI.cpp | 2 + 6 files changed, 40 insertions(+), 37 deletions(-) diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h b/clang/include/clang/InstallAPI/DylibVerifier.h index 07dbd3bf5f2b10..a3df25f10de4b1 100644 --- a/clang/include/clang/InstallAPI/DylibVerifier.h +++ b/clang/include/clang/InstallAPI/DylibVerifier.h @@ -10,6 +10,7 @@ #define LLVM_CLANG_INSTALLAPI_DYLIBVERIFIER_H #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/SourceManager.h" #include "clang/InstallAPI/MachO.h" namespace clang { @@ -99,11 +100,7 @@ class DylibVerifier : llvm::MachO::RecordVisitor { Result getState() const { return Ctx.FrontendState; } /// Set different source managers to the same diagnostics engine. - void setSourceManager(SourceManager &SourceMgr) const { -if (!Ctx.Diag) - return; -Ctx.Diag->setSourceManager(&SourceMgr); - } + void setSourceManager(IntrusiveRefCntPtr SourceMgr); private: /// Determine whether to compare declaration to symbol in binary. @@ -190,6 +187,9 @@ class DylibVerifier : llvm::MachO::RecordVisitor { // Track DWARF provided source location for dylibs. DWARFContext *DWARFCtx = nullptr; + + // Source manager for each unique compiler instance. + llvm::SmallVector, 12> SourceManagers; }; } // namespace installapi diff --git a/clang/include/clang/InstallAPI/Frontend.h b/clang/include/clang/InstallAPI/Frontend.h index 5cccd891c58093..bc4e77de2b7256 100644 --- a/clang/include/clang/InstallAPI/Frontend.h +++ b/clang/include/clang/InstallAPI/Frontend.h @@ -36,7 +36,7 @@ class InstallAPIAction : public ASTFrontendAction { std::unique_ptr CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override { Ctx.Diags->getClient()->BeginSourceFile(CI.getLangOpts()); -Ctx.Verifier->setSourceManager(CI.getSourceManager()); +Ctx.Verifier->setSourceManager(CI.getSourceManagerPtr()); return std::make_unique( CI.getASTContext(), Ctx, CI.getSourceManager(), CI.getPreprocessor()); } diff --git a/clang/include/clang/InstallAPI/FrontendRecords.h b/clang/include/clang/InstallAPI/FrontendRecords.h index 59271e81e230c2..ef82398addd7ac 100644 --- a/clang/include/clang/InstallAPI/FrontendRecords.h +++ b/clang/include/clang/InstallAPI/FrontendRecords.h @@ -21,6 +21,7 @@ namespace installapi { struct FrontendAttrs { const AvailabilityInfo Avail; const Decl *D; + const SourceLocation Loc; const HeaderType Access; }; diff --git a/clang/lib/InstallAPI/DylibVerifier.cpp b/clang/lib/InstallAPI/DylibVerifier.cpp index 2387ee0e78ad56..4fa2d4e9292c72 100644 --- a/clang/lib/InstallAPI/DylibVerifier.cpp +++ b/clang/lib/InstallAPI/DylibVerifier.cpp @@ -214,16 +214,16 @@ bool DylibVerifier::compareObjCInterfaceSymbols(const Record *R, StringRef SymName, bool PrintAsWarning = false) { if (SymLinkage == RecordLinkage::Unknown) Ctx.emitDiag([&]() { -Ctx.Diag->Report(SymCtx.FA->D->getLocation(), - PrintAsWarning ? diag::warn_library_missing_symbol -: diag::err_library_missing_symbol) +Ctx.Diag->Report(SymCtx.FA->Loc, PrintAsWarning + ? diag::warn_library_missing_symbol + : diag::err_library_missing_symbol) << SymName; }); else Ctx.emitDiag([&]() { -Ctx.Diag->Report(SymCtx.FA->D->getLocation(), - PrintAsWarning ? diag::warn_library_hidden_symbol -: diag::err_library_hidden_symbol) +Ctx.Diag->Report(SymCtx.FA->Loc, PrintAsWarning + ? diag::warn_library_hidden_symbol + : diag::err_library_hidden_
[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
cyndyishida wrote: > FYI, it looks like this change broke `compiler-rt` build, e.g. in > https://lab.llvm.org/buildbot/#/builders/270/builds/12485 Should be resolved by: https://github.com/llvm/llvm-project/commit/fe45029dbdee6b3df2dbeaed17c9dd598ec511f2 I suspect compiler-rt may be relying on defaults set by Apple* cmake caches on unrelated environments. https://github.com/llvm/llvm-project/pull/87684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
@@ -1029,6 +1038,16 @@ macro(add_llvm_executable name) add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} ) endif(LLVM_EXPORTED_SYMBOL_FILE) + if (NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES) +if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS) + set_property(TARGET ${name} APPEND_STRING PROPERTY +LINK_FLAGS " -Wl,-no_exported_symbols") +else() + message(FATAL_ERROR +"LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES cannot be disabled when linker does not support \"-no_exported_symbols\"") cyndyishida wrote: Yea, theres more platform-friendly and older ways to achieve the same thing. I opted not to because AFAIK, our toolchain only builds with linkers that support the straightforward flag, and wasn't sure how useful this would be for other platforms. https://github.com/llvm/llvm-project/pull/87684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/87684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/87674 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)
cyndyishida wrote: Thanks for reviewing @zixu-w ! https://github.com/llvm/llvm-project/pull/87674 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/87684 >From 3ac6872328334384fa20998541fac841add767d9 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 4 Apr 2024 12:08:28 -0700 Subject: [PATCH 1/4] [cmake] Build executables with -no_exported_symbols when building Apple toolchain Building the Apple way turns off plugin support, meaning we don't need to be exporting unloadable symbols from all executables. While deadstripping effects aren't expected to change, enabling this across all tools prevents the creation of export tries. This saves us ~3.5 MB's in just the universal build of `clang`. --- clang/cmake/caches/Apple-stage2.cmake | 1 + lldb/cmake/caches/Apple-lldb-base.cmake | 1 + llvm/CMakeLists.txt | 3 +++ llvm/cmake/modules/AddLLVM.cmake| 30 ++--- llvm/docs/CMake.rst | 4 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/clang/cmake/caches/Apple-stage2.cmake b/clang/cmake/caches/Apple-stage2.cmake index 72cdedd611bc96..faf61fd1fe9ecb 100644 --- a/clang/cmake/caches/Apple-stage2.cmake +++ b/clang/cmake/caches/Apple-stage2.cmake @@ -15,6 +15,7 @@ set(LLVM_ENABLE_ZLIB ON CACHE BOOL "") set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") set(LLVM_ENABLE_MODULES ON CACHE BOOL "") set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "") +set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") set(CLANG_SPAWN_CC1 ON CACHE BOOL "") set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "") diff --git a/lldb/cmake/caches/Apple-lldb-base.cmake b/lldb/cmake/caches/Apple-lldb-base.cmake index 4d4f02bfae95bd..021538896b2346 100644 --- a/lldb/cmake/caches/Apple-lldb-base.cmake +++ b/lldb/cmake/caches/Apple-lldb-base.cmake @@ -3,6 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "") set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "") set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") +set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "") set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "") diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 6f5647d70d8bc1..7e393acacb80d8 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE option(LLVM_EXTERNALIZE_DEBUGINFO "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF) +option(LLVM_ENABLE_NO_EXPORTED_SYMBOLS + "When building executables, disable any symbol exports (Darwin Only)" OFF) + set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING "Sign executables and dylibs with the given identity or skip if empty (Darwin Only)") diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 745935f1405170..141a97c852e24f 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32) endif() endif() - # Apple's linker complains about duplicate libraries, which CMake likes to do - # to support ELF platforms. To silence that warning, we can use - # -no_warn_duplicate_libraries, but only in versions of the linker that - # support that flag. - if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") include(CheckLinkerFlag) -check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES) - else() -set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "") +# Linkers that support Darwin allow a setting to internalize all symbol exports, +# aiding in reducing binary size and often is applicable for executables. +check_linker_flag(C "-Wl,-no_exported_symbols" LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS) + +if (NOT LLVM_USE_LINKER) + # Apple's linker complains about duplicate libraries, which CMake likes to do + # to support ELF platforms. To silence that warning, we can use + # -no_warn_duplicate_libraries, but only in versions of the linker that + # support that flag. + check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES) +else() + set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "") +endif() + + else() +set(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS OFF CACHE INTERNAL "") endif() endif() @@ -1029,6 +1038,11 @@ macro(add_llvm_executable name) add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} ) endif(LLVM_EXPORTED_SYMBOL_FILE) + if (LLVM_ENABLE_NO_EXPORTED_SYMBOLS AND LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS) +set_property(TARGET ${name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,-no_exported_symbols") + endif() + if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB) set(USE_SHARED USE_SHARED) end
[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/87674 >From 7ef1a803c10cfef8f577a4e439221d778215464a Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Wed, 27 Mar 2024 12:17:01 -0400 Subject: [PATCH 1/3] [InstallAPI] Capture and compare load commands that may differ per arch slice * Capture reexported libraries, allowable clients, rpaths, shared cache eligiblity. * Add support for select Xarch options. * Add diagnostics related to capturing these options. * Add support for verifying these attributes against what is encoded in the dylib. --- .../clang/Basic/DiagnosticDriverKinds.td | 1 + .../clang/Basic/DiagnosticInstallAPIKinds.td | 21 + clang/include/clang/InstallAPI/Context.h | 17 + .../include/clang/InstallAPI/DylibVerifier.h | 29 +- clang/include/clang/InstallAPI/MachO.h| 2 + clang/lib/InstallAPI/CMakeLists.txt | 1 + .../InstallAPI/DiagnosticBuilderWrappers.cpp | 111 +++ .../InstallAPI/DiagnosticBuilderWrappers.h| 49 ++ clang/lib/InstallAPI/DylibVerifier.cpp| 196 ++ clang/lib/InstallAPI/Frontend.cpp | 54 ++ clang/test/InstallAPI/binary-attributes.test | 70 ++ .../InstallAPI/driver-invalid-options.test| 6 + .../InstallAPI/reexported-frameworks.test | 638 + clang/test/InstallAPI/rpath.test | 663 ++ clang/tools/clang-installapi/CMakeLists.txt | 1 + .../clang-installapi/ClangInstallAPI.cpp | 27 +- .../tools/clang-installapi/InstallAPIOpts.td | 40 +- clang/tools/clang-installapi/Options.cpp | 277 +++- clang/tools/clang-installapi/Options.h| 43 +- 19 files changed, 2230 insertions(+), 16 deletions(-) create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.h create mode 100644 clang/test/InstallAPI/binary-attributes.test create mode 100644 clang/test/InstallAPI/reexported-frameworks.test create mode 100644 clang/test/InstallAPI/rpath.test diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 3d86f7510bde20..fdce4f3f9d9a60 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -663,6 +663,7 @@ def warn_drv_darwin_sdk_invalid_settings : Warning< "SDK settings were ignored as 'SDKSettings.json' could not be parsed">, InGroup>; +def err_missing_sysroot : Error<"no such sysroot directory: '%0'">; def err_drv_darwin_sdk_missing_arclite : Error< "SDK does not contain 'libarclite' at the path '%0'; try increasing the minimum deployment target">; diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index e3263fe9ccb9d4..0a477da7186b09 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -19,9 +19,11 @@ def err_no_such_header_file : Error<"no such %select{public|private|project}1 he def warn_no_such_excluded_header_file : Warning<"no such excluded %select{public|private}0 header file: '%1'">, InGroup; def warn_glob_did_not_match: Warning<"glob '%0' did not match any header file">, InGroup; def err_no_such_umbrella_header_file : Error<"%select{public|private|project}1 umbrella header file not found in input: '%0'">; +def err_cannot_find_reexport : Error<"cannot find re-exported %select{framework|library}0: '%1'">; } // end of command line category. let CategoryName = "Verification" in { +// Diagnostics about symbols. def warn_target: Warning<"violations found for %0">, InGroup; def err_library_missing_symbol : Error<"declaration has external linkage, but dynamic library doesn't have symbol '%0'">; def warn_library_missing_symbol : Warning<"declaration has external linkage, but dynamic library doesn't have symbol '%0'">, InGroup; @@ -43,6 +45,25 @@ def err_dylib_symbol_flags_mismatch : Error<"dynamic library symbol '%0' is " "%select{weak defined|thread local}1, but its declaration is not">; def err_header_symbol_flags_mismatch : Error<"declaration '%0' is " "%select{weak defined|thread local}1, but symbol is not in dynamic library">; + +// Diagnostics about load commands. +def err_architecture_mismatch : Error<"architectures do not match: '%0' (provided) vs '%1' (found)">; +def warn_platform_mismatch : Warning<"platform does not match: '%0' (provided) vs '%1' (found)">, InGroup; +def err_platform_mismatch : Error<"platform does not match: '%0' (provided) vs '%1' (found)">; +def err_install_name_mismatch : Error<"install_name does not match: '%0' (provided) vs '%1' (found)">; +def err_current_version_mismatch : Error<"current_version does not match: '%0' (provided) vs '%1' (found)">; +def err_compatibility_version_mismatch : Error<"compatibility_version does not match: '%0' (provided) vs
[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/87684 >From 3ac6872328334384fa20998541fac841add767d9 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 4 Apr 2024 12:08:28 -0700 Subject: [PATCH 1/3] [cmake] Build executables with -no_exported_symbols when building Apple toolchain Building the Apple way turns off plugin support, meaning we don't need to be exporting unloadable symbols from all executables. While deadstripping effects aren't expected to change, enabling this across all tools prevents the creation of export tries. This saves us ~3.5 MB's in just the universal build of `clang`. --- clang/cmake/caches/Apple-stage2.cmake | 1 + lldb/cmake/caches/Apple-lldb-base.cmake | 1 + llvm/CMakeLists.txt | 3 +++ llvm/cmake/modules/AddLLVM.cmake| 30 ++--- llvm/docs/CMake.rst | 4 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/clang/cmake/caches/Apple-stage2.cmake b/clang/cmake/caches/Apple-stage2.cmake index 72cdedd611bc96..faf61fd1fe9ecb 100644 --- a/clang/cmake/caches/Apple-stage2.cmake +++ b/clang/cmake/caches/Apple-stage2.cmake @@ -15,6 +15,7 @@ set(LLVM_ENABLE_ZLIB ON CACHE BOOL "") set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") set(LLVM_ENABLE_MODULES ON CACHE BOOL "") set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "") +set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") set(CLANG_SPAWN_CC1 ON CACHE BOOL "") set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "") diff --git a/lldb/cmake/caches/Apple-lldb-base.cmake b/lldb/cmake/caches/Apple-lldb-base.cmake index 4d4f02bfae95bd..021538896b2346 100644 --- a/lldb/cmake/caches/Apple-lldb-base.cmake +++ b/lldb/cmake/caches/Apple-lldb-base.cmake @@ -3,6 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "") set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "") set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") +set(LLVM_ENABLE_NO_EXPORTED_SYMBOLS ON CACHE BOOL "") set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "") diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 6f5647d70d8bc1..7e393acacb80d8 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE option(LLVM_EXTERNALIZE_DEBUGINFO "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF) +option(LLVM_ENABLE_NO_EXPORTED_SYMBOLS + "When building executables, disable any symbol exports (Darwin Only)" OFF) + set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING "Sign executables and dylibs with the given identity or skip if empty (Darwin Only)") diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 745935f1405170..141a97c852e24f 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -258,15 +258,24 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32) endif() endif() - # Apple's linker complains about duplicate libraries, which CMake likes to do - # to support ELF platforms. To silence that warning, we can use - # -no_warn_duplicate_libraries, but only in versions of the linker that - # support that flag. - if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") include(CheckLinkerFlag) -check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES) - else() -set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "") +# Linkers that support Darwin allow a setting to internalize all symbol exports, +# aiding in reducing binary size and often is applicable for executables. +check_linker_flag(C "-Wl,-no_exported_symbols" LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS) + +if (NOT LLVM_USE_LINKER) + # Apple's linker complains about duplicate libraries, which CMake likes to do + # to support ELF platforms. To silence that warning, we can use + # -no_warn_duplicate_libraries, but only in versions of the linker that + # support that flag. + check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES) +else() + set(LLVM_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "") +endif() + + else() +set(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS OFF CACHE INTERNAL "") endif() endif() @@ -1029,6 +1038,11 @@ macro(add_llvm_executable name) add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} ) endif(LLVM_EXPORTED_SYMBOL_FILE) + if (LLVM_ENABLE_NO_EXPORTED_SYMBOLS AND LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS) +set_property(TARGET ${name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,-no_exported_symbols") + endif() + if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB) set(USE_SHARED USE_SHARED) end
[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/87674 >From 7ef1a803c10cfef8f577a4e439221d778215464a Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Wed, 27 Mar 2024 12:17:01 -0400 Subject: [PATCH 1/2] [InstallAPI] Capture and compare load commands that may differ per arch slice * Capture reexported libraries, allowable clients, rpaths, shared cache eligiblity. * Add support for select Xarch options. * Add diagnostics related to capturing these options. * Add support for verifying these attributes against what is encoded in the dylib. --- .../clang/Basic/DiagnosticDriverKinds.td | 1 + .../clang/Basic/DiagnosticInstallAPIKinds.td | 21 + clang/include/clang/InstallAPI/Context.h | 17 + .../include/clang/InstallAPI/DylibVerifier.h | 29 +- clang/include/clang/InstallAPI/MachO.h| 2 + clang/lib/InstallAPI/CMakeLists.txt | 1 + .../InstallAPI/DiagnosticBuilderWrappers.cpp | 111 +++ .../InstallAPI/DiagnosticBuilderWrappers.h| 49 ++ clang/lib/InstallAPI/DylibVerifier.cpp| 196 ++ clang/lib/InstallAPI/Frontend.cpp | 54 ++ clang/test/InstallAPI/binary-attributes.test | 70 ++ .../InstallAPI/driver-invalid-options.test| 6 + .../InstallAPI/reexported-frameworks.test | 638 + clang/test/InstallAPI/rpath.test | 663 ++ clang/tools/clang-installapi/CMakeLists.txt | 1 + .../clang-installapi/ClangInstallAPI.cpp | 27 +- .../tools/clang-installapi/InstallAPIOpts.td | 40 +- clang/tools/clang-installapi/Options.cpp | 277 +++- clang/tools/clang-installapi/Options.h| 43 +- 19 files changed, 2230 insertions(+), 16 deletions(-) create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.h create mode 100644 clang/test/InstallAPI/binary-attributes.test create mode 100644 clang/test/InstallAPI/reexported-frameworks.test create mode 100644 clang/test/InstallAPI/rpath.test diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 3d86f7510bde20..fdce4f3f9d9a60 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -663,6 +663,7 @@ def warn_drv_darwin_sdk_invalid_settings : Warning< "SDK settings were ignored as 'SDKSettings.json' could not be parsed">, InGroup>; +def err_missing_sysroot : Error<"no such sysroot directory: '%0'">; def err_drv_darwin_sdk_missing_arclite : Error< "SDK does not contain 'libarclite' at the path '%0'; try increasing the minimum deployment target">; diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index e3263fe9ccb9d4..0a477da7186b09 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -19,9 +19,11 @@ def err_no_such_header_file : Error<"no such %select{public|private|project}1 he def warn_no_such_excluded_header_file : Warning<"no such excluded %select{public|private}0 header file: '%1'">, InGroup; def warn_glob_did_not_match: Warning<"glob '%0' did not match any header file">, InGroup; def err_no_such_umbrella_header_file : Error<"%select{public|private|project}1 umbrella header file not found in input: '%0'">; +def err_cannot_find_reexport : Error<"cannot find re-exported %select{framework|library}0: '%1'">; } // end of command line category. let CategoryName = "Verification" in { +// Diagnostics about symbols. def warn_target: Warning<"violations found for %0">, InGroup; def err_library_missing_symbol : Error<"declaration has external linkage, but dynamic library doesn't have symbol '%0'">; def warn_library_missing_symbol : Warning<"declaration has external linkage, but dynamic library doesn't have symbol '%0'">, InGroup; @@ -43,6 +45,25 @@ def err_dylib_symbol_flags_mismatch : Error<"dynamic library symbol '%0' is " "%select{weak defined|thread local}1, but its declaration is not">; def err_header_symbol_flags_mismatch : Error<"declaration '%0' is " "%select{weak defined|thread local}1, but symbol is not in dynamic library">; + +// Diagnostics about load commands. +def err_architecture_mismatch : Error<"architectures do not match: '%0' (provided) vs '%1' (found)">; +def warn_platform_mismatch : Warning<"platform does not match: '%0' (provided) vs '%1' (found)">, InGroup; +def err_platform_mismatch : Error<"platform does not match: '%0' (provided) vs '%1' (found)">; +def err_install_name_mismatch : Error<"install_name does not match: '%0' (provided) vs '%1' (found)">; +def err_current_version_mismatch : Error<"current_version does not match: '%0' (provided) vs '%1' (found)">; +def err_compatibility_version_mismatch : Error<"compatibility_version does not match: '%0' (provided) vs
[clang] [InstallAPI] Add test to validate cc1 arg forwarding (PR #87666)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/87666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Add test to validate cc1 arg forwarding (PR #87666)
https://github.com/cyndyishida edited https://github.com/llvm/llvm-project/pull/87666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/87674 >From 7ef1a803c10cfef8f577a4e439221d778215464a Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Wed, 27 Mar 2024 12:17:01 -0400 Subject: [PATCH] [InstallAPI] Capture and compare load commands that may differ per arch slice * Capture reexported libraries, allowable clients, rpaths, shared cache eligiblity. * Add support for select Xarch options. * Add diagnostics related to capturing these options. * Add support for verifying these attributes against what is encoded in the dylib. --- .../clang/Basic/DiagnosticDriverKinds.td | 1 + .../clang/Basic/DiagnosticInstallAPIKinds.td | 21 + clang/include/clang/InstallAPI/Context.h | 17 + .../include/clang/InstallAPI/DylibVerifier.h | 29 +- clang/include/clang/InstallAPI/MachO.h| 2 + clang/lib/InstallAPI/CMakeLists.txt | 1 + .../InstallAPI/DiagnosticBuilderWrappers.cpp | 111 +++ .../InstallAPI/DiagnosticBuilderWrappers.h| 49 ++ clang/lib/InstallAPI/DylibVerifier.cpp| 196 ++ clang/lib/InstallAPI/Frontend.cpp | 54 ++ clang/test/InstallAPI/binary-attributes.test | 70 ++ .../InstallAPI/driver-invalid-options.test| 6 + .../InstallAPI/reexported-frameworks.test | 638 + clang/test/InstallAPI/rpath.test | 663 ++ clang/tools/clang-installapi/CMakeLists.txt | 1 + .../clang-installapi/ClangInstallAPI.cpp | 27 +- .../tools/clang-installapi/InstallAPIOpts.td | 40 +- clang/tools/clang-installapi/Options.cpp | 277 +++- clang/tools/clang-installapi/Options.h| 43 +- 19 files changed, 2230 insertions(+), 16 deletions(-) create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.h create mode 100644 clang/test/InstallAPI/binary-attributes.test create mode 100644 clang/test/InstallAPI/reexported-frameworks.test create mode 100644 clang/test/InstallAPI/rpath.test diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 3d86f7510bde20..fdce4f3f9d9a60 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -663,6 +663,7 @@ def warn_drv_darwin_sdk_invalid_settings : Warning< "SDK settings were ignored as 'SDKSettings.json' could not be parsed">, InGroup>; +def err_missing_sysroot : Error<"no such sysroot directory: '%0'">; def err_drv_darwin_sdk_missing_arclite : Error< "SDK does not contain 'libarclite' at the path '%0'; try increasing the minimum deployment target">; diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index e3263fe9ccb9d4..0a477da7186b09 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -19,9 +19,11 @@ def err_no_such_header_file : Error<"no such %select{public|private|project}1 he def warn_no_such_excluded_header_file : Warning<"no such excluded %select{public|private}0 header file: '%1'">, InGroup; def warn_glob_did_not_match: Warning<"glob '%0' did not match any header file">, InGroup; def err_no_such_umbrella_header_file : Error<"%select{public|private|project}1 umbrella header file not found in input: '%0'">; +def err_cannot_find_reexport : Error<"cannot find re-exported %select{framework|library}0: '%1'">; } // end of command line category. let CategoryName = "Verification" in { +// Diagnostics about symbols. def warn_target: Warning<"violations found for %0">, InGroup; def err_library_missing_symbol : Error<"declaration has external linkage, but dynamic library doesn't have symbol '%0'">; def warn_library_missing_symbol : Warning<"declaration has external linkage, but dynamic library doesn't have symbol '%0'">, InGroup; @@ -43,6 +45,25 @@ def err_dylib_symbol_flags_mismatch : Error<"dynamic library symbol '%0' is " "%select{weak defined|thread local}1, but its declaration is not">; def err_header_symbol_flags_mismatch : Error<"declaration '%0' is " "%select{weak defined|thread local}1, but symbol is not in dynamic library">; + +// Diagnostics about load commands. +def err_architecture_mismatch : Error<"architectures do not match: '%0' (provided) vs '%1' (found)">; +def warn_platform_mismatch : Warning<"platform does not match: '%0' (provided) vs '%1' (found)">, InGroup; +def err_platform_mismatch : Error<"platform does not match: '%0' (provided) vs '%1' (found)">; +def err_install_name_mismatch : Error<"install_name does not match: '%0' (provided) vs '%1' (found)">; +def err_current_version_mismatch : Error<"current_version does not match: '%0' (provided) vs '%1' (found)">; +def err_compatibility_version_mismatch : Error<"compatibility_version does not match: '%0' (provided) vs '%1'
[clang] [InstallAPI] Capture & compare load commands that may differ per arch slice (PR #87674)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/87674 >From a7e67582e35fe6c33a1e391eaf6cc7d5b49087c6 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Wed, 27 Mar 2024 12:17:01 -0400 Subject: [PATCH 1/2] [InstallAPI] Capture and compare load commands that may differ per arch slice * Capture reexported libraries, allowable clients, rpaths, shared cache eligiblity. * Add support for select Xarch options. * Add diagnostics related to capturing these options. * Add support for verifying these attributes against what is encoded in the dylib. --- .../clang/Basic/DiagnosticDriverKinds.td | 1 + .../clang/Basic/DiagnosticInstallAPIKinds.td | 21 + clang/include/clang/InstallAPI/Context.h | 17 + .../include/clang/InstallAPI/DylibVerifier.h | 25 +- clang/include/clang/InstallAPI/MachO.h| 2 + clang/lib/InstallAPI/CMakeLists.txt | 1 + .../InstallAPI/DiagnosticBuilderWrappers.cpp | 111 +++ .../InstallAPI/DiagnosticBuilderWrappers.h| 49 ++ clang/lib/InstallAPI/DylibVerifier.cpp| 175 + clang/lib/InstallAPI/Frontend.cpp | 54 ++ clang/test/InstallAPI/binary-attributes.test | 70 ++ .../InstallAPI/driver-invalid-options.test| 6 + .../InstallAPI/reexported-frameworks.test | 551 +++ clang/test/InstallAPI/rpath.test | 663 ++ clang/tools/clang-installapi/CMakeLists.txt | 1 + .../clang-installapi/ClangInstallAPI.cpp | 27 +- .../tools/clang-installapi/InstallAPIOpts.td | 40 +- clang/tools/clang-installapi/Options.cpp | 269 ++- clang/tools/clang-installapi/Options.h| 43 +- 19 files changed, 2110 insertions(+), 16 deletions(-) create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp create mode 100644 clang/lib/InstallAPI/DiagnosticBuilderWrappers.h create mode 100644 clang/test/InstallAPI/binary-attributes.test create mode 100644 clang/test/InstallAPI/reexported-frameworks.test create mode 100644 clang/test/InstallAPI/rpath.test diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 3d86f7510bde20..fdce4f3f9d9a60 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -663,6 +663,7 @@ def warn_drv_darwin_sdk_invalid_settings : Warning< "SDK settings were ignored as 'SDKSettings.json' could not be parsed">, InGroup>; +def err_missing_sysroot : Error<"no such sysroot directory: '%0'">; def err_drv_darwin_sdk_missing_arclite : Error< "SDK does not contain 'libarclite' at the path '%0'; try increasing the minimum deployment target">; diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index e3263fe9ccb9d4..0a477da7186b09 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -19,9 +19,11 @@ def err_no_such_header_file : Error<"no such %select{public|private|project}1 he def warn_no_such_excluded_header_file : Warning<"no such excluded %select{public|private}0 header file: '%1'">, InGroup; def warn_glob_did_not_match: Warning<"glob '%0' did not match any header file">, InGroup; def err_no_such_umbrella_header_file : Error<"%select{public|private|project}1 umbrella header file not found in input: '%0'">; +def err_cannot_find_reexport : Error<"cannot find re-exported %select{framework|library}0: '%1'">; } // end of command line category. let CategoryName = "Verification" in { +// Diagnostics about symbols. def warn_target: Warning<"violations found for %0">, InGroup; def err_library_missing_symbol : Error<"declaration has external linkage, but dynamic library doesn't have symbol '%0'">; def warn_library_missing_symbol : Warning<"declaration has external linkage, but dynamic library doesn't have symbol '%0'">, InGroup; @@ -43,6 +45,25 @@ def err_dylib_symbol_flags_mismatch : Error<"dynamic library symbol '%0' is " "%select{weak defined|thread local}1, but its declaration is not">; def err_header_symbol_flags_mismatch : Error<"declaration '%0' is " "%select{weak defined|thread local}1, but symbol is not in dynamic library">; + +// Diagnostics about load commands. +def err_architecture_mismatch : Error<"architectures do not match: '%0' (provided) vs '%1' (found)">; +def warn_platform_mismatch : Warning<"platform does not match: '%0' (provided) vs '%1' (found)">, InGroup; +def err_platform_mismatch : Error<"platform does not match: '%0' (provided) vs '%1' (found)">; +def err_install_name_mismatch : Error<"install_name does not match: '%0' (provided) vs '%1' (found)">; +def err_current_version_mismatch : Error<"current_version does not match: '%0' (provided) vs '%1' (found)">; +def err_compatibility_version_mismatch : Error<"compatibility_version does not match: '%0' (provided) vs '%1'