Files
RedBear-OS/local/recipes/qt/qtdeclarative/source/tools/qmljs/qmljs.cpp
T
vasilito f31522130f fix: comprehensive boot warnings and exceptions — fixable silenced, unfixable diagnosed
Build system (5 gaps hardened):
- COOKBOOK_OFFLINE defaults to true (fork-mode)
- normalize_patch handles diff -ruN format
- New 'repo validate-patches' command (25/25 relibc patches)
- 14 patched Qt/Wayland/display recipes added to protected list
- relibc archive regenerated with current patch chain

Boot fixes (fixable):
- Full ISO EFI partition: 16 MiB → 1 MiB (matches mini, BIOS hardcoded 2 MiB offset)
- D-Bus system bus: absolute /usr/bin/dbus-daemon path (was skipped)
- redbear-sessiond: absolute /usr/bin/redbear-sessiond path (was skipped)
- daemon framework: silenced spurious INIT_NOTIFY warnings for oneshot_async services (P0-daemon-silence-init-notify.patch)
- udev-shim: demoted INIT_NOTIFY warning to INFO (expected for oneshot_async)
- relibc: comprehensive named semaphores (sem_open/close/unlink) replacing upstream todo!() stubs
- greeterd: Wayland socket timeout 15s → 30s (compositor DRM wait)
- greeter-ui: built and linked (header guard unification, sem_compat stubs removed)
- mc: un-ignored in both configs, fixed glib/libiconv/pcre2 transitive deps
- greeter config: removed stale keymapd dependency from display/greeter services
- prefix toolchain: relibc headers synced, _RELIBC_STDLIB_H guard unified

Unfixable (diagnosed, upstream):
- i2c-hidd: abort on no-I2C-hardware (QEMU) — process::exit → relibc abort
- kded6/greeter-ui: page fault 0x8 — Qt library null deref
- Thread panics fd != -1 — Rust std library on Redox
- DHCP timeout / eth0 MAC — QEMU user-mode networking
- hwrngd/thermald — no hardware RNG/thermal in VM
- live preload allocation — BIOS memory fragmentation, continues on demand
2026-05-05 20:20:37 +01:00

181 lines
6.9 KiB
C++

// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <private/qqmlbuiltinfunctions_p.h>
#include <private/qqmljsast_p.h>
#include <private/qqmljsengine_p.h>
#include <private/qqmljslexer_p.h>
#include <private/qqmljsparser_p.h>
#include <private/qqmlscriptblob_p.h>
#include <private/qqmltypeloader_p.h>
#include <private/qv4codegen_p.h>
#include <private/qv4context_p.h>
#include <private/qv4errorobject_p.h>
#include <private/qv4functionobject_p.h>
#include <private/qv4globalobject_p.h>
#include <private/qv4mm_p.h>
#include <private/qv4module_p.h>
#include <private/qv4object_p.h>
#include <private/qv4objectproto_p.h>
#include <private/qv4runtime_p.h>
#include <private/qv4script_p.h>
#include <private/qv4string_p.h>
#include <QtCore/qcommandlineparser.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
#include <iostream>
static void showException(QV4::ExecutionContext *ctx, const QV4::Value &exception, const QV4::StackTrace &trace)
{
QV4::Scope scope(ctx);
QV4::ScopedValue ex(scope, exception);
QV4::ErrorObject *e = ex->as<QV4::ErrorObject>();
if (!e) {
std::cerr << "Uncaught exception: " << qPrintable(ex->toQString()) << std::endl;
} else {
std::cerr << "Uncaught exception: " << qPrintable(e->toQStringNoThrow()) << std::endl;
}
for (const QV4::StackFrame &frame : trace) {
std::cerr << " at " << qPrintable(frame.function) << " (" << qPrintable(frame.source);
if (frame.line >= 0)
std::cerr << ':' << frame.line;
std::cerr << ')' << std::endl;
}
}
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
QCommandLineParser parser;
parser.addHelpOption();
parser.setApplicationDescription("Utility to execute scripts in QML's V4 engine");
parser.addVersionOption();
parser.addPositionalArgument("files", "Files to execute.", "[files...]");
QCommandLineOption forceJit("jit", "Force JIT.");
parser.addOption(forceJit);
QCommandLineOption forceInterpreter("interpret", "Force interpreter.");
parser.addOption(forceInterpreter);
QCommandLineOption qml("qml", "Run as QML.");
parser.addOption(qml);
QCommandLineOption module("module", "Run as Module.");
parser.addOption(module);
QCommandLineOption cache("cache", "Use cache.");
parser.addOption(cache);
parser.process(app);
bool jitEnabled = false;
if (parser.isSet(forceJit)) {
qputenv("QV4_JIT_CALL_THRESHOLD", QByteArray("0"));
jitEnabled = true;
}
if (parser.isSet(forceInterpreter)) {
qputenv("QV4_FORCE_INTERPRETER", QByteArray("1"));
if (jitEnabled) {
std::cerr << "You cannot use 'Force JIT' and 'Force Interpreter' at the same time.";
return EXIT_FAILURE;
}
}
const bool runAsQml = parser.isSet(qml);
const bool runAsModule = parser.isSet(module);
const bool useCache = parser.isSet(cache);
const QStringList args = parser.positionalArguments();
QV4::ExecutionEngine vm;
QV4::Scope scope(&vm);
QV4::ScopedContext ctx(scope, vm.rootContext());
QV4::GlobalExtensions::init(vm.globalObject, QJSEngine::ConsoleExtension | QJSEngine::GarbageCollectionExtension);
for (const QString &fn : args) {
QV4::ScopedValue result(scope);
if (runAsModule) {
QV4::ScopedValue result(scope);
QUrl url = QUrl::fromLocalFile(QFileInfo(fn).absoluteFilePath());
if (!fn.endsWith(QLatin1String(".mjs")))
url.setFragment(QLatin1String("module"));
QQmlRefPointer<QQmlScriptBlob> blob = vm.typeLoader()->getScript(url);
if (blob->isComplete()) {
const auto module
= vm.executableCompilationUnit(blob->scriptData()->compilationUnit());
if (module->instantiate())
module->evaluate();
} else {
// Local URL is loaded synchronously.
Q_ASSERT(blob->isError());
vm.throwError(QStringLiteral("Could not load module file"));
}
} else {
QFile file(fn);
if (!file.open(QFile::ReadOnly)) {
std::cerr << "Error: cannot open file " << fn.toUtf8().constData() << std::endl;
return EXIT_FAILURE;
}
QScopedPointer<QV4::Script> script;
if (useCache && QFile::exists(fn + QLatin1Char('c'))) {
auto unit = QQml::makeRefPointer<QV4::CompiledData::CompilationUnit>();
QString error;
if (unit->loadFromDisk(QUrl::fromLocalFile(fn), QFileInfo(fn).lastModified(), &error)) {
script.reset(new QV4::Script(
&vm, nullptr, vm.insertCompilationUnit(std::move(unit))));
} else {
std::cout << "Error loading" << qPrintable(fn) << "from disk cache:" << qPrintable(error) << std::endl;
}
}
if (!script) {
QByteArray ba = file.readAll();
const QString code = QString::fromUtf8(ba.constData(), ba.size());
file.close();
script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, fn));
script->setParseAsBinding(runAsQml);
script->parse();
}
if (!scope.hasException()) {
const auto unit = script->compilationUnit();
if (useCache && unit && !(unit->unitData()->flags & QV4::CompiledData::Unit::StaticData)) {
if (unit->unitData()->sourceTimeStamp == 0) {
const_cast<QV4::CompiledData::Unit*>(unit->unitData())->sourceTimeStamp = QFileInfo(fn).lastModified().toMSecsSinceEpoch();
}
QString saveError;
if (!unit->baseCompilationUnit()->saveToDisk(
QUrl::fromLocalFile(fn), &saveError)) {
std::cout << "Error saving JS cache file: " << qPrintable(saveError) << std::endl;
}
}
// QElapsedTimer t; t.start();
result = script->run();
// std::cout << t.elapsed() << " ms. elapsed" << std::endl;
}
}
if (scope.hasException()) {
QV4::StackTrace trace;
QV4::ScopedValue ex(scope, scope.engine->catchException(&trace));
showException(ctx, ex, trace);
return EXIT_FAILURE;
}
if (!result->isUndefined()) {
if (! qgetenv("SHOW_EXIT_VALUE").isEmpty())
std::cout << "exit value: " << qPrintable(result->toQString()) << std::endl;
}
}
return EXIT_SUCCESS;
}