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

Generate and install libgap.pc for use with pkg-config #5080

Merged
merged 21 commits into from
Oct 14, 2022

Conversation

dimpase
Copy link
Member

@dimpase dimpase commented Oct 4, 2022

Implement generation and installation of libgap.pc, to be used with pkg-config, as discussed in #275

Text for release notes

see title

@dimpase dimpase requested a review from fingolfin October 4, 2022 19:26
@fingolfin fingolfin added topic: build system release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes labels Oct 4, 2022
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this, much appreciated!

is there a good way to test this works as intended? Like a minimal invocation of the pkg-config tool we could put into a test script?

libgap.pc.in Outdated Show resolved Hide resolved
libgap.pc.in Outdated Show resolved Hide resolved
libgap.pc.in Outdated Show resolved Hide resolved
@dimpase
Copy link
Member Author

dimpase commented Oct 5, 2022

I'll see how to add a test with pkg-config.

@dimpase
Copy link
Member Author

dimpase commented Oct 5, 2022

By the way, shouldn't install-libgap make target have install-headers as a dependency?

@dimpase
Copy link
Member Author

dimpase commented Oct 5, 2022

it's also a bit strange that install does not depend on all, and so make install fails if make was not called before.

@dimpase
Copy link
Member Author

dimpase commented Oct 6, 2022

Not sure where the tests I added should be chained. Please advice.

@dimpase dimpase requested a review from fingolfin October 6, 2022 16:48
@dimpase
Copy link
Member Author

dimpase commented Oct 6, 2022

I guess we want to have it tested on CI.

@dimpase
Copy link
Member Author

dimpase commented Oct 6, 2022

I don't grok .github/workflows/CI.yml - e.g. where is what's happening in teststandard specified?

configure.ac Show resolved Hide resolved
libgap.pc.in Show resolved Hide resolved
libgap.pc.in Outdated Show resolved Hide resolved
Makefile.rules Show resolved Hide resolved
@dimpase
Copy link
Member Author

dimpase commented Oct 6, 2022

One more discrepancy I noticed: in libgap tests code, includes don't have gap/ prefix, and this could potentially confuse
downstream, who would use installed GAP headers, which do come with gap/ prefix.
In the test I work around it by appending /gap to the -I flag, but this shouldn't be needed.

IMHO libgap tests should use gap/ prefix in includes, maybe at expense of creating a symbolic link to (uninstalled) headers?

@dimpase
Copy link
Member Author

dimpase commented Oct 7, 2022

As far as I can see, pkg-config is not available in testmakeinstall CI "matrix row"

no, it's actually a bug in makefile I introduced. I can't call pkg-config ahead of make install-libgap done

@dimpase
Copy link
Member Author

dimpase commented Oct 7, 2022

OK, we're almost there. The test now fails as follows:

Package gmp was not found in the pkg-config search path.
Perhaps you should add the directory containing `gmp.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gmp', required by 'libgap', not found

So the question is where to look for gmp.pc ? Is it because GMP is vendored? Or we're on an outdated system which does not install gmp.pc, while installing GMP?

@dimpase
Copy link
Member Author

dimpase commented Oct 7, 2022

Hmm, no, libgmp-dev is installed all right, but on Ubuntu Bionic gmp.pc is not installed, cf https://packages.ubuntu.com/bionic/amd64/libgmp-dev/filelist (because it's quite old, it's GMP 6.1, not 6.2).

Should we move to newer Ubuntu (Bionic will reach end of standard support in April 2023) ?

@fingolfin
Copy link
Member

We want to update to a newer Ubuntu, see #5009 but also see PR #5026 and the problem there (32bit support seems to be going away)

@fingolfin
Copy link
Member

I've updated PR #5026 now so that we could merge it (if e.g. @ChrisJefferson approves it), at which point the tests would be running in 20.04 or 22.04 (I forgot and didn't check but either has gmp.pc)

@fingolfin
Copy link
Member

it's also a bit strange that install does not depend on all, and so make install fails if make was not called before.

It should depend on all relevant targets, such as libgap, gap etc. with one exception: the manuals; because make doc is currently not idempotent and it is a pest to have it re-run pdflatex again and again for no good reason. (This is "documented" in a comment in install-doc). If someone were to submit a PR to make make doc idempotent, we could fix that. But for now it seemed like a low priority; the general mantra for installing software using autoconf has always been ./configure && make && make install

@dimpase
Copy link
Member Author

dimpase commented Oct 7, 2022

well, is it done, or something else needs to be done, still, here?

@collares collares mentioned this pull request Oct 9, 2022
13 tasks
@dimpase
Copy link
Member Author

dimpase commented Oct 11, 2022

CI is OK (except 32-bit one, which is due to broken system packages)

@fingolfin fingolfin added the topic: libgap things related to libgap label Oct 11, 2022
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this.

And my apologies, but yeah I still do have concerns... I can also try to take care of them myself later, but here are my remarks anyway


# test libgap's pkg-config's libgap flags fetching
tst/testpkgconfigbuild: install
$(eval PKG_REPORTED_CFLAGS := $(shell PKG_CONFIG_PATH=$(DESTDIR)$(libdir)/pkgconfig pkg-config --cflags libgap | cut -d' ' -f 1)/gap)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the cut?

Ahh, I think it's to append /gap to the first of include paths returned by--cflags, right? But why to the first, and why is it OK to discard any other? Are there other?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need cut, as pkg-config --cflags adds a trailing space. For it's designed for convenience in the normal setups, not when you all of a sudden must add a nontrivial suffix for the include path. As I mentioned in a comment somewhere here, I'd rather have all the test code for libgap use headers with explicit gap/ prefix - then we'd need this weird hackery.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to add gap/ here as libgap testing code uses #include <foo.h> rather than #include <gap/foo.h>.

@@ -13,6 +13,7 @@
/confdefs.h
/conftest*
/libtool
/libgap.pc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, why libgap.pc and not gap.pc? (I don't want to bikeshed, and I am fine with keeping it as-is! I am merely curious and wondering if there is a deeper rationale for these names that you are aware of. Looking at the pkgconfig dir of one of my machines, I see gap.pc, mpfr.pc, zlib.pc yet libcurl.pc and libzmq.pc -- so it seems pretty much random?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, libgap.pc is pretty much what's needed to include libgap in the project. But gap.pc is a bit unclear.

libgap.pc.in Outdated
Description: Library containing the kernel of GAP, a computer algebra system
URL: https://www.gap-system.org
Version: @PACKAGE_VERSION@
Requires.private: gmp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, doesn't it also require zlib, and possibly readline, depending on the install options? Otherwise static linking won't work after all, will it?

Did you test this at all? Static linking libgmp doesn't strike me as very useful, so perhaps this line should just be removed?

I mean, I am also fine with keeping it, and won't block this PR over it; but it seems misleading?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what, for libgap? Does libgap depend on zlib and readline?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we always link against libz. Whether we link against GNU readline depends on configure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps, we should just remove Requires line, and wait for possible bug reports (from some clever Linux distro which likes to underlink stuff...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing it would be fine by me.

libgap.pc.in Outdated Show resolved Hide resolved
Makefile.rules Outdated
@@ -1268,6 +1271,27 @@ testlibgap: ${LIBGAPTESTS}
$(v) -A -l $(top_srcdir) -q -T --nointeract >$(v).out && \
diff $(top_srcdir)/$(v).expect $(v).out && ) :

# test libgap's pkg-config's libgap version reporting
tst/testpkgconfigversion: install-libgap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This target does not actually create tst/testpkgconfigversion and as such should be added to .PHONY (and then perhaps renamed testpkgconfigversion).

Suggested change
tst/testpkgconfigversion: install-libgap
.PHONY: testpkgconfigversion
testpkgconfigversion: install-libgap

Though it also does not set an exit code, so it'll never fail... Perhaps add an exit 1 in a suitable place?

Or just remove it here and add the same code into ci.sh, where it can be rewritten without mangling shell code ;-). (The expected version could then be computed via make print-GAP_VERSION)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep the make version, as it allows testing locally in a normal way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite get the removal of tst/ - I thought it's a convention for test targets, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other test target has a tst/ prefix.

And you can invoke dev/ci.sh locally, I regularly do it. But as I said, i won't quibble over this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other test target has a tst/ prefix.

how about Makefile.rules:tst/testlibgap/%: ? Or Makefile.rules:tst/testkernel/%: ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are not test targets (in particular, they are not PHONY) but rather regular file targets that are then used by the test targets testlibgap and testkernel

.github/workflows/CI.yml Outdated Show resolved Hide resolved
Makefile.rules Outdated Show resolved Hide resolved
Makefile.rules Show resolved Hide resolved
Makefile.rules Show resolved Hide resolved
dev/ci.sh Outdated Show resolved Hide resolved
.github/workflows/CI.yml Outdated Show resolved Hide resolved
@dimpase
Copy link
Member Author

dimpase commented Oct 11, 2022 via email

dimpase and others added 14 commits October 12, 2022 12:29
Co-authored-by: Max Horn <max@quendi.de>
to execute them, run

    make tst/testpkgconfigbuild tst/testpkgconfigversion
Co-authored-by: Max Horn <max@quendi.de>
Co-authored-by: Max Horn <max@quendi.de>
Co-authored-by: Max Horn <max@quendi.de>
use @GAP_VERSION@ for Version

Co-authored-by: Max Horn <max@quendi.de>
Co-authored-by: Max Horn <max@quendi.de>
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@fingolfin fingolfin merged commit d298b42 into gap-system:master Oct 14, 2022
@dimpase
Copy link
Member Author

dimpase commented Oct 14, 2022

thanks!

@dimpase dimpase deleted the pc_file branch October 14, 2022 11:29
@dimpase dimpase mentioned this pull request Oct 14, 2022
@fingolfin fingolfin changed the title adding libgap.pc generation and installation, to be used with pkg-config Generate and install libgap.pc for use with pkg-config Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: build system topic: libgap things related to libgap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants