Skip to content

Cannot compile on MacOS #361

@mouse07410

Description

@mouse07410

Env

MacOS Sequoia 15.7.1, Xcode-26.1. OpenSSL-3.5.4 installed by Macports (this matters).

Problem

Fails to compile - unable to find OpenSSL header files:

$ cargo install kryoptic-tools
    Updating crates.io index
  Downloaded kryoptic-tools v1.3.1
  Downloaded 1 crate (17.1KiB) in 0.73s
  Installing kryoptic-tools v1.3.1
    Updating crates.io index
     Locking 109 packages to latest compatible versions
  Downloaded asn1_derive v0.21.3
  Downloaded asn1 v0.21.3
  Downloaded cryptoki v0.10.0
  Downloaded secrecy v0.8.0
  Downloaded cryptoki-sys v0.4.0
.  .  .  .  .
   Compiling serde_derive v1.0.228
   Compiling anstyle v1.0.13
   Compiling toml_writer v1.0.4
error: failed to run custom build command for `ossl v1.3.1`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/tmp/cargo-installZVLibP/release/build/ossl-71a3c457c521656d/build-script-build` (exit status: 101)
  --- stdout
  cargo::rustc-check-cfg=cfg(ossl_v307,ossl_v320,ossl_v350,ossl_mldsa,ossl_mlkem,ossl_slhdsa)
  cargo:rustc-link-lib=crypto
  Compile Error: "Unable to generate bindings: ClangDiagnostic(\"ossl.h:8:10: fatal error: 'openssl/core_dispatch.h' file not found\\n\")"

  --- stderr
  ossl.h:8:10: fatal error: 'openssl/core_dispatch.h' file not found
warning: build failed, waiting for other jobs to finish...
error: failed to compile `kryoptic-tools v1.3.1`, intermediate artifacts can be found at `/tmp/cargo-installZVLibP`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
$ 

OpenSSL headers live in /opt/local/include/openssl/, libraries - in /opt/local/lib/ (symlinked from /opt/local/libexec/openssl3/):

$ fd core_dispatch.h /opt/local/include/openssl
/opt/local/include/openssl/core_dispatch.h
$ 

There needs to be a way to point kryoptic build process at the location of the OpenSSL binary installation.
Currently set env vars do that, but kryoptic does not look at them:

$ env | grep OPENSSL
OPENSSL_LIB_DIR=/opt/local/lib
OPENSSL_INCLUDE_DIR=/opt/local/include
OPENSSL_APP=/opt/local/libexec/openssl3/bin/openssl
OPENSSL_MODULES=/opt/local/libexec/openssl3/lib/ossl-modules
OPENSSL_CFLAGS=-O3 -std=gnu18 -march=native -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I/opt/local/include
OPENSSL_ROOT_DIR=/opt/local/libexec/openssl3
OPENSSL_CONF=/opt/local/etc/openssl/openssl.cnf
OPENSSL_CXXFLAGS=-std=gnu++20 -O3 -march=native -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I/opt/local/include
OPENSSL_DIR=/opt/local/libexec/openssl3
$ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions