Skip to content

Commit

Permalink
Deps: Fix GCC 14 build errors for lua-openssl on MSYS2
Browse files Browse the repository at this point in the history
Yet another "temporary" workaround. Dodging the problem with diff patches is questionable at best, but unblocks the other PRs.

Once the problem has been fixed upstream, or alternatively the workaround has been applied upstream, can likely get rid of this.
  • Loading branch information
rdw-software committed Aug 19, 2024
1 parent b679f0c commit 3e6f66c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
14 changes: 14 additions & 0 deletions deps/luaopenssl-unixbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ OPENSSL_INCLUDE_DIR=deps/openssl/openssl/include
LIBCRYPTO=$OUT_DIR/libcrypto.a
LIBSSL=$OUT_DIR/libssl.a

cleanup() {
echo "Reverting GCC 14 diagnostics patch (to make sure the build is idempotent)"
cd $SRC_DIR
git apply -R ../gcc14-diagnostics-workaround.diff
cd -
}

trap cleanup EXIT

echo "Applying GCC 14 diagnostics patch (this should hopefully be temporary)"
cd $SRC_DIR
git apply ../gcc14-diagnostics-workaround.diff
cd -

unset PKG_CONFIG_PATH # Prevent CMake from using the system OpenSSL (which may not necessarily be compatible)

cmake -S $SRC_DIR -B $BUILD_DIR -G Ninja -DOPENSSL_LIBRARIES=$OUT_DIR -DBUILD_SHARED_LUA_OPENSSL=OFF -DOPENSSL_ROOT_DIR=$OPENSSL_DIR -DOPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_DIR -DLUAJIT_INCLUDE_DIRS=$LUAJIT_SRC_DIR -DLUAJIT_LIBRARIES=$LUAJIT_SRC_DIR -DLUA_INCLUDE_DIR=$LUAJIT_SRC_DIR -DLUAJIT_LIBRARIES=$LUAJIT_LIBRARY_PATH -DCMAKE_C_COMPILER=gcc -DOPENSSL_CRYPTO_LIBRARY=$LIBCRYPTO -DOPENSSL_SSL_LIBRARY=$LIBSSL -DLUA_OPENSSL_LIBTYPE=STATIC -DOPENSSL_USE_STATIC_LIBS=ON
Expand Down
14 changes: 14 additions & 0 deletions deps/luaopenssl-windowsbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ OPENSSL_INCLUDE_DIR=deps/openssl/openssl/include
LIBCRYPTO=$OUT_DIR/libcrypto.a
LIBSSL=$OUT_DIR/libssl.a

cleanup() {
echo "Reverting GCC 14 diagnostics patch (to make sure the build is idempotent)"
cd $SRC_DIR
git apply -R ../gcc14-diagnostics-workaround.diff
cd -
}

trap cleanup EXIT

echo "Applying GCC 14 diagnostics patch (this should hopefully be temporary)"
cd $SRC_DIR
git apply ../gcc14-diagnostics-workaround.diff
cd -

cmake -S $SRC_DIR -B $BUILD_DIR -G Ninja -DOPENSSL_LIBRARIES=$OUT_DIR -DBUILD_SHARED_LUA_OPENSSL=OFF -DOPENSSL_ROOT_DIR=$OPENSSL_DIR -DOPENSSL_INCLUDE_DIR=$OPENSSL_INCLUDE_DIR -DLUAJIT_INCLUDE_DIRS=$LUAJIT_SRC_DIR -DLUAJIT_LIBRARIES=$LUAJIT_SRC_DIR -DLUA_INCLUDE_DIR=$LUAJIT_SRC_DIR -DLUAJIT_LIBRARIES=$LUAJIT_LIBRARY_PATH -DCMAKE_C_COMPILER=gcc -DOPENSSL_CRYPTO_LIBRARY=$LIBCRYPTO -DOPENSSL_SSL_LIBRARY=$LIBSSL -DLUA_OPENSSL_LIBTYPE=STATIC -DOPENSSL_USE_STATIC_LIBS=ON
cmake --build $BUILD_DIR --clean-first

Expand Down
50 changes: 50 additions & 0 deletions deps/zhaog/gcc14-diagnostics-workaround.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
diff --git a/src/ocsp.c b/src/ocsp.c
index 57ec6a59..02bd4ebb 100644
--- a/src/ocsp.c
+++ b/src/ocsp.c
@@ -104,12 +104,22 @@ static int openssl_ocsp_request_read(lua_State *L)
BIO *bio = load_bio_object(L, 1);
int pem = lua_gettop(L) > 1 ? auxiliar_checkboolean(L, 2) : 0;

+#if defined(__GNUC__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
+#endif
+
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
OCSP_REQUEST *req = pem ? PEM_read_bio_OCSP_REQUEST(bio, NULL, NULL)
: d2i_OCSP_REQUEST_bio(bio, NULL);
+
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
+
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
@@ -137,12 +147,22 @@ static int openssl_ocsp_response_read(lua_State *L)
int pem = lua_gettop(L) > 1 ? auxiliar_checkboolean(L, 2) : 0;
int ret = 0;

+#if defined(__GNUC__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
+#endif
+
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
OCSP_RESPONSE *res = pem ? PEM_read_bio_OCSP_RESPONSE(bio, NULL, NULL)
: d2i_OCSP_RESPONSE_bio(bio, NULL);
+
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
+
#if defined(__clang__)
#pragma clang diagnostic pop
#endif

0 comments on commit 3e6f66c

Please sign in to comment.