Changeset 32256

Show
Ignore:
Timestamp:
11.07.2018 17:46:20 (5 months ago)
Author:
sjm84
Message:

Changes to get xpdftools compiled up on the 32 bit linux LSB, since 32 bit xpdftools binaries is what we hope to use on both 32 and 64 bit machines.

Location:
gs2-extensions/xpdf-tools/trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gs2-extensions/xpdf-tools/trunk/src/GS-README.txt

    r32255 r32256  
    128128 
    129129 
    130 2. To compile Xpdf-Tools dynamically and make it find *our* dynamically linked libraries for its helper packages zlib, libpng and freetype, edit packages/CASCADE-MAKE/XPDFTOOLS.sh to contain: 
     1302. To compile Xpdf-Tools dynamically and make it find *our* dynamically linked libraries for its helper packages zlib, libpng, libjpeg and freetype, edit packages/CASCADE-MAKE/XPDFTOOLS.sh to contain: 
    131131 
    132132    cmake -DCMAKE_BUILD_TYPE=Release \ 
     
    134134        -DZLIB_LIBRARY=$prefix/lib/libz.so.1.2.7 \          # <========= THIS 
    135135        -DPNG_LIBRARY=$prefix/lib/libpng15.so.15.30.0 \     # <========= THIS 
     136        -DJPEG_LIBRARY=$prefix/lib/libjpeg.so.PUT_THE_NUMBER_HERE \ # <========= THIS AND ENTER THE .SO VERSION NUMBER 
    136137        -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.so.6.3.20 \  # <========= THIS 
    137138        -DCMAKE_DISABLE_FIND_PACKAGE_Qt4=1 \ 
     
    207208Since we're compiling up freetype, libpng and zlib packages as part of the Xpdf-Tools GS2-extension with CASCADE-MAKE, the next step was to compile xpdf-tools by dynamically linking against our .so files for these 3 libraries. To do so, XPDFTOOL.sh should have the following changes 
    208209 
    209     (1) set up CFLAGS, CXXFLAGS, CPPFLAGS and LDFLAGS to help linkage of xpdf-tools find our .so versions of the necessary libs: 
     210      (1) For linux, we need to build on the LSB environment. 
     211      We're moreover hoping that 32 bit binaries generated this way will work on both 32 and 64 bit machines. 
     212 
     213      However, on the 32 bit LSB environment, we additionally need to pass in "-march=i486|i586|i686" to gcc 
     214      Without it, things end up with the error 
     215          undefined reference to `__sync_add_and_fetch_4' 
     216      See https://stackoverflow.com/questions/130740/link-error-when-compiling-gcc-atomic-operation-in-32-bit-mode 
     217      which further explains that 
     218          "-march=" means "generate code for a particular CPU (and don't run on older CPUs)". 
     219      So, although uname -m returns i686 on the 32 bit linux VM that generates the nightly bins, we 
     220      still want to support i586 and i486 systems, so passing that in as the architecture 
     221      Don't do this for 64 bit systems. 
     222      And it seems it only needs to be set on CXXFLAGS in this case. 
     223 
     224          arch=`uname -m` 
     225      if [[ $arch = *"64"* ]]; then 
     226             arch= 
     227      else 
     228          echo "@@@ 32 bit machine, need to pass in -march=i486 to avoid certain linking errors" 
     229          arch="-march=i486" 
     230      fi 
     231      ... 
     232      export CXXFLAGS="$CXXFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15 $arch" 
     233 
     234    (2) set up CFLAGS, CXXFLAGS, CPPFLAGS and LDFLAGS to help linkage of xpdf-tools find our .so versions of the necessary libs: 
    210235 
    211236    export CFLAGS="$CFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15" 
    212237    export CPPFLAGS="$CPPFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15" 
    213     export CXXFLAGS="$CXXFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15" 
     238    export CXXFLAGS="$CXXFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15 $arch" 
    214239    export LDFLAGS="$LDFLAGS -L$GEXTXPDFTOOLS_INSTALLED/lib" 
    215240 
    216     (2) The CMAKE command we run must pass the full paths to the actual .so library files (the ones with specific 
     241    (3) The CMAKE command we run must pass the full paths to the actual .so library files (the ones with specific 
    217242    versions in their files names) rather than the symbolically linked generally-named .so files (the latter won't 
    218243    be found when building xpdf-tools and CMake will try to look for the .so library files elsewhere on the system): 
     
    239264 
    240265 
    241     (3) Since CMakeLists.txt has been modified, we initially renamed the xpdf src tarball to gs-xpdf-4.00.tar.gz. 
     266    (4) Since CMakeLists.txt has been modified, we initially renamed the xpdf src tarball to gs-xpdf-4.00.tar.gz. 
    242267    However, the current version works with the regular downloaded xpdf-4.00.tar.gz tarball. But after extraction, 
    243268    XPDFTOOLS.sh copies across the custom packages/gs-CMakeLists.txt into the extracted tarball's xpdf subdirectory, 
     
    362387Initial attempts at modifying gs-CMakeLists.txt for static compiling that proved to be unnecessary: 
    363388 
    364     (1) Setting -static globally doesn't have a useful effect. 
     389    (i) Setting -static globally doesn't have a useful effect. 
    365390 
    366391    # We want to build static xpdf-tools binaries. See 
     
    381406---- 
    382407 
    383     (2) Threads::Threads instead of -lpthread results in a partially dynamic executable. 
     408    (ii) Threads::Threads instead of -lpthread results in a partially dynamic executable. 
    384409 
    385410    # The original, unmodified CMakeLists.txt was not set up sufficiently 
     
    404429 
    405430 
    406 (5) To view the unmodified CMakeLists.txt included in the xpdf-4.00 source code tarball, untar it and look for its "xpdf/CMakeLists.txt" (not the toplevel file of the same name). 
     4315. To view the unmodified CMakeLists.txt included in the xpdf-4.00 source code tarball, untar it and look for its "xpdf/CMakeLists.txt" (not the toplevel file of the same name). 
    407432Run a 'diff' against gs-CMakeLists.txt to see further differences, such as debug statements and comments. Most comments have been removed and placed into this readme file instead. 
    408433 
    409434 
    410 (6) When CASCADE-MAKE is run on the xpdf-tools GS2-extension, it first compiles up CMake, needed to compile up xpdf-tools. 
     4356. When CASCADE-MAKE is run on the xpdf-tools GS2-extension, it first compiles up CMake, needed to compile up xpdf-tools. 
    411436Unlike the library packages like freetype, libpng and zlib that we also build for xpdf-tools as part of this gs2-extension, CMake's build products don't need to be included in the distribution tarball of our built xpdf-tools executables. 
    412437 
  • gs2-extensions/xpdf-tools/trunk/src/packages/CASCADE-MAKE/XPDFTOOLS.sh

    r32249 r32256  
    1212prefix=$GEXTXPDFTOOLS_INSTALLED 
    1313 
     14# When trying to compile xpdf-tools on a 32 bit linux LSB, we get the error 
     15# "undefined reference to `__sync_add_and_fetch_4'" unless we follow the instructions at 
     16# https://stackoverflow.com/questions/130740/link-error-when-compiling-gcc-atomic-operation-in-32-bit-mode 
     17# and append to CXXFLAGS "-march=i486", which is the earliest architecture for which compilation 
     18# succeeds and the xpdftool binaries produced work (even though our 32 bit LSB is i686). 
     19arch=`uname -m` 
     20if [[ $arch = *"64"* ]]; then 
     21    arch= 
     22else 
     23    echo "@@@ 32 bit unix, passing in -march=i486 to avoid certain linking errors" 
     24    arch="-march=i486" 
     25fi 
     26 
    1427# Use C/CPP/CXX FLAGS and LDFLAGS for further setting up 
    1528# libpng and libz for compiling xpdftools 
    1629export CFLAGS="$CFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15" 
    1730export CPPFLAGS="$CPPFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15" 
    18 export CXXFLAGS="$CXXFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15" 
     31export CXXFLAGS="$CXXFLAGS -I$GEXTXPDFTOOLS_INSTALLED/include -I$GEXTXPDFTOOLS_INSTALLED/include/libpng15 $arch" 
    1932export LDFLAGS="$LDFLAGS -L$GEXTXPDFTOOLS_INSTALLED/lib" 
    2033 
     
    114127 
    115128## For building dynamic xpdf-tools executables, change the above to have the following instead 
    116 ## (still unable get the .so for LIBJPEG generated, so could try JPEG_LIBRARY set same as above) 
     129## The .so for LIBJPEG gets generated for libjpeg version 9c (but not 6b). Correct the .so version number below. 
    117130#       -DZLIB_LIBRARY=$prefix/lib/libz.so.1.2.7 \ 
    118131#       -DTIFF_LIBRARY=$prefix/lib/libtiff.so.5.2.2 \ 
    119132#       -DPNG_LIBRARY=$prefix/lib/libpng15.so.15.30.0 \ 
     133#       -DJPEG_LIBRARY=$prefix/lib/libjpeg.so.PUT_THE_NUMBER_HERE \ 
    120134#       -DFREETYPE_LIBRARY=$prefix/lib/libfreetype.so.6.3.20 \ 
    121135# (The 3rd line can alternatively be "-DFREETYPE_DIR=$prefix")