Poppler fails to build due to missing stdio.h include for libjpeg
When building Poppler with upstream LLVM hash 14f0776550b5a49e1c42f49a00213f7f3fa047bf
, jpeglib.h
is unable to be built.
To quote our logs for building ChromeOS
/usr/bin/x86_64-cros-linux-gnu-clang++ -Dpoppler_EXPORTS -I/build/amd64-generic/tmp/portage/app-text/poppler-23.01.0/work/poppler-23.01.0 -I/build/amd64-generic/tmp/portage/app-text/poppler-23.01.0/work/poppler-23.01.0/fofi -I/build/amd64-generic/tmp/portage/app-text/poppler-23.01.0/work/poppler-23.01.0/goo -I/build/amd64-generic/tmp/portage/app-text/poppler-23.01.0/work/poppler-23.01.0/poppler -I. -Ipoppler -isystem /build/amd64-generic/usr/include/openjpeg-2.3 -isystem /build/amd64-generic/usr/include/freetype2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Os -pipe -march=x86-64 -msse3 -g -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -ffunction-sections -fdata-sections -Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -std=c++17 -MD -MT CMakeFiles/poppler.dir/poppler/ImageEmbeddingUtils.cc.o -MF CMakeFiles/poppler.dir/poppler/ImageEmbeddingUtils.cc.o.d -o CMakeFiles/poppler.dir/poppler/ImageEmbeddingUtils.cc.o -c /build/amd64-generic/tmp/portage/app-text/poppler-23.01.0/work/poppler-23.01.0/poppler/ImageEmbeddingUtils.cc
In file included from /build/amd64-generic/tmp/portage/app-text/poppler-23.01.0/work/poppler-23.01.0/poppler/ImageEmbeddingUtils.cc:18:
/build/amd64-generic/usr/include/jpeglib.h:916:52: error: unknown type name 'FILE'
EXTERN(void) jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile);
^
/build/amd64-generic/usr/include/jpeglib.h:917:53: error: unknown type name 'FILE'
EXTERN(void) jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile);
This is because Poppler is missing a preceding include to stdio.h. Likely FILE
was provided by some transitive dependencies in LLVM prior to this hash, so it just happened to work. However, this is no longer the case.
To quote the relevant section of the libjpeg README:
Mechanics of usage: include files, linking, etc
-----------------------------------------------
Applications using the JPEG library should include the header file jpeglib.h
to obtain declarations of data types and routines. Before including
jpeglib.h, include system headers that define at least the typedefs FILE and
size_t. On ANSI-conforming systems, including <stdio.h> is sufficient; on
older Unix systems, you may need <sys/types.h> to define size_t.
If the application needs to refer to individual JPEG library error codes, also
include jerror.h to define those symbols.
And similar discussion on the libjpeg-turbo
github: https://github.com/libjpeg-turbo/libjpeg-turbo/issues/17
I'll make a merge request to fix the issue.
Mirror of this public bug report in ChromeOS: https://b.corp.google.com/issues/282219721