Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about the build / package of libpdfium.so for new arch [ppc64le] #187

Open
mgiessing opened this issue Jan 15, 2025 · 3 comments
Open

Comments

@mgiessing
Copy link

I've successfully built libpdfium.so for ppc64le architecture, but when I tried to package it into a pypdfium2 manylinux wheel (2014/glibc2.17+ & 2_28/glibc2.28+) I figured out there must be an issue somewhere as I got:

[...]
OSError: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /pypdfium2/data/linux_ppc64le/libpdfium.so)
[...]

I then inspected the libpdfium for aarch64, x86_64 & ppc64le and saw that for the first two the highest glibc was indeed 2.17, but for ppc64le I had up to 2.29:

aarch64:

$ objdump -x lib/libpdfium.so | grep GLIBC
    0x06969197 0x00 05 GLIBC_2.17
    0x06969197 0x00 04 GLIBC_2.17
    0x06969197 0x00 02 GLIBC_2.17
    0x06969197 0x00 03 GLIBC_2.17

x86_64:

$ objdump -x lib/libpdfium.so | grep GLIBC
    0x09691a75 0x00 08 GLIBC_2.2.5
    0x09691972 0x00 11 GLIBC_2.3.2
    0x09691a75 0x00 06 GLIBC_2.2.5
    0x09691a75 0x00 02 GLIBC_2.2.5
    0x0d696913 0x00 03 GLIBC_2.3
    0x09691973 0x00 14 GLIBC_2.3.3
    0x09691974 0x00 05 GLIBC_2.3.4
    0x0d696914 0x00 04 GLIBC_2.4
    0x0d696917 0x00 12 GLIBC_2.7
    0x06969191 0x00 09 GLIBC_2.11
    0x06969194 0x00 07 GLIBC_2.14
    0x06969196 0x00 15 GLIBC_2.16
    0x0d696913 0x00 10 GLIBC_2.3

ppc64le:

$ objdump -x lib/libpdfium.so | grep GLIBC
    0x06969197 0x00 04 GLIBC_2.17
    0x06969197 0x00 03 GLIBC_2.17
    0x06969187 0x00 05 GLIBC_2.27
    0x06969189 0x00 06 GLIBC_2.29
    0x06969197 0x00 02 GLIBC_2.17
    0x06969197 0x00 07 GLIBC_2.17

I did 3 main changes to make it work:

  • Built debian_bullseye_linux_ppc64el with the sysroot_creator.py script
  • Built libclang_rt.builtins.a for powerpc64le using the clang build.py script
  • Added ppc64le to various places in the build toolchain

I believe the first two should be fine as I did it in the same git checkout but I'm wondering if I have somewhere forget a spot in the build toolchain to restrict the lib to e.g. 2.17?

Btw. I tried to keep it as simple as possible, here is the patch I apply after checking out:
https://github.com/mgiessing/pdfium-binaries/blob/ppc64le/patches/build_config_ppc64le.patch

Any help is appreciated :)

@mgiessing
Copy link
Author

Based on this issue #82 I saw in my sysroot.../libc6/DEBIAN/symbols I also got too recent symbols for 2.27 & 2.29 - I just don't know how to proper process of creating this looks like.
When I build a new arm64 sysroot using the sysroot_creator.py script it also has newer symbols (2.27, 2.29...) in it - so I guess there is a different way of creating that image...

I was more or less following the chromium notes here

Again, any help is appreciated :)

@bblanchon
Copy link
Owner

Hi @mgiessing,

Congratulations on building PDFium no ppc64le 🎉

Does it need the host to be ppc64le, or can it be cross-built?
If we want to include this in the weekly build, it must build on an x64 host.

I wish I could help you, but as you saw in #82, I'm clueless about the GLIB version issues.
Your best chance is to ask on the PDFium group.

Best regards,
Benoit

@mgiessing
Copy link
Author

mgiessing commented Jan 16, 2025

Thank you! It can be cross-compiled on an x86_64 system - I have a AlmaLinux8.9 and tried it manually using:

dnf install -y git podman
mkdir -p $HOME/git && cd $HOME/git

git clone -b ppc64le https://github.com/mgiessing/pdfium-binaries 

# pdfium-binaries use ubuntu:24.04 in their GH Actions
podman run -ti -v $HOME/git:/root/git --cap-add=AUDIT_WRITE ubuntu:24.04
apt update && apt install sudo lsb-release file git python3 python3-pip wget curl -y
cd /root/git/pdfium-binaries/
PDFium_BRANCH="chromium/6954" bash build.sh linux ppc64le

However there are two "dirty" things that should probably be changed to the upstream pdfium/build/third_party project:

  • They don't build debian_bullseye_ppc64el_sysroot, that's why I built it manually, uploaded it and patched into the sysroots.json:
+    },
+    "bullseye_ppc64el": {
+        "Sha256Sum": "d2e359f5460d2a70fb938c91139b8022fe4d85475567baaa7864eb39073f4c5a",
+        "SysrootDir": "debian_bullseye_ppc64el-sysroot",
+        "Tarball": "debian_bullseye_ppc64el_sysroot.tar.xz",
+        "URL": "https://ibm.box.com/shared/static/n9n2zcuybktrgbtph6q6bsif02pkpfak.xz"
  • Same for libclang - I built & uploaded the libclang_rt.builtins and get them after checkout:
#Get libclang-rt for powerpc64le
pushd "${SOURCE}/third_party/llvm-build/Release+Asserts/lib/clang/20/lib/"
wget https://ibm.box.com/shared/static/7ez5z7vu75c0u2dno5t3anszwd2wrgdv.gz -O clang-rt-20-ppc.tar.gz
mkdir -p powerpc64le-unknown-linux-gnu
tar -xf clang-rt-20-ppc.tar.gz
rm -rf clang-rt-20-ppc.tar.gz
popd

Once all of this matured better I'm happy to provide a clean PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants