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

Problems to solve to be perfect #1

Closed
paulocoutinhox opened this issue May 24, 2018 · 34 comments
Closed

Problems to solve to be perfect #1

paulocoutinhox opened this issue May 24, 2018 · 34 comments

Comments

@paulocoutinhox
Copy link
Owner

paulocoutinhox commented May 24, 2018

Hi,

I finished my script to build the PDFium to iOS. All is here with manual patchs:
https://github.com/prsolucoes/mobile-pdfium

It generate files:

- libpdfium_arm.a
- libpdfium_arm64.a
- libpdfium_x64.a
- libpdfium_x86.a
- libpdfium.a (universal)

FIRST PROBLEM

The problem is that i join all ".a" files on each library and each library have +/- 200MB and the universal near 1GB of size.

I want understand what libraries i need merge with libtool, i have this:

- pdfium/out/debug-arm/obj/libfpdfdoc.a
- pdfium/out/debug-arm/obj/libfxge.a
- pdfium/out/debug-arm/obj/libpdfium.a
- pdfium/out/debug-arm/obj/libfdrm.a
- pdfium/out/debug-arm/obj/libformfiller.a
- pdfium/out/debug-arm/obj/third_party/libjpeg_turbo/libsimd.a
- pdfium/out/debug-arm/obj/third_party/libjpeg_turbo/libjpeg.a
- pdfium/out/debug-arm/obj/third_party/libfx_agg.a
- pdfium/out/debug-arm/obj/third_party/zlib/libzlib_x86_simd.a
- pdfium/out/debug-arm/obj/third_party/zlib/libchrome_zlib.a
- pdfium/out/debug-arm/obj/third_party/libbigint.a
- pdfium/out/debug-arm/obj/third_party/libfx_freetype.a
- pdfium/out/debug-arm/obj/third_party/libfx_libopenjpeg.a
- pdfium/out/debug-arm/obj/third_party/libfx_lcms2.a
- pdfium/out/debug-arm/obj/third_party/icu/libicuuc.a
- pdfium/out/debug-arm/obj/libpwl.a
- pdfium/out/debug-arm/obj/libfpdftext.a
- pdfium/out/debug-arm/obj/libfpdfapi.a
- pdfium/out/debug-arm/obj/libfxcrt.a
- pdfium/out/debug-arm/obj/libfxcodec.a
- pdfium/out/debug-arm/obj/libfxjs.a

Today im merging all for each library and each arch and the library is with a huge file size.

SECOND PROBLEM

The libraries are compile always with iOS 10 and xcode give me 402 warning about it:

ld: warning: object file (/Users/paulo/Downloads/UXReader-iOS/UXReader/UXReader/PDFium/libpdfium.a(cpdf_formcontrol.o)) was built for newer iOS version (10.0) than being linked (8.0)

My project need be for iOS 8.0, but the libraries are compile with iOS 10.

How to solve it?

THIRD PROBLEM

I merge and link with all libraries (.a), but when i use with a sample project i still have some functions not linked inside the library ".a":

screenshot 2018-05-24 01 49 12

FOURTY PROBLEM

How to build with bitcode support? How to enable and disable it?

FINISH

Can anyone help me with this problems?

Thanks.

@raghuwanshi
Copy link
Contributor

Thank you for saving my time by providing this script. I am still working on this project but let me share the solution to your first problem. You can use these args:

is_debug=false
symbol_level=0

Please see the symbol_level documentation for further details. Although my need to build PDFium on iOS is for a different purpose and due to that I have some other issues rather than what you have mentioned here, I will see if can find any solution for them.

@paulocoutinhox
Copy link
Owner Author

paulocoutinhox commented Jul 31, 2018

Ok. I will test it now. It is args for gen or for ninja call? Im trying for gen now.

@paulocoutinhox
Copy link
Owner Author

The flag "is_debug" i already use.

image

@paulocoutinhox
Copy link
Owner Author

My first problem is about merge all that libraries. The file size is too big.

raghuwanshi added a commit to raghuwanshi/mobile-pdfium that referenced this issue Aug 1, 2018
This is to fix the issued mentioned in the following issue as the first problem:

paulocoutinhox#1

With this change I am able to achieve a 38 Mb universal .a file rather than a gigabyte file.
@raghuwanshi
Copy link
Contributor

I hope that suggested change has also reduced the files sizes for you.

@hhartz
Copy link

hhartz commented Aug 17, 2018

@raghuwanshi maybe make a pull request?

@raghuwanshi
Copy link
Contributor

@hhartz I was able to fix the third problem too. Besides that I think I can automate those manual patching steps too. I am busy with something else right now. I will commit all I can do once I get some free time.

@chml
Copy link

chml commented Aug 28, 2018

THIRD PROBLEM

I merge and link with all libraries (.a), but when i use with a sample project i still have some functions not linked inside the library ".a":

