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

sdjournal: pkg-config isn't queried for include paths #351

Open
flokli opened this issue Jan 16, 2021 · 1 comment
Open

sdjournal: pkg-config isn't queried for include paths #351

flokli opened this issue Jan 16, 2021 · 1 comment

Comments

@flokli
Copy link

flokli commented Jan 16, 2021

Moved over from #141 (comment)

#141 moved libsystemd from being linked at build time to being dlopen-ed at runtime.

However, that PR entirely removed the pkg-config directive.

As pkg-config isn't only used for linker flags, but also for include paths, this breaks the build on systems that don't ship the systemd headers in the default include paths (such as NixOS):

# github.com/coreos/go-systemd/sdjournal
vendor/github.com/coreos/go-systemd/sdjournal/journal.go:27:11: fatal error: systemd/sd-journal.h: No such file or directory
   27 | // #include <systemd/sd-journal.h>
      |           ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

One option might be to keep using pkg-config to discover include dirs, or ship the header files inline if we're relying on them.

Frankly, I'm not entirely sure about whether dlopen-ing libsystemd inside go-systemd is a good idea.

Usually, package managers use the library paths and NEEDED symbols in ELF headers to reason about runtime depenencies.

Switching from linking to dlopen causes this to not happen anymore, and leads to sudden, unexpected failures at runtime in any binaries that use go-systemd somewhere, if the dynamic linker can't find the library in the "common library paths" at runtime. Propagating these dependencies through sounds more desirable IMHO.

#141 originally just wanted to avoid linking against libsystemd at runtime, I wonder if this can be accomplished by passing some flags at build time, or is only required when compiling in the components that require libsystemd functionality in first place.

@owen-d
Copy link

owen-d commented Jul 8, 2021

@flokli Thanks for all the digging (and nixpkgs work detailing your intermediate workarounds that led me here). Much <3 from a NixOS noob.

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

No branches or pull requests

2 participants