Skip to content

Commit

Permalink
Fix Linux backward compat issues w/ leptonica
Browse files Browse the repository at this point in the history
Never pull the GLIBC_2.22 version of fmemopen on Linux.
None of our ARM targets run anything that new.
Fix koreader#421

Note to mainteners: there's an updated patch for the upcoming leptonica
version, because the code got easier to deal with ;).
  • Loading branch information
NiLuJe committed May 16, 2016
1 parent aae908f commit 82511d5
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
3 changes: 3 additions & 0 deletions thirdparty/leptonica/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ include(ExternalProject)
ExternalProject_Add(
${PROJECT_NAME}
DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P ${GIT_CLONE_SCRIPT_FILENAME}
# Make sure we use the old fmemopen symbol on Linux when building against glibc >= 2.22 (c.f. base#421)
# NOTE: The patch will be much simpler w/ the upcoming leptonica version, there's a 1.74 version of the patch already in our tree for when that time comes ;)
PATCH_COMMAND patch -N -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/leptonica-1.72-fmemopen-compat-symbol.patch
CONFIGURE_COMMAND ""
# skip build and install, libk2pdfopt will build it
BUILD_COMMAND ""
Expand Down
60 changes: 60 additions & 0 deletions thirdparty/leptonica/leptonica-1.72-fmemopen-compat-symbol.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/src/bmpio.c b/src/bmpio.c
index e775dd2..68dc56c 100644
--- a/src/bmpio.c
+++ b/src/bmpio.c
@@ -554,6 +554,7 @@ RGBA_QUAD *pquad;
#endif /* HAVE_CONFIG_H */

#if HAVE_FMEMOPEN
+__asm__(".symver fmemopen,fmemopen@GLIBC_2.2.5");
extern FILE *open_memstream(char **data, size_t *size);
extern FILE *fmemopen(void *data, size_t size, const char *mode);
#endif /* HAVE_FMEMOPEN */
diff --git a/src/jp2kio.c b/src/jp2kio.c
index 9eb88d1..105b160 100644
--- a/src/jp2kio.c
+++ b/src/jp2kio.c
@@ -743,6 +743,7 @@ opj_image_cmptparm_t cmptparm[4];
* Read/write to memory *
*---------------------------------------------------------------------*/
#if HAVE_FMEMOPEN
+__asm__(".symver fmemopen,fmemopen@GLIBC_2.2.5");
extern FILE *open_memstream(char **data, size_t *size);
extern FILE *fmemopen(void *data, size_t size, const char *mode);
#endif /* HAVE_FMEMOPEN */
diff --git a/src/jpegio.c b/src/jpegio.c
index 06185da..ddc4a3c 100644
--- a/src/jpegio.c
+++ b/src/jpegio.c
@@ -939,6 +939,7 @@ jmp_buf jmpbuf; /* must be local to the function */
* Read/write to memory *
*---------------------------------------------------------------------*/
#if HAVE_FMEMOPEN
+__asm__(".symver fmemopen,fmemopen@GLIBC_2.2.5");
extern FILE *open_memstream(char **data, size_t *size);
extern FILE *fmemopen(void *data, size_t size, const char *mode);
#endif /* HAVE_FMEMOPEN */
diff --git a/src/pngio.c b/src/pngio.c
index 19f6c55..79b7ed3 100644
--- a/src/pngio.c
+++ b/src/pngio.c
@@ -1252,6 +1252,7 @@ l_pngSetReadStrip16To8(l_int32 flag)
* Read/write to memory *
*---------------------------------------------------------------------*/
#if HAVE_FMEMOPEN
+__asm__(".symver fmemopen,fmemopen@GLIBC_2.2.5");
extern FILE *open_memstream(char **data, size_t *size);
extern FILE *fmemopen(void *data, size_t size, const char *mode);
#endif /* HAVE_FMEMOPEN */
diff --git a/src/pnmio.c b/src/pnmio.c
index 3b4b931..00b4e47 100644
--- a/src/pnmio.c
+++ b/src/pnmio.c
@@ -601,6 +601,7 @@ PIX *pixs;
#endif /* HAVE_CONFIG_H */

#if HAVE_FMEMOPEN
+__asm__(".symver fmemopen,fmemopen@GLIBC_2.2.5");
extern FILE *open_memstream(char **data, size_t *size);
extern FILE *fmemopen(void *data, size_t size, const char *mode);
#endif /* HAVE_FMEMOPEN */
12 changes: 12 additions & 0 deletions thirdparty/leptonica/leptonica-1.74-fmemopen-compat-symbol.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/utils.c b/src/utils.c
index 76e7d43..9da46b0 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1912,6 +1912,7 @@ FILE *fp;
return (FILE *)ERROR_PTR("data not defined", procName, NULL);

#if HAVE_FMEMOPEN
+ __asm__(".symver fmemopen,fmemopen@GLIBC_2.2.5");
if ((fp = fmemopen((void *)data, size, "rb")) == NULL)
return (FILE *)ERROR_PTR("stream not opened", procName, NULL);
#else /* write to tmp file */

0 comments on commit 82511d5

Please sign in to comment.