build.cpp: host Boost/OpenSSL detection leaks into cross-compiled (Windows) builds #68

Closed
opened 2026-12-06 10:58:51 +00:00 by faumaray · 1 comment
Owner

Context

VBS can now produce Windows-target packages from a Linux host (vbs install --target-os windows, MinGW-w64 cross toolchain). The native VoidLibrary description is evaluated for the Windows target, but its external dependency detection still looks at the host's conventional roots (/usr/include, ...).

Symptoms

On a Linux host with system Boost/OpenSSL installed:

  • detect_dependency("OpenSSL", {"openssl/ssl.h", ...}) finds the host headers, so VOID_CRYPTO_HAS_OPENSSL=1 is defined for the Windows build.
  • The exported include directory is /usr/include (a host path). Passing it to MinGW either mixes glibc headers into the Windows build:
    /usr/include/stdlib.h:67:5: error: conflicting declaration 'typedef struct div_t div_t'
    
    or, once host system includes are filtered out by the consumer, the OpenSSL headers cannot be found:
    src/Crypto/Crypto.cpp:18:10: fatal error: openssl/core_names.h: No such file or directory
    

Request

Make the external dependency detection target-aware: when cross-compiling (target != host), do not search the host's system roots for the target build; only use explicitly configured target roots (OPENSSL_ROOT_DIR etc. pointing at target libraries) or disable the optional dependency. The same applies to Boost.

Reproduced in an Arch container with mingw-w64-gcc, running the self-hosted install of Void/Build-System (--target-os windows).

## Context VBS can now produce Windows-target packages from a Linux host (`vbs install --target-os windows`, MinGW-w64 cross toolchain). The native VoidLibrary description is evaluated for the Windows target, but its external dependency detection still looks at the **host**'s conventional roots (`/usr/include`, ...). ## Symptoms On a Linux host with system Boost/OpenSSL installed: - `detect_dependency("OpenSSL", {"openssl/ssl.h", ...})` finds the host headers, so `VOID_CRYPTO_HAS_OPENSSL=1` is defined for the Windows build. - The exported include directory is `/usr/include` (a host path). Passing it to MinGW either mixes glibc headers into the Windows build: ``` /usr/include/stdlib.h:67:5: error: conflicting declaration 'typedef struct div_t div_t' ``` or, once host system includes are filtered out by the consumer, the OpenSSL headers cannot be found: ``` src/Crypto/Crypto.cpp:18:10: fatal error: openssl/core_names.h: No such file or directory ``` ## Request Make the external dependency detection target-aware: when cross-compiling (target != host), do not search the host's system roots for the target build; only use explicitly configured target roots (`OPENSSL_ROOT_DIR` etc. pointing at target libraries) or disable the optional dependency. The same applies to Boost. Reproduced in an Arch container with `mingw-w64-gcc`, running the self-hosted install of Void/Build-System (`--target-os windows`).
Author
Owner

Fixed on main in 1b19473. When the target OS differs from the host, the description no longer searches host roots (/usr, /usr/local, /opt/homebrew) or CPATH/LIBRARY_PATH; it uses _ROOT/_INCLUDE_DIR/_LIBRARY_DIR and the profile sysroot instead. Native builds are unchanged.

Fixed on main in 1b19473. When the target OS differs from the host, the description no longer searches host roots (/usr, /usr/local, /opt/homebrew) or CPATH/LIBRARY_PATH; it uses <NAME>_ROOT/<NAME>_INCLUDE_DIR/<NAME>_LIBRARY_DIR and the profile sysroot instead. Native builds are unchanged.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Void/Library#68