gen2brain / go-fitz

Golang wrapper for the MuPDF Fitz library
GNU Affero General Public License v3.0
429 stars 97 forks source link

feat: support windows/arm64 #112

Closed iwilltry42 closed 4 weeks ago

iwilltry42 commented 3 months ago

According to fitz_cgo.go and the libs files, Windows arm64 (aarch64) doesn't seem to be supported directly. Is there any time and interest for adding it?

gen2brain commented 3 months ago

If it is easy for me to add new crossdev toolchain on mu system I will add it. Not sure, I don't even know what devices use windows/arm64. I will check after the summer is over.

iwilltry42 commented 3 months ago

I used https://github.com/mstorsjo/llvm-mingw but still failed building the mupdf lib because of sse4.1 instructions. I must be missing something, but I'm also not an expert in this field.

gen2brain commented 1 month ago

Ok, I added libraries for windows/arm64.

# CGO_ENABLED=1 CC=aarch64-w64-mingw32-gcc GOOS=windows GOARCH=arm64 go build -ldflags '-s -w'

# file example.exe
example.exe: PE32+ executable (console) Aarch64, for MS Windows, 7 sections
iwilltry42 commented 1 month ago

This is dope, I'll try it soon, thank you!

May I ask how you got there? I failed to get it working.

gen2brain commented 1 month ago

I just used aarch64-w64-mingw-gcc from llvm-mingw as CC and compiled the library similar as what I do for other platforms. Here is an excerpt:

MINGW_ARM_64="/usr/aarch64-w64-mingw32"

OPTS="HAVE_X11=no HAVE_GLFW=no HAVE_GLUT=no WANT_OPENSSL=no WANT_CURL=no HAVE_MUJS=yes HAVE_JSCORE=no HAVE_V8=no"

export PATH=${PATH}:${MINGW_ARM_64}/bin
CROSS="aarch64-w64-mingw32-" \
PKG_CONFIG_LIBDIR=${MINGW_ARM_64}/lib/pkgconfig \
    CC=${CROSS}gcc CXX=${CROSS}g++ \
    LD=${CROSS}ld AR=${CROSS}ar \
    CROSSCOMPILE=yes `eval "${OPTS}"` make -j$(nproc) libs OS=mingw64-cross-arm64

And I had to modify Makerules to add mingw64-cross-arm64 section, similar to mingw64-cross.