Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,32 @@ jobs:
with:
name: SumatraPDF-linux-wine-debug
path: out/dbg64-wine/SumatraPDF.exe

native:
name: Native build and unit tests
runs-on: ubuntu-latest
container: debian:trixie
steps:
- name: Check out source code
uses: actions/checkout@v7

- name: Install clang, OpenSSL headers and bun
run: |
apt-get update
apt-get install -y --no-install-recommends \
build-essential clang lld libssl-dev \
ca-certificates curl unzip git
curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr/local bash

# builds all dependency libs, runs test_util's unit-test suite
# natively, and links test_engines
- name: Build dependencies and run native unit tests
run: bun cmd/build-linux.ts -debug

- name: Upload test tools
uses: actions/upload-artifact@v7
with:
name: sumatra-linux-native-tools
path: |
out/linux-dbg64/test_util
out/linux-dbg64/test_engines
19 changes: 17 additions & 2 deletions cmd/build-linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
spawnCmd,
} from "./build-deps-common";
import {
aGumbo,
zlib,
unrar,
libwebp,
Expand Down Expand Up @@ -594,6 +595,7 @@ const DEP_LIBS_BASE = [
},
],
},
aGumbo,
zlib,
makeUnrar,
makeLibdjvu,
Expand Down Expand Up @@ -623,7 +625,12 @@ const TEST_UTIL_SOURCES = [
"src/Commands.cpp",
"src/CrashHandlerNoOp.cpp",
"src/DisplayMode.cpp",
"src/DocProperties.cpp",
"src/Flags.cpp",
"src/PdfDarkModeImageClassifier_ut.cpp",
"src/PdfDarkModeImageRules.cpp",
"src/PdfDarkModeOklab.cpp",
"src/PdfDarkModeOklab_ut.cpp",
"src/RefHoverDetect.cpp",
"src/RefHoverTextDetect.cpp",
"src/SimpleLog_ut.cpp",
Expand Down Expand Up @@ -663,6 +670,9 @@ const TEST_ENGINES_SOURCES = [
"src/GumboHelpers.cpp",
"src/MobiDoc.cpp",
"src/PalmDbReader.cpp",
"src/PdfCadDetect.cpp",
"src/PdfCadEnhanceDevice.cpp",
"src/PdfDarkModeNoOp.cpp",
"src/TreeModel.cpp",
"src/tools/test_engines.cpp",
];
Expand Down Expand Up @@ -880,6 +890,7 @@ async function buildTestUtil(
...commonFlags,
...units.map((u) => u.obj),
join(outDir, "lib", "libbase.a"),
"-lcrypto",
];
const res = await spawnCmd(linkArgs);
if (!res.ok) {
Expand Down Expand Up @@ -957,6 +968,7 @@ async function buildTestEngines(
exePath,
...commonFlags,
...units.map((u) => u.obj),
"-Wl,--start-group",
join(outDir, "lib", "libbase.a"),
join(outDir, "lib", "libmupdf.a"),
join(outDir, "lib", "libcmark-gfm.a"),
Expand All @@ -966,12 +978,15 @@ async function buildTestEngines(
join(outDir, "lib", "libfreetype.a"),
join(outDir, "lib", "libbrotli.a"),
join(outDir, "lib", "liblcms2.a"),
join(outDir, "lib", "libopenjpeg.a"),
join(outDir, "lib", "liba-openjpeg.a"),
join(outDir, "lib", "libjbig2dec.a"),
join(outDir, "lib", "liblibjpeg-turbo.a"),
join(outDir, "lib", "libdjvudec.a"),
join(outDir, "lib", "liblibarchive.a"),
join(outDir, "lib", "libzlib.a"),
join(outDir, "lib", "liba-gumbo.a"),
join(outDir, "lib", "liba-zlib.a"),
"-Wl,--end-group",
"-lcrypto",
];
const res = await spawnCmd(linkArgs);
if (!res.ok) {
Expand Down
6 changes: 6 additions & 0 deletions ext/a-openjpeg/opj_malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ void * opj_realloc(void * m, size_t s);
void opj_free(void * m);

#if defined(__GNUC__) && !defined(OPJ_SKIP_POISON)
/* clang (unlike gcc) enforces poison inside system headers, and mm_malloc.h
(pulled in by the SSE intrinsic headers) calls malloc/free. Include the
intrinsics before poisoning so later includes are no-ops via include guards. */
#if defined(__x86_64__) || defined(__i386__)
#include <immintrin.h>
#endif
#pragma GCC poison malloc calloc realloc free
#endif

Expand Down