]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
appveyor: Fix LDFLAGS for Windows build
authorTobias Brunner <tobias@strongswan.org>
Fri, 3 Mar 2023 12:02:44 +0000 (13:02 +0100)
committerTobias Brunner <tobias@strongswan.org>
Mon, 6 Mar 2023 14:07:57 +0000 (15:07 +0100)
With newer OpenSSL builds, the DLL files contain parts of the version
number and the architecture in their name, e.g. for OpenSSL 1.1.1 the
DLL for libcrypto is called libcrypto-1_1-x64.dll.  So referencing that
directly could be kinda tricky.  And by using `-lcrypto` we therefore
didn't link those DLLs but the OpenSSL version installed by msys2.
Since the latter ships OpenSSL 3 since January and the VS 2019 image
was updated recently, our builds broke as we used the headers from
the 1.1.1 installation but then tried to link OpenSSL 3.

Luckily, in the lib/ directory of the OpenSSL installation, there is a
libcrypto.lib file, which is an import library (containing the symbols
and a reference to the DLL).  We can use that to link the right library
via `-lcrypto`.

With the old OpenSSL 1.0.2 build on the VS 2015 image, there is also
such a .lib file but it seems the linker is too old or otherwise incapable
of finding the DLL.  But since the DLL is just called libeay32.dll there,
we use that directly and don't reference the lib/ dir.

Also removed a superfluous AC_MSG_RESULT() if libeay32 isn't found.

configure.ac
scripts/test.sh

index 8fb048e58112e19f80c5a3854a7544224f3212bc..541a5877d06c5145c10607990a1e257d5528b63b 100644 (file)
@@ -1169,7 +1169,7 @@ if test x$openssl = xtrue; then
        if test "x$windows" = xtrue; then
                openssl_lib=eay32
                AC_CHECK_LIB([$openssl_lib],[EVP_CIPHER_CTX_new],[LIBS="$LIBS"],
-                       [AC_MSG_RESULT([no]);openssl_lib=""],[$DLLIB])
+                       [openssl_lib=""],[$DLLIB])
        fi
        if test -z "$openssl_lib"; then
                openssl_lib=crypto
index 5e15f0af842dd93fcfcb5f907a2cfdc969fd1df4..6b2e8caa124ac86a7538a5a9151832cddf47cad2 100755 (executable)
@@ -286,17 +286,23 @@ win*)
        if test "$APPVEYOR" != "True"; then
                TARGET=
        else
+               CONFIG="$CONFIG --enable-openssl"
                case "$IMG" in
                2015|2017)
                        # old OpenSSL versions don't provide HKDF
                        CONFIG="$CONFIG --enable-kdf"
                        ;;
                esac
-               CONFIG="$CONFIG --enable-openssl"
+
                CFLAGS="$CFLAGS -I$OPENSSL_DIR/include"
-               LDFLAGS="-L$OPENSSL_DIR"
+               LDFLAGS="-L$OPENSSL_DIR/lib"
+               case "$IMG" in
+               2015)
+                       # gcc/ld might be too old to find libeay32 via .lib instead of .dll
+                       LDFLAGS="-L$OPENSSL_DIR"
+                       ;;
+               esac
                export LDFLAGS
-
        fi
        CFLAGS="$CFLAGS -mno-ms-bitfields"
        DEPS="gcc-mingw-w64-base"