diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md index a4c80b6d9b..a43f4e8f88 100644 --- a/Ports/AvailablePorts.md +++ b/Ports/AvailablePorts.md @@ -13,6 +13,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n | [`Another-World`](Another-World/) | Another World Bytecode Interpreter | | https://github.com/fabiensanglard/Another-World-Bytecode-Interpreter | | [`aria2`](aria2/) | aria2 | 1.36.0 | https://aria2.github.io | | [`awk`](awk/) | The One True Awk | 20220122 | https://github.com/onetrueawk/awk | +| [`backward-cpp`](backward-cpp/) | Backward-cpp | 1.6 | https://github.com/bombela/backward-cpp | | [`bash`](bash/) | GNU Bash | 5.1.16 | https://www.gnu.org/software/bash/ | | [`bass`](bass/) | Beneath a Steel Sky | cd-1.2 | https://www.scummvm.org/games | | [`bc`](bc/) | bc | 6.1.1 | https://github.com/gavinhoward/bc | diff --git a/Ports/backward-cpp/package.sh b/Ports/backward-cpp/package.sh new file mode 100755 index 0000000000..bb15e045bb --- /dev/null +++ b/Ports/backward-cpp/package.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env -S bash ../.port_include.sh +port='backward-cpp' +version='1.6' +files="https://github.com/bombela/backward-cpp/archive/refs/tags/v${version}.tar.gz backward-cpp-${version}.tar.gz c654d0923d43f1cea23d086729673498e4741fb2457e806cfaeaea7b20c97c10" +auth_type='sha256' +useconfigure='true' +configopts=( + "-DCMAKE_TOOLCHAIN_FILE=${SERENITY_BUILD_DIR}/CMakeToolchain.txt" +) +depends=( + 'binutils' + 'zlib' +) + +configure() { + run cmake "${configopts[@]}" +} + +install() { + run make install + run mkdir -p ${SERENITY_INSTALL_ROOT}/usr/local/bin/backtrace_tests + run_nocd cp -r ${workdir}/test_* ${SERENITY_INSTALL_ROOT}/usr/local/bin/backtrace_tests +} diff --git a/Ports/backward-cpp/patches/0001-test-Don-t-use-program_invocation_name-on-Serenity.patch b/Ports/backward-cpp/patches/0001-test-Don-t-use-program_invocation_name-on-Serenity.patch new file mode 100644 index 0000000000..5bc9bad0aa --- /dev/null +++ b/Ports/backward-cpp/patches/0001-test-Don-t-use-program_invocation_name-on-Serenity.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Andrew Kaster +Date: Sat, 11 Mar 2023 13:57:17 -0700 +Subject: [PATCH] test: Don't use program_invocation_name on Serenity + +--- + test/_test_main.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/_test_main.cpp b/test/_test_main.cpp +index 68211e030fd2984f291b412e2298a5359806c211..8cd458ab95b4b23d0935270eb6b5b63a63ee4da9 100644 +--- a/test/_test_main.cpp ++++ b/test/_test_main.cpp +@@ -43,7 +43,7 @@ char argv0[MAX_PATH]; + inline const char *getprogname() { + return GetModuleFileName(NULL, argv0, sizeof(argv0)) ? argv0 : NULL; + } +-#elif !defined(__APPLE__) ++#elif !defined(__APPLE__) && !defined(__serenity__) + // N.B. getprogname() is an Apple/BSD-ism. + // program_invocation_name is a GLIBC-ism, but it's also + // supported by libmusl. diff --git a/Ports/backward-cpp/patches/0002-backward-Pretend-to-be-Linux-with-some-modifications.patch b/Ports/backward-cpp/patches/0002-backward-Pretend-to-be-Linux-with-some-modifications.patch new file mode 100644 index 0000000000..de5abcb105 --- /dev/null +++ b/Ports/backward-cpp/patches/0002-backward-Pretend-to-be-Linux-with-some-modifications.patch @@ -0,0 +1,69 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Andrew Kaster +Date: Sat, 11 Mar 2023 15:17:34 -0700 +Subject: [PATCH] backward: Pretend to be Linux, with some modifications + +--- + backward.hpp | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/backward.hpp b/backward.hpp +index ac7ad51738f8d13f07a6162d421b191696c9f84a..03f4f7546c4e59f3b17529c61a0f387e09e3731c 100644 +--- a/backward.hpp ++++ b/backward.hpp +@@ -63,7 +63,7 @@ + #elif defined(BACKWARD_SYSTEM_UNKNOWN) + #elif defined(BACKWARD_SYSTEM_WINDOWS) + #else +-#if defined(__linux) || defined(__linux__) ++#if defined(__linux) || defined(__linux__) || defined(__serenity__) + #define BACKWARD_SYSTEM_LINUX + #elif defined(__APPLE__) + #define BACKWARD_SYSTEM_DARWIN +@@ -213,7 +213,9 @@ + #endif + #include + #include ++#ifndef __serenity__ + #include ++#endif + #include + + #if BACKWARD_HAS_BFD == 1 +@@ -737,7 +739,7 @@ public: + protected: + void load_thread_info() { + #ifdef BACKWARD_SYSTEM_LINUX +-#ifndef __ANDROID__ ++#if !defined(__ANDROID__) && !defined(__serenity__) + _thread_id = static_cast(syscall(SYS_gettid)); + #else + _thread_id = static_cast(gettid()); +@@ -4140,7 +4142,9 @@ public: + SIGBUS, // Bus error (bad memory access) + SIGFPE, // Floating point exception + SIGILL, // Illegal Instruction ++#if !defined(__serenity__) + SIGIOT, // IOT trap. A synonym for SIGABRT ++#endif + SIGQUIT, // Quit from keyboard + SIGSEGV, // Invalid memory reference + SIGSYS, // Bad argument to routine (SVr4) +@@ -4231,6 +4235,8 @@ public: + error_addr = reinterpret_cast(uctx->uc_mcontext->__ss.__rip); + #elif defined(__APPLE__) + error_addr = reinterpret_cast(uctx->uc_mcontext->__ss.__eip); ++#elif defined(__serenity__) && defined(__x86_64__) ++ error_addr = reinterpret_cast(uctx->uc_mcontext.rip); + #else + #warning ":/ sorry, ain't know no nothing none not of your architecture!" + #endif +@@ -4245,7 +4251,7 @@ public: + printer.address = true; + printer.print(st, stderr); + +-#if _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L ++#if (_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L) && !defined(__serenity__) + psiginfo(info, nullptr); + #else + (void)info; diff --git a/Ports/backward-cpp/patches/ReadMe.md b/Ports/backward-cpp/patches/ReadMe.md new file mode 100644 index 0000000000..55e1b03561 --- /dev/null +++ b/Ports/backward-cpp/patches/ReadMe.md @@ -0,0 +1,12 @@ +# Patches for backward-cpp on SerenityOS + +## `0001-test-Don-t-use-program_invocation_name-on-Serenity.patch` + +test: Don't use program_invocation_name on Serenity + + +## `0002-backward-Pretend-to-be-Linux-with-some-modifications.patch` + +backward: Pretend to be Linux, with some modifications + +