Skip to content

build: generate pkgconfig file - #473

Merged
devinamatthews merged 3 commits into
flame:masterfrom
ajaypanyala:pkgconfig
Feb 1, 2021
Merged

devinamatthews merged 3 commits into
flame:masterfrom
ajaypanyala:pkgconfig

Conversation

@ajaypanyala

@ajaypanyala ajaypanyala commented Jan 12, 2021 •

Copy link
Copy Markdown
Contributor

Fixes #472

Comment thread Makefile
# Set the path to the subdirectory of the share installation directory.
MK_SHARE_DIR_INST := $(INSTALL_SHAREDIR)/blis

PC_SHARE_DIR_INST := $(INSTALL_SHAREDIR)/pkgconfig

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't this supposed to be $(INSTALL_LIBDIR)/pkgconfig?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It could be, but since the rest of the blis config files are installed in share, I used the same to be consistent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pkg-config will not find blis if it's not installed into $(INSTALL_LIBDIR)/pkgconfig right? (Unless the user manually sets PKG_CONFIG_PATH)

@ajaypanyala ajaypanyala Jan 12, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right. Thanks for bringing that up. I was only testing it from within a CMake project and that works either way with CMake. How about adding a datadir=@prefix@/share to blis.pc.in. pkg-config should automatically pick up from datadir/pkgconfig as well right ? Alternatively, I could also change it to $(INSTALL_LIBDIR)/pkgconfig, but I would prefer @devinamatthews comment on this one before I do that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See comment here.

@devinamatthews

Copy link
Copy Markdown
Member

@ajaypanyala @isuruf I'm in over my head here but this guide says "On a typical Unix system, it will search in the directories /usr/lib/pkgconfig and /usr/share/pkgconfig". On my mac they're all in /usr/lib. On our cluster they're all in /usr/share... Since a pkg-config file is not actually an executable library I would put it in share, but then again .la files go in lib so I guess anything goes.

My main concern is actually using the BLIS CFLAGS and LDFLAGS... these should only be necessary for downstream application to use when linking the static version, and even then not all of the flags are necessary. Perhaps the initial version can assume dynamic linking and omit those?

@ajaypanyala

Copy link
Copy Markdown
Contributor Author

@devinamatthews I was not sure how to separate CFLAGS needed by downstream application from the ones that are private to blis build when writing them out to the pc file. Since the default blis configuration is building both static and dynamic libs, it might be better not to omit them since we do not know what the downstream application would prefer to use ?

@isuruf

isuruf commented Jan 12, 2021

Copy link
Copy Markdown
Contributor

For libraries that are needed only during static linking you can add them to Libs.private instead of Libs which is used when pkg-config --static is used.

@isuruf

isuruf commented Jan 12, 2021

Copy link
Copy Markdown
Contributor

@ajaypanyala @isuruf I'm in over my head here but this guide says "On a typical Unix system, it will search in the directories /usr/lib/pkgconfig and /usr/share/pkgconfig". On my mac they're all in /usr/lib. On our cluster they're all in /usr/share... Since a pkg-config file is not actually an executable library I would put it in share, but then again .la files go in lib so I guess anything goes.

Didn't know that. I'm fine with either option then.

@devinamatthews

Copy link
Copy Markdown
Member

I would say leave them out, and we can put a caveat in the docs that says for now it (pkg-config) only works with dynamic linking. It's still a net gain in functionality.

@ajaypanyala

ajaypanyala commented Jan 12, 2021 •

Copy link
Copy Markdown
Contributor Author

@devinamatthews I pushed a small change as suggested by @isuruf . With this pkg-config --libs blis assumes you want the dynamic version and just gives -lblis. A call to pkg-config --libs blis --static would return the contents of Libs.private as well which could be for example -lm -lpthread -fopenmp -lrt.

@ajaypanyala

ajaypanyala commented Jan 12, 2021 •

Copy link
Copy Markdown
Contributor Author

My main concern is actually using the BLIS CFLAGS and LDFLAGS... these should only be necessary for downstream application to use when linking the static version, and even then not all of the flags are necessary.

@devinamatthews Could you point me to a blis configuration that would populate CFLAGS where some flags are not needed downstream even for static linking? I did not see any such case atleast in the configurations I tested. The CFLAGS were empty in all the tests on my end, so could not tell.

@devinamatthews

Copy link
Copy Markdown
Member

I can't say for sure, maybe -funsafe-math-optimizations. But even basic optimization flags shouldn't be passed on to downstream applications. If -fopenmp is in Libs.private then I think that is sufficient and CFLAGS can be dropped. Good work on the --static workaround.

@ajaypanyala

Copy link
Copy Markdown
Contributor Author

Dropped CFLAGS. Thanks!

@ajaypanyala

Copy link
Copy Markdown
Contributor Author

@devinamatthews @isuruf Is this good to go ? Please let me know if something else is needed before merging.

@devinamatthews

Copy link
Copy Markdown
Member

Yes, looks good. I'll merge.

@devinamatthews
devinamatthews merged commit f50c1b7 into flame:master Feb 1, 2021
@ajaypanyala
ajaypanyala deleted the pkgconfig branch February 1, 2021 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build: write a pkg-config file

3 participants