Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 756394 - media-libs/openjpeg-2.3.1-r1: broken include path in OpenJPEGConfig.cmake (was: app-text/poppler-20.11.0 compile fails with 'error: openjpeg.h: No such file or directory')
Summary: media-libs/openjpeg-2.3.1-r1: broken include path in OpenJPEGConfig.cmake (wa...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: No maintainer - Look at https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers if you want to take care of it
URL:
Whiteboard: fixed in 2.4.0
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-25 00:36 UTC by sharpshopter
Modified: 2021-01-02 21:35 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Full build log (app-text:poppler-20.11.0:20201124-203455.log,115.03 KB, text/x-log)
2020-11-25 00:37 UTC, sharpshopter
Details
openjpeg patch (fix-cmake-include-dir.patch,824 bytes, patch)
2020-12-09 20:16 UTC, sharpshopter
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sharpshopter 2020-11-25 00:36:34 UTC
app-text/poppler-20.11.0 compile fails with 'error: openjpeg.h: No such file or directory'

/usr/include/openjpeg-2.3/openjpeg.h exists.

Build logs show '-isystem /include/openjpeg-2.3' in the g++ calls rather than '-isystem /usr/include/openjpeg-2.3'

Reproducible: Always

Steps to Reproduce:
1.emerge -1 app-text/poppler
Actual Results:  
error: openjpeg.h: No such file or directory

Expected Results:  
Successful build

# ls /usr/include/openjpeg-2.3/
openjpeg.h  opj_config.h  opj_stdint.h



Snippet from build log:
FAILED: CMakeFiles/poppler.dir/poppler/JPEG2000Stream.cc.o 
/bin/x86_64-pc-linux-gnu-g++ -Dpoppler_EXPORTS -I/tmp/portage/app-text/poppler-20.11.0/work/poppler-20.11.0 -I/tmp/portage/app-text/poppler-20.11.0/work/poppler-20.11.0/fofi -I/tmp/portage/app-text/poppler-20.11.0/work/poppler-20.11.0/goo -I/tmp/portage/app-text/poppler-20.11.0/work/poppler-20.11.0/poppler -I. -Ipoppler -isystem /usr/include/freetype2 -isystem /include/openjpeg-2.3  -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wcast-align -Wformat-security -Wframe-larger-than=65536 -Wlogical-op -Wmissing-format-attribute -Wnon-virtual-dtor -Woverloaded-virtual -Wmissing-declarations -Wundef -Wzero-as-null-pointer-constant -Wshadow -Wsuggest-override -O2 -pipe -march=native -Wnon-virtual-dtor -Woverloaded-virtual -fPIC   -pthread -std=c++14 -MD -MT CMakeFiles/poppler.dir/poppler/JPEG2000Stream.cc.o -MF CMakeFiles/poppler.dir/poppler/JPEG2000Stream.cc.o.d -o CMakeFiles/poppler.dir/poppler/JPEG2000Stream.cc.o -c /tmp/portage/app-text/poppler-20.11.0/work/poppler-20.11.0/poppler/JPEG2000Stream.cc
/tmp/portage/app-text/poppler-20.11.0/work/poppler-20.11.0/poppler/JPEG2000Stream.cc:20:10: fatal error: openjpeg.h: No such file or directory
   20 | #include <openjpeg.h>
      |          ^~~~~~~~~~~~
compilation terminated.



# emerge --info '=app-text/poppler-20.11.0::gentoo'                   
Portage 3.0.9 (python 3.7.9-final-0, default/linux/amd64/17.1/desktop/plasma, gcc-9.3.0, glibc-2.32-r2, 5.4.72-gentoo x86_64)
=================================================================                               
                         System Settings                                                        
=================================================================
System uname: Linux-5.4.72-gentoo-x86_64-AMD_Ryzen_7_3700X_8-Core_Processor-with-gentoo-2.7     KiB Mem:    16422476 total,   2684928 free
KiB Swap:    8388604 total,   6293124 free
Timestamp of repository gentoo: Tue, 24 Nov 2020 19:45:02 +0000                                 Head commit of repository gentoo: 3dc9a5c12352360566a9678b07b7b8c35cb1a47e
sh bash 5.0_p18   
ld GNU ld (Gentoo 2.34 p6) 2.34.0
app-shells/bash:          5.0_p18::gentoo
dev-lang/perl:            5.30.3::gentoo
dev-lang/python:          2.7.18-r4::gentoo, 3.7.9::gentoo, 3.8.6::gentoo, 3.9.0::gentoo
dev-util/cmake:           3.17.4-r1::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.7::gentoo                                                           
sys-apps/openrc:          0.42.1::gentoo                                                        
sys-apps/sandbox:         2.20::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.2-r1::gentoo                                                     
sys-devel/binutils:       2.34-r2::gentoo
sys-devel/gcc:            9.3.0-r1::gentoo                                                      
sys-devel/gcc-config:     2.3.2-r1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.2.1-r4::gentoo                                                      
sys-kernel/linux-headers: 5.4-r1::gentoo (virtual/os-headers)                                   
sys-libs/glibc:           2.32-r2::gentoo
Repositories:                                                                                   
                                                                                                
gentoo
    location: /var/db/repos/gentoo                                                              
    sync-type: rsync                                                                            
    sync-uri: rsync://rsync.au.gentoo.org/gentoo-portage/                                       
    priority: -1000                                                                                 sync-rsync-verify-max-age: 24                                                               
    sync-rsync-verify-jobs: 1                                                                       sync-rsync-verify-metamanifest: yes                                                             sync-rsync-extra-opts:                                                                      
                                                                                                x-portage                                                                                           location: /usr/local/portage                                                                    masters: gentoo                                                                                 priority: 0                                                                                                                                                                                 
gridcoin                                                                                        
    location: /var/lib/layman/gridcoin
    masters: gentoo                                                                                 priority: 50                                                                                

personal                                                                                        
    location: /var/lib/layman/personal
    masters: gentoo                             
    priority: 50        
                                                
steam-overlay        
    location: /var/lib/layman/steam-overlay
    masters: gentoo                             
    priority: 50                                                                                
                                                                                                
ACCEPT_KEYWORDS="amd64"                         
ACCEPT_LICENSE="* -@EULA"     
CBUILD="x86_64-pc-linux-gnu" 
CFLAGS="-O2 -pipe -march=native"
CHOST="x86_64-pc-linux-gnu" 
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=native"                                                              
DISTDIR="/usr/local/portdist"                                                                   
EMERGE_DEFAULT_OPTS="-j4 --load-average=8"      
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_R
UNTIME_DIR"                                                                                     
FCFLAGS="-O2 -pipe"                             
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified
 distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news p
arallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"                             
FFLAGS="-O2 -pipe"                              
GENTOO_MIRRORS="http://ftp.iinet.net.au/pub/gentoo/ http://ftp.swin.edu.au/gentoo/ https://gentoo.osuosl.org/"                                                                                  
LANG="en_AU.UTF-8"
LDFLAGS="-Wl,--as-needed"        
LINGUAS="en_AU en en_US"                 
MAKEOPTS="-j16"                                 
PKGDIR="/var/cache/binpkgs"                                                                     
PORTAGE_CONFIGROOT="/"                          
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exc
lude=/local --exclude=/packages --exclude=/.git"                                                
PORTAGE_TMPDIR="/var/tmp"             
USE="X a52 aac acl acpi activities alsa amd64 apparmor berkdb branding bzip2 cairo cdda cdr cjk cli crypt cuda dbus declarative dri dts dvd dvdr elogind emboss encode exif ffmpeg flac fortran gdbm gif git glamor gpm gtk gui iconv icu ipv6 jpeg kde kipi kwallet lcms libglvnd libnotify libtirpc lm_sensors mad mng mp3 mp4 mpeg mplayer mtp multilib ncurses nls nptl nptlonly offensive ogg opencl opengl openmp opus pam pango pcre pcsc-lite pdf phonon plasma png policykit ppds pulseaudio python qml qt5 readline samba sdl seccomp speex spell sqlite ssl startup-notification svg tcpd theora threads tiff truetype udev udisks unicode usb vdpau vim vim-syntax vorbis wayland widgets wxwidgets x264 xattr xcb xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64 pc" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en-AU en-GB en en-US" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2 php7-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python2_7 python3_7" RUBY_TARGETS="ruby25 ruby26" USERLAND="GNU" VIDEO_CARDS="vesa nv nouveau nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"                         
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS



# emerge -pqv '=app-text/poppler-20.11.0::gentoo'
[ebuild  r  U ] app-text/poppler-20.11.0 [0.90.1] USE="cairo cjk cxx introspection jpeg jpeg2k lcms png qt5 tiff utils -curl -debug -doc -nss" 
[ebuild  rR   ] net-print/cups-filters-1.27.4  USE="dbus foomatic jpeg pdf png postscript tiff -ldap -pclm -perl -static-libs -test -zeroconf" 

The following packages are causing rebuilds:

  (app-text/poppler-20.11.0:0/104::gentoo, ebuild scheduled for merge) causes rebuilds for:
    (net-print/cups-filters-1.27.4:0/0::gentoo, ebuild scheduled for merge)



# equery f openjpeg
 * Searching for openjpeg ...
 * Contents of media-libs/openjpeg-2.3.1-r1:
/usr
/usr/bin
/usr/bin/opj_compress
/usr/bin/opj_decompress
/usr/bin/opj_dump
/usr/include
/usr/include/openjpeg-2.3
/usr/include/openjpeg-2.3/openjpeg.h
/usr/include/openjpeg-2.3/opj_config.h
/usr/include/openjpeg-2.3/opj_stdint.h
/usr/lib
/usr/lib/debug
/usr/lib/debug/usr
/usr/lib/debug/usr/bin
/usr/lib/debug/usr/bin/opj_compress.debug
/usr/lib/debug/usr/bin/opj_decompress.debug
/usr/lib/debug/usr/bin/opj_dump.debug
/usr/lib/debug/usr/lib64
/usr/lib/debug/usr/lib64/libopenjp2.so.2.3.1.debug
/usr/lib64
/usr/lib64/cmake
/usr/lib64/cmake/openjpeg-2.3
/usr/lib64/cmake/openjpeg-2.3/OpenJPEGConfig.cmake
/usr/lib64/cmake/openjpeg-2.3/OpenJPEGTargets-gentoo.cmake
/usr/lib64/cmake/openjpeg-2.3/OpenJPEGTargets.cmake
/usr/lib64/libopenjp2.so -> libopenjp2.so.7
/usr/lib64/libopenjp2.so.2.3.1
/usr/lib64/libopenjp2.so.7 -> libopenjp2.so.2.3.1
/usr/lib64/pkgconfig
/usr/lib64/pkgconfig/libopenjp2.pc
/usr/share
/usr/share/doc
/usr/share/doc/openjpeg-2.3.1-r1
/usr/share/doc/openjpeg-2.3.1-r1/AUTHORS.md.bz2
/usr/share/doc/openjpeg-2.3.1-r1/CHANGELOG.md.bz2
/usr/share/doc/openjpeg-2.3.1-r1/NEWS.md.bz2
/usr/share/doc/openjpeg-2.3.1-r1/README.md.bz2
/usr/share/doc/openjpeg-2.3.1-r1/THANKS.md.bz2
Comment 1 sharpshopter 2020-11-25 00:37:17 UTC
Created attachment 674788 [details]
Full build log
Comment 2 sharpshopter 2020-12-09 09:28:48 UTC
I looked into this a bit further.


$ cat /usr/lib64/pkgconfig/libopenjp2.pc 
prefix=/usr
bindir=${prefix}/bin
mandir=${prefix}//usr/share/man
docdir=${prefix}//usr/share/doc/openjpeg-2.3.1-r1
libdir=${prefix}/lib64
includedir=${prefix}/include/openjpeg-2.3

Name: openjp2
Description: JPEG2000 library (Part 1 and 2)
URL: http://www.openjpeg.org/
Version: 2.3.1
Libs: -L${libdir} -lopenjp2
Libs.private: -lm
Cflags: -I${includedir}



I don't know cmake well, but I can see the make call in configure has "-DENABLE_LIBOPENJPEG=openjpeg2", and the build.ninja file that results has all the incorrect (ie. no leading /usr) include paths for openjpeg.
Comment 3 sharpshopter 2020-12-09 10:11:24 UTC
Further I think I have traced in back to /lib64/cmake/openjpeg-2.3/OpenJPEGConfig.cmake not setting OPENJPEG_INCLUDE_DIRS correctly.

I think this is the relevant code, but my lack of cmake knowledge means I can't see anything wrong and don't know how to debug this.

get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
  # This is an install tree
  include(${SELF_DIR}/OpenJPEGTargets.cmake)

  # We find a relative path from the PKG directory to header files.
  set(PKG_DIR "/usr/lib64/cmake/openjpeg-2.3")
  set(INC_DIR "/usr/include/openjpeg-2.3")
  file(RELATIVE_PATH PKG_TO_INC_RPATH "${PKG_DIR}" "${INC_DIR}")

  get_filename_component(OPENJPEG_INCLUDE_DIRS "${SELF_DIR}/${PKG_TO_INC_RPATH}" ABSOLUTE)
Comment 4 sharpshopter 2020-12-09 10:20:58 UTC
So I worked out how to debug the cmake process, and get this in the output:

/usr/lib64/cmake/openjpeg-2.3/OpenJPEGConfig.cmake(35):  get_filename_component(OPENJPEG_INCLUDE_DIRS /usr/lib64/cmake/openjpeg-2.3/../../../include/openjpeg-2.3 ABSOLUTE )

So that was a red herring and OPENJPEG_INCLUDE_DIRS is actually correct.
Comment 5 sharpshopter 2020-12-09 10:42:25 UTC
So I ran the debugging again and caught the issue.

/lib64/cmake/openjpeg-2.3/OpenJPEGConfig.cmake(25):  get_filename_component(SELF_DIR /lib64/cmake/openjpeg-2.3/OpenJPEGConfig.cmake PATH )                                                      
/lib64/cmake/openjpeg-2.3/OpenJPEGConfig.cmake(26):  if(EXISTS /lib64/cmake/openjpeg-2.3/OpenJPEGTargets.cmake )                                                                                
/lib64/cmake/openjpeg-2.3/OpenJPEGConfig.cmake(28):  include(/lib64/cmake/openjpeg-2.3/OpenJPEGTargets.cmake )                                                                                  
/lib64/cmake/openjpeg-2.3/OpenJPEGConfig.cmake(31):  set(PKG_DIR /usr/lib64/cmake/openjpeg-2.3 )/lib64/cmake/openjpeg-2.3/OpenJPEGConfig.cmake(32):  set(INC_DIR /usr/include/openjpeg-2.3 )    /lib64/cmake/openjpeg-2.3/OpenJPEGConfig.cmake(33):  file(RELATIVE_PATH PKG_TO_INC_RPATH /usr/lib64/cmake/openjpeg-2.3 /usr/include/openjpeg-2.3 )                                              
/lib64/cmake/openjpeg-2.3/OpenJPEGConfig.cmake(35):  get_filename_component(OPENJPEG_INCLUDE_DIRS /lib64/cmake/openjpeg-2.3/../../../include/openjpeg-2.3 ABSOLUTE )

If this file is accessed via a symlink, this cmake file never canonicalises the SELF_DIR. It pretty much assumes it is /usr/lib64/cmake/openjpeg-2.3 and will produce weird results if that's not the case.

So to me this is starting to look like a bug with openjpeg.
Comment 6 sharpshopter 2020-12-09 10:47:02 UTC
Looks like there's an upstream issue open for this: https://github.com/uclouvain/openjpeg/issues/1174

I don't really know the process from here.
Comment 7 sharpshopter 2020-12-09 20:16:47 UTC
Created attachment 677497 [details, diff]
openjpeg patch

This patch against *openjpeg* fixes this issue for me. It touches lines near what openjpeg-2.3.1-gnuinstalldirs.patch touches too, so not sure if it should be wrapped into that patch and what portage rules on patch application order are (the patch I attached applies after the gnuinstalldirs one).
Comment 8 sharpshopter 2020-12-10 19:42:26 UTC
My fix got merged upstream.
Comment 9 Andreas Sturmlechner gentoo-dev 2021-01-02 21:35:58 UTC
Thanks for reporting upstream!