Repository: spack/spack

Issue:
Failed to bootstrap pkg-config with pgi compiler
I failed to bootstrap `pkg-config` with `pgi@16.10`.  The error says "PGC-F-0249-#error --  Your platform/compiler is missing constructor support (glib-init.c: 284)". Shall I submit a bug report to `pkg-config`?


```
$ spack purge; spack clean pkg-config; spack install pkg-config %pgi@16.10
==> Installing pkg-config
==> Using cached archive: /tmp/rpm/spack_source_cache/pkg-config/pkg-config-0.29.1.tar.gz
==> Already staged pkg-config-0.29.1-acbcjyz6mwiu7fnleuuatbxolunoszhl in /home/rpm/spack/var/spack/stage/pkg-config-0.29.1-acbcjyz6mwiu7fnleuuatbxolunoszhl
==> Already patched pkg-config
==> Building pkg-config [Package]
==> Executing phase : 'install'
==> Error: ProcessError: Command exited with status 2:
    'make'
/home/rpm/spack/var/spack/repos/builtin/packages/pkg-config/package.py:63, in install:
     53       def install(self, spec, prefix):
     54           args = ["--prefix={0}".format(prefix),
     55                   "--enable-shared"]
     56           if "+internal_glib" in spec:
     57               # There's a bootstrapping problem here;
     58               # glib uses pkg-config as well, so break
     59               # the cycle by using the internal glib.
     60               args.append("--with-internal-glib")
     61           configure(*args)
     62
  >> 63           make()
     64           make("install")

See build log for details:
  /tmp/rpm/spack_stage/spack-stage/spack-stage-w24BST/pkg-config-0.29.1/spack-build.out
```


Discussion:
I've ran into this bug as well but hadn't yet gotten around to submitting a bug report. You're actually better off submitting a bug report to the glibc developers. pkg-config depends on glibc, but glibc depends on pkg-config. The developers realized this would cause a circular dependency, so pkg-config contains glibc in one of its sub-directories. If the glibc developers give you a patch for glibc, you can also apply it to the pkg-config package. PGI is a much stricter compiler than GCC, so I'm not surprised it doesn't build glibc. I've found developers to be fairly responsive about PGI patches.
Just curious if a bug report was filed. This problem persists with pkg-config-0.29.2.
I never personally filed a bug report. I recommend contacting the glibc developers.
I managed to workaround this problem by using the system pkg-config, by adding it to the `packages.yaml` file.
```YAML
packages:
    pkg-config: 
        paths: 
            pkg-config: /usr/bin/pkg-config
        buildable: False
```
Yes, that's what we've been doing as well. I've asked @ssergien to contact the glibc developers and get to the bottom of this.
Thanks for the packages.yaml trick !
Any update on this?
Ran into this issue when trying to install `openmpi@3.1.2` with `pgi@19.10`.  I pointed spack to the system installed pkg-config (@0.27.1), but very quickly ran into another error when building `libpciaccess@0.13.5` regarding undefined references to `inw`, `outw`, `inb`, `outb`, `inl`, and `outl` in `libpciaccess.so`.  I'm not sure if this is related to using an older pkg-config or if it's completely unrelated, but it would be nice if spack was able to install pkg-config in order to help debug this issue.
@nicholas-sly this is a known problem with the PGI compilers and libpciaccess, it has nothing to do with pkg-config. I actually reported this one back in 2016. See:

* https://bugs.freedesktop.org/show_bug.cgi?id=94398
* https://www.pgroup.com/userforum/viewtopic.php?f=4&t=5126
* https://gitlab.freedesktop.org/xorg/lib/libpciaccess/issues/7
@adamjstewart Wow.  You seem to have gotten a lot of response and little resolution.  

If that's the case, should Spack include an incompatibility between PGI and libpciaccess?  

Perhaps allowing for libpciaccess to be built with gcc even if it's a dependency of something else being built with PGI (as was seemingly hinted at in one of those threads)?
> If that's the case, should Spack include an incompatibility between PGI and libpciaccess?

Yes, we should add a `conflicts('%pgi')` to the package and include those URLs in comments.

> Perhaps allowing for libpciaccess to be built with gcc even if it's a dependency of something else being built with PGI (as was seemingly hinted at in one of those threads)?

@tgamblin is currently working on a new concretizer that will allow this. Specifically, build dependencies like `pkg-config` will be built with the system default compiler (usually GCC) and conflicts will influence the concretizer's decision on which compiler to use.
I ran into the same issue trying to install pkg-config@0.29 with pgi@19.7. I'm using Spack 14.2.
Shall I go for the trick of directing pkg-config to use the system package or there is  another fix for it? 

As far as I know, nothing has changed. You should use an external installation of `pkgconfig` and report the build issue to the `pkgconfig` developers.
I'm also running into issues similar to the above when trying to build components with pgi compilers via spack.   Jim G
Does `pkgconf` build with PGI? Has anyone contacted the `pkg-config` or `pkgconf` developers?
As PGI appears to be subsumed by the nvidia HPC tools set, we are probably just going to drop our support for now.  If it doesn't currently work, I'd be surprised if the `pkgconf`/`pkg-config` developers care to put any effort into this.
@nicholas-sly I assume any patches needed for NVIDIA HPC support will be identical to those needed for PGI support. I'm not opposed to dropping support for both (and adding conflicts). The new concretizer should be smart enough to compile build-dependencies with GCC and compile the rest of your DAG with the compiler you request.
This is true.  We're just unsure what licensing will even look like, so we're bailing until we know more.  I think the conflicts in anticipation of the new concretizer are the way I'd like to see this dealt with.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/pkg-config/package.py b/var/spack/repos/builtin/packages/pkg-config/package.py
--- a/var/spack/repos/builtin/packages/pkg-config/package.py
+++ b/var/spack/repos/builtin/packages/pkg-config/package.py
@@ -25,6 +25,9 @@ class PkgConfig(AutotoolsPackage):
     # The following patch is needed for gcc-6.1
     patch('g_date_strftime.patch', when='@:0.29.1')
 
+    # https://github.com/spack/spack/issues/3525
+    conflicts('%pgi')
+
     parallel = False
 
     executables = ['^pkg-config$']
diff --git a/var/spack/repos/builtin/packages/pkgconf/package.py b/var/spack/repos/builtin/packages/pkgconf/package.py
--- a/var/spack/repos/builtin/packages/pkgconf/package.py
+++ b/var/spack/repos/builtin/packages/pkgconf/package.py
@@ -31,6 +31,9 @@ class Pkgconf(AutotoolsPackage):
     # TODO: Add a package for the kyua testing framework
     # depends_on('kyua', type='test')
 
+    # https://github.com/spack/spack/issues/3525
+    conflicts('%pgi')
+
     executables = ['^pkgconf$', '^pkg-config$']
 
     @classmethod


Test patch: