Skip to content

🐛 CGO / OpenSSL linking relies on local environment variables #27

@apierr

Description

@apierr

Description

Tests in bccsp/hybrid currently succeed on macOS only when specific CGO environment variables are manually set to link OpenSSL. This indicates that OpenSSL is not being linked automatically, even though liboqs depends on it.

At the moment, the build implicitly relies on local environment configuration, which is fragile and not portable.

Local workaround (current state)

The following environment variables are required locally to make the build and tests pass:

export CGO_ENABLED=1
export CGO_CFLAGS="-I/opt/homebrew/opt/openssl@3/include"
export CGO_LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib -lssl -lcrypto"

Possible solutions

  • (Recommended) Use pkg-config in CGO directives (e.g., // #cgo pkg-config: liboqs openssl) so that OpenSSL is linked automatically across macOS, Linux, and CI.
  • Add OS-specific CGO flags guarded by build tags (e.g., darwin) if pkg-config cannot be assumed.
  • As a fallback, document the required CGO environment variables in the README (least robust option).

Notes

  • Issue observed on macOS (arm64, Homebrew OpenSSL 3).
  • Error manifests as undefined OpenSSL symbols during the linking stage.
  • Tests pass once OpenSSL is explicitly linked via CGO flags.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions