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

Does a spack-built pkg-config work with external packages? #48293

Open
3 tasks done
climbfuji opened this issue Dec 26, 2024 · 1 comment
Open
3 tasks done

Does a spack-built pkg-config work with external packages? #48293

climbfuji opened this issue Dec 26, 2024 · 1 comment
Labels
bug Something isn't working triage The issue needs to be prioritized

Comments

@climbfuji
Copy link
Contributor

Steps to reproduce

I am logging this as a "bug" and not a "build error", because it looks like a conceptual problem and not a build error tied to a specific package. However, I can best describe this with a specific example:

Package freetype depends on libpng, which itself depends on zlib-api. freetype uses pkg-config to find libpng in the (default) autotools build. pkg-config on my system is built by spack, zlib-api is provided by the OS libz in /usr, and libpng is built by spack. The freetype build fails with:

     134    checking /p/app/projects/NEPTUNE/spack-stack/spack-stack-dev-20241220/spack/lib/spack/env/intel/icc compiler flag -pedantic to assure ANSI C99 works correctly... ok, adding to XX_ANSIFLAGS
     135    checking /p/app/projects/NEPTUNE/spack-stack/spack-stack-dev-20241220/spack/lib/spack/env/intel/icc compiler flag -std=c99 to assure ANSI C99 works correctly... ok, adding to XX_ANSIFLAGS
     136    checking for -fvisibility=hidden compiler flag... yes
     137    checking for BZIP2... yes
     138    checking for LIBPNG... no
     139    checking for libpng-config... no
  >> 140    configure: error: libpng support requested but library not found

With some digging, this is because of:

> cat /p/app/projects/NEPTUNE/spack-stack/spack-stack-dev-20241220/cache/build_stage/heinzell/spack-stage-freetype-2.13.2-rmiuppfxo5jswfbvwfzyj2cvwunak6t3/spack-src/builds/unix/config.log
...
configure:14272: $PKG_CONFIG --exists --print-errors "$libpng_pkg"
Package zlib was not found in the pkg-config search path.
Perhaps you should add the directory containing `zlib.pc'
to the PKG_CONFIG_PATH environment variable
Package 'zlib', required by 'libpng', not found
configure:14275: $? = 1
configure:14282: checking for LIBPNG
configure:14289: $PKG_CONFIG --exists --print-errors "$libpng_pkg"
Package zlib was not found in the pkg-config search path.
Perhaps you should add the directory containing `zlib.pc'
to the PKG_CONFIG_PATH environment variable
Package 'zlib', required by 'libpng', not found
configure:14292: $? = 1
configure:14306: $PKG_CONFIG --exists --print-errors "$libpng_pkg"
Package zlib was not found in the pkg-config search path.
Perhaps you should add the directory containing `zlib.pc'
to the PKG_CONFIG_PATH environment variable
Package 'zlib', required by 'libpng', not found
configure:14309: $? = 1
configure:14323: result: no
Package 'zlib', required by 'libpng', not found
configure:14369: checking for libpng-config
configure:14402: result: no
configure:14421: error: libpng support requested but library not found

Error message

The error is shown above. Since pkg-config is built by spack, the default=OS PKG_CONFIG_PATH is not /usr etc. But because zlib is an external package in /usr, and presumably because spack does not add OS paths to the spack build environments, zlib.pc isn't found (it exists in /usr/lib64/pkgconfig/zlib.pc).

I can fix this for freetype by setting environment variables that configure knows about that override pkg-config, but I imagine that this situation isn't unique to freetype and that a more general solution is preferred:

  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  PKG_CONFIG  path to pkg-config utility
  PKG_CONFIG_PATH
              directories to add to pkg-config's search path
  PKG_CONFIG_LIBDIR
              path overriding pkg-config's built-in search path
  LT_SYS_LIBRARY_PATH
              User-defined run-time library search path.
  ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config
  ZLIB_LIBS   linker flags for ZLIB, overriding pkg-config
  BZIP2_CFLAGS
              C compiler flags for BZIP2, overriding pkg-config
  BZIP2_LIBS  linker flags for BZIP2, overriding pkg-config
  LIBPNG_CFLAGS
              C compiler flags for LIBPNG, overriding pkg-config
  LIBPNG_LIBS linker flags for LIBPNG, overriding pkg-config
  HARFBUZZ_CFLAGS
              C compiler flags for HARFBUZZ, overriding pkg-config
  HARFBUZZ_LIBS
              linker flags for HARFBUZZ, overriding pkg-config
  BROTLI_CFLAGS
              C compiler flags for BROTLI, overriding pkg-config
  BROTLI_LIBS linker flags for BROTLI, overriding pkg-config
  LIBRSVG_CFLAGS
              C compiler flags for LIBRSVG, overriding pkg-config
  LIBRSVG_LIBS
              linker flags for LIBRSVG, overriding pkg-config

Information on your system

* **Spack:** 0.23.0 (c0dc3572e4ce215ab4810ef22ea6082eba07e4ef)
* **Python:** 3.6.8
* **Platform:** linux-rhel8-zen3

General information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output
@climbfuji climbfuji added bug Something isn't working triage The issue needs to be prioritized labels Dec 26, 2024
@climbfuji climbfuji changed the title Does a spack-built pkg-config work with external packages Does a spack-built pkg-config work with external packages? Dec 26, 2024
@climbfuji
Copy link
Contributor Author

A workaround was merged into our fork/branch: JCSDA#496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage The issue needs to be prioritized
Projects
None yet
Development

No branches or pull requests

1 participant