From b28dd38a6bfbfea42cf3aa5a06d92cfbe23b0258 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 14 Apr 2026 23:44:34 +0300 Subject: [PATCH] net.ssl: fix C error on Mac M1 when compiling pure V code (fixes #21820) --- vlib/net/openssl/openssl.c.v | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/vlib/net/openssl/openssl.c.v b/vlib/net/openssl/openssl.c.v index 0a8d54317..29c75e676 100644 --- a/vlib/net/openssl/openssl.c.v +++ b/vlib/net/openssl/openssl.c.v @@ -31,21 +31,14 @@ $if $pkgconfig('openssl') { #flag -lssl -lcrypto } #flag linux -ldl -lpthread - // MacPorts - #flag darwin -I/opt/local/include - #flag darwin -L/opt/local/lib - // Brew - #flag darwin -I/usr/local/opt/openssl/include - #flag darwin -L/usr/local/opt/openssl/lib - // brew on macos-12 (ci runner) - #flag darwin -I/usr/local/opt/openssl@3/include - #flag darwin -L/usr/local/opt/openssl@3/lib - // Brew arm64 - #flag darwin -I /opt/homebrew/opt/openssl/include - #flag darwin -L /opt/homebrew/opt/openssl/lib - // Procursus - #flag darwin -I/opt/procursus/include - #flag darwin -L/opt/procursus/lib + // Prefer a single matching macOS OpenSSL prefix to avoid mixing Intel and arm64 installs. + $if arm64 { + #flag darwin -I$when_first_existing('/opt/local/include','/opt/homebrew/opt/openssl/include','/opt/homebrew/opt/openssl@3/include','/opt/procursus/include','/usr/local/opt/openssl/include','/usr/local/opt/openssl@3/include') + #flag darwin -L$when_first_existing('/opt/local/lib','/opt/homebrew/opt/openssl/lib','/opt/homebrew/opt/openssl@3/lib','/opt/procursus/lib','/usr/local/opt/openssl/lib','/usr/local/opt/openssl@3/lib') + } $else { + #flag darwin -I$when_first_existing('/opt/local/include','/usr/local/opt/openssl/include','/usr/local/opt/openssl@3/include','/opt/procursus/include','/opt/homebrew/opt/openssl/include','/opt/homebrew/opt/openssl@3/include') + #flag darwin -L$when_first_existing('/opt/local/lib','/usr/local/opt/openssl/lib','/usr/local/opt/openssl@3/lib','/opt/procursus/lib','/opt/homebrew/opt/openssl/lib','/opt/homebrew/opt/openssl@3/lib') + } } #include # Please install OpenSSL development headers -- 2.39.5