build: add pkg-config support for locating system libsodium#1273
Open
chenrui333 wants to merge 1 commit into
Open
build: add pkg-config support for locating system libsodium#1273chenrui333 wants to merge 1 commit into
chenrui333 wants to merge 1 commit into
Conversation
Signed-off-by: Rui Chen <rui@chenrui.dev>
6 tasks
cjdelisle
reviewed
Dec 10, 2025
| if (process.env.SODIUM_USE_PKG_CONFIG) { | ||
| try { | ||
| const cflags = ChildProcess | ||
| .execSync('pkg-config --cflags-only-I libsodium', { encoding: 'utf8' }) |
Owner
There was a problem hiding this comment.
Testing this on ubuntu I get nothing:
root@cjd-dev:~# pkg-config --cflags-only-I libsodium
root@cjd-dev:~#
That's because the headers are found in /usr/include and it removes system imports. It would be better to use --keep-system-cflags as per:
root@cjd-dev:~# pkg-config --cflags-only-I --keep-system-cflags libsodium
-I/usr/include
root@cjd-dev:~#
And that should make it work in this case
cjdelisle
reviewed
Dec 10, 2025
| throw new Error("Unable to find a path to libsodium headers"); | ||
| throw new Error( | ||
| "Unable to find a path to libsodium headers. " + | ||
| "If you have system libsodium installed, try setting SODIUM_USE_PKG_CONFIG=1." |
Owner
There was a problem hiding this comment.
When I run this with SODIUM_USE_PKG_CONFIG=1 and system sodium cannot be found, I get this error which is contrary to what should be happening. Per my reading of your code, it should be falling back on the vendored version. We need to investigate why this is happening.
cjdelisle
reviewed
Dec 10, 2025
| }); | ||
| })); | ||
| // Try pkg-config first if SODIUM_USE_PKG_CONFIG is set | ||
| if (process.env.SODIUM_USE_PKG_CONFIG) { |
Owner
There was a problem hiding this comment.
Instead of SODIUM_USE_PKG_CONFIG I would prefer:
CJDNS_FORCE_SODIUM_PKG_CONFIG-> Fail if none found in pkg-configCJDNS_SKIP_SODIUM_PKG_CONFIG-> Do not try pkg-config, only use vendored version
And if nothing is passed, attempt pkg-config and then fall back to vendored version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add pkg-config support for locating system libsodium