cb424d7448
verify-patch-sanity.py validates every active recipe .patch has internally- consistent hunk line counts — catching the 'malformed patch at line N' failure at commit/CI/preflight time instead of hours into a cook. This cycle hit that class three times (qtwaylandscanner, sddm, xwayland), each only discovered when cookbook tried to apply the patch. Running it across the repo found 29 latent malformed patches (validated against GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22'). They were harmless only because they sit in vendored recipes (baked, not re- applied) — but would fail on any version-bump re-derivation. --fix recounts the hunk headers (body untouched) and repaired all 29. Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test (test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats (empty placeholders, bare-@@ git hunks).
55 lines
2.1 KiB
C++
55 lines
2.1 KiB
C++
//===- lib/Passes/PassPluginLoader.cpp - Load Plugins for New PM Passes ---===//
|
|
//
|
|
// 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 "llvm/Passes/PassPlugin.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include <cstdint>
|
|
|
|
using namespace llvm;
|
|
|
|
Expected<PassPlugin> PassPlugin::Load(const std::string &Filename) {
|
|
std::string Error;
|
|
auto Library =
|
|
sys::DynamicLibrary::getPermanentLibrary(Filename.c_str(), &Error);
|
|
if (!Library.isValid())
|
|
return make_error<StringError>(Twine("Could not load library '") +
|
|
Filename + "': " + Error,
|
|
inconvertibleErrorCode());
|
|
|
|
PassPlugin P{Filename, Library};
|
|
|
|
// llvmGetPassPluginInfo should be resolved to the definition from the plugin
|
|
// we are currently loading.
|
|
intptr_t getDetailsFn =
|
|
(intptr_t)Library.getAddressOfSymbol("llvmGetPassPluginInfo");
|
|
|
|
if (!getDetailsFn)
|
|
// If the symbol isn't found, this is probably a legacy plugin, which is an
|
|
// error
|
|
return make_error<StringError>(Twine("Plugin entry point not found in '") +
|
|
Filename + "'. Is this a legacy plugin?",
|
|
inconvertibleErrorCode());
|
|
|
|
P.Info = reinterpret_cast<decltype(llvmGetPassPluginInfo) *>(getDetailsFn)();
|
|
|
|
if (P.Info.APIVersion != LLVM_PLUGIN_API_VERSION)
|
|
return make_error<StringError>(
|
|
Twine("Wrong API version on plugin '") + Filename + "'. Got version " +
|
|
Twine(P.Info.APIVersion) + ", supported version is " +
|
|
Twine(LLVM_PLUGIN_API_VERSION) + ".",
|
|
inconvertibleErrorCode());
|
|
|
|
if (!P.Info.RegisterPassBuilderCallbacks)
|
|
return make_error<StringError>(Twine("Empty entry callback in plugin '") +
|
|
Filename + "'.'",
|
|
inconvertibleErrorCode());
|
|
|
|
return P;
|
|
}
|