Try change file third_party/BUILD.gn line 539 jumbo_source_set("pdfium_base") { to static_library("pdfium_base") {, to get the libpdfium_base.a.

@raghuwanshi
Copy link
Contributor

@chml I tried that but that did not fix all errors. Then I found the real solution. I will commit that and make a pull request.

@hhartz
Copy link

hhartz commented Aug 29, 2018

I use the following patch file, which also removes the need for the whole chromium checkout (as it doesn't build the iossim test); http://ix.io/1lvz

raghuwanshi added a commit to raghuwanshi/mobile-pdfium that referenced this issue Aug 29, 2018
This is to fix the issued mentioned in the following issue as the first and third problem:

paulocoutinhox#1

With this change I am able to achieve a 38 Mb universal .a file rather than a gigabyte file.
Linker errors; which were thrown during build of application using this library; are also fixed.

Other two problems mentioned in the issue are not related to the project I am working on. I will not be able to work on them.
@hhartz
Copy link

hhartz commented Aug 29, 2018

@raghuwanshi did you manage to get arm to build with neon? I'm getting missing symbols

@raghuwanshi
Copy link
Contributor

@hhartz I am using it for Xamarin.iOS. I was able to build my application for all four platforms i.e. ARM, ARM64, x86 and x64

@hhartz
Copy link

hhartz commented Aug 29, 2018

@raghuwanshi I'm getting linker issues for armv7, can you confirm your app builds when archiving, and that you have armv7 as one of the architectures?

  "_jsimd_ycc_extrgb_convert_neon", referenced from:
      _jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_jsimd_ycc_extrgbx_convert_neon", referenced from:
      l_switch.table.jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_jsimd_ycc_extxbgr_convert_neon", referenced from:
      l_switch.table.jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_jsimd_idct_ifast_neon", referenced from:
      _jsimd_idct_ifast in libpdfium.a(jsimd_arm.o)
  "_jsimd_idct_2x2_neon", referenced from:
      _jsimd_idct_2x2 in libpdfium.a(jsimd_arm.o)
  "_jsimd_h2v1_fancy_upsample_neon", referenced from:
      _jsimd_h2v1_fancy_upsample in libpdfium.a(jsimd_arm.o)
  "_jsimd_ycc_extbgrx_convert_neon", referenced from:
      l_switch.table.jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_jsimd_ycc_extxrgb_convert_neon", referenced from:
      l_switch.table.jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_jsimd_idct_islow_neon", referenced from:
      _jsimd_idct_islow in libpdfium.a(jsimd_arm.o)
  "_jsimd_idct_4x4_neon", referenced from:
      _jsimd_idct_4x4 in libpdfium.a(jsimd_arm.o)
  "_jsimd_ycc_extbgr_convert_neon", referenced from:
      l_switch.table.jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_jsimd_ycc_rgb565_convert_neon", referenced from:
      _jsimd_ycc_rgb565_convert in libpdfium.a(jsimd_arm.o)
ld: symbol(s) not found for architecture armv7```

@paulocoutinhox
Copy link
Owner Author

paulocoutinhox commented Aug 29, 2018

I merged the pull request, but im still getting errors:

image

Generated PDFium release:
https://www.dropbox.com/s/7fvj5n8ryv00xpb/pdfium-release.zip?dl=1

Sample project:
https://github.com/vfr/UXReader-iOS

** replace "libpdfium.a" from project to lib inside "pdfium-release.zip".

And have a lot of warnings about iOS version different from the used version for .a library.

@chml
Copy link

chml commented Aug 30, 2018

Add all these .a files, then it works
image

@paulocoutinhox
Copy link
Owner Author

But all .a files is inside the main .a file. They are merged.

@paulocoutinhox
Copy link
Owner Author

The problems in related to arm64. It is running fine on simulator. I think that zlib or something is not compiling to arm64.

@paulocoutinhox
Copy link
Owner Author

ARMv7:

Undefined symbols for architecture armv7:
  "_jsimd_ycc_extrgb_convert_neon", referenced from:
      _jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_jsimd_ycc_extbgr_convert_neon", referenced from:
      l_switch.table.jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_jsimd_ycc_extbgrx_convert_neon", referenced from:
      l_switch.table.jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_jsimd_ycc_extxrgb_convert_neon", referenced from:
      l_switch.table.jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_Cr_z_inflateInit_", referenced from:
      (anonymous namespace)::FlateInit() in libpdfium.a(fx_codec_flate.o)
  "_jsimd_idct_islow_neon", referenced from:
      _jsimd_idct_islow in libpdfium.a(jsimd_arm.o)
  "_jsimd_idct_4x4_neon", referenced from:
      _jsimd_idct_4x4 in libpdfium.a(jsimd_arm.o)
  "_jsimd_idct_2x2_neon", referenced from:
      _jsimd_idct_2x2 in libpdfium.a(jsimd_arm.o)
  "_jsimd_h2v1_fancy_upsample_neon", referenced from:
      _jsimd_h2v1_fancy_upsample in libpdfium.a(jsimd_arm.o)
  "_jsimd_idct_ifast_neon", referenced from:
      _jsimd_idct_ifast in libpdfium.a(jsimd_arm.o)
  "_Cr_z_inflate", referenced from:
      (anonymous namespace)::FlateOutput(void*, unsigned char*, unsigned int) in libpdfium.a(fx_codec_flate.o)
  "_jsimd_ycc_rgb565_convert_neon", referenced from:
      _jsimd_ycc_rgb565_convert in libpdfium.a(jsimd_arm.o)
  "_jsimd_ycc_extrgbx_convert_neon", referenced from:
      l_switch.table.jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_jsimd_ycc_extxbgr_convert_neon", referenced from:
      l_switch.table.jsimd_ycc_rgb_convert in libpdfium.a(jsimd_arm.o)
  "_Cr_z_inflateEnd", referenced from:
      (anonymous namespace)::FlateEnd(void*) in libpdfium.a(fx_codec_flate.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

ARM64:

Undefined symbols for architecture arm64:
  "_Cr_z_inflate", referenced from:
      (anonymous namespace)::FlateOutput(void*, unsigned char*, unsigned int) in libpdfium.a(fx_codec_flate.o)
  "_Cr_z_inflateEnd", referenced from:
      (anonymous namespace)::FlateEnd(void*) in libpdfium.a(fx_codec_flate.o)
  "_Cr_z_inflateInit_", referenced from:
      (anonymous namespace)::FlateInit() in libpdfium.a(fx_codec_flate.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@Changzw
Copy link

Changzw commented Sep 13, 2018

libpdfium.a

Architectures in the fat file: ./libpdfium.a are: armv7 i386 x86_64 arm64
P.S. for simulator, you should add libz.tbd to your target.

platform:iOS 8.

pdfium commit hash: a38996be8

@hhartz
Copy link

hhartz commented Sep 13, 2018

I managed to get it building + running myself, by reverting the change that use libjpeg_turbo instead of libjpeg. @Changzw can you confirm it actually compiles if you archive a target which has armv7? in my experience it will fail due to having some specific SIMD symbols missing, even if file libpdfium.a tells you there is an armv7 segment

@Changzw
Copy link

Changzw commented Sep 14, 2018

I don't have armv7 devices and test armv7, but this lib can be archived.
if libpdfium.a don't include armv7, the compiler will report error

@paulocoutinhox
Copy link
Owner Author

@Changzw Put here what config you use to:

1 - Change the iOS version that library was built
2 - Include simd/z things that error happen.

Thanks.

@hhartz
Copy link

hhartz commented Sep 18, 2018

@prsolucoes In this branch you'll see instructions for how to build pdfium with working armv7. I took the liberty of copying your make.py (with attribution in the commit), and have a set of changes/reverts to make it work all outlined in the README.md. Basically it reverts the use of libjpeg_turbo to libjpeg. An improvement would be to only use that for arm and let it use libjpeg_turbo for other architectures, which I haven't gotten around to (yet). I played around with settings various compiler flags as mentioned in various threads, as well as adding gas-preprocessor.pl to PATH without any luck. Not a lasting solution, but it's the hammer that solves my issue at the moment :) The compiled binary can be fetched in iosprecompiled/ with git lfs fetch && git lfs update

@Changzw
Copy link

Changzw commented Nov 2, 2018

if you archive a target which has armv7?

I did it. use this link to download .a
#1 (comment)

@hhartz
Copy link

hhartz commented Nov 2, 2018

@Changzw As described in my earlier comments, I already have a working setup. Also, you should probably provide a build config instead, as people should have full control over the code they release to their customers.

@paulocoutinhox
Copy link
Owner Author

@hhartz Can you help me modify my script to build all with success? I want leave this repository as a reference to everyone that need it. After i will do the same for Android.

@Changzw
Copy link

Changzw commented Nov 8, 2018

it is a very huge project :( ! I not only change source code depended by pdfium, but also update UXReader code to support latest pdfium version and pdfium building config .

Sorry, I don't have enough time to do this.

@peddamat
Copy link

peddamat commented Nov 27, 2018

@Changzw I am unable to download the file from #1 (comment). Unfortunately, I do not read Chinese, and attempting to translate the page using Google Translate results in a 404. : ( Is there an alternative place that you can post it?

@Changzw
Copy link

Changzw commented Nov 30, 2018

@Changzw I am unable to download the file from #1 (comment). Unfortunately, I do not read Chinese, and attempting to translate the page using Google Translate results in a 404. : ( Is there an alternative place that you can post it?

try this.
All is bitcode version.

@peddamat
Copy link

peddamat commented Dec 1, 2018

@Changzw Thank you so much, I will report back with my results.

@paulocoutinhox
Copy link
Owner Author

Hi,

I solved all problems. It is working now. Check travis and new README file for instructions.

I something can be better, please report.

Thanks.

@paulocoutinhox
Copy link
Owner Author

Maybe someone could help here:
#4

@paulocoutinhox
Copy link
Owner Author

The main problem is here:
image

@paulocoutinhox
Copy link
Owner Author

Hi,

Problems solved. I have reimplemented read string methods from two files to solve memory bugs:

Now it is working very well on all devices.

Thanks.

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

6 participants