luvi icon indicating copy to clipboard operation
luvi copied to clipboard

Failed building in Termux with shared OpenSSL 3.0, PCRE, and Luv

Open 0komo opened this issue 2 years ago • 3 comments

Hello, I tried building luvi with shared OpenSSL 3.0, PCRE, and Luv. When cmake tried to build luvi, it failed with an error.

ld: error: jitted_tmp/src/lua/init.lua_luvi_generated.o: SHT_STRTAB string table section [index 3] is non-null terminated

The build flags.

cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DWithSharedLibluv=OFF -DWithSharedLibluv=ON -DWithSharedPCRE=ON -DCMAKE_LIBRARY_PATH=/data/data/com.termux/files/usr/lib -DOPENSSL_ROOT_DIR=/data/data/com.termux/files/usr -DOPENSSL_INCLUDE_DIR=/data/data/com.termux/files/usr/include -DOPENSSL_LIBRARIES=/data/data/com.termux/files/usr/lib -DPCRE_INCLUDE_DIR=/data/data/com.termux/files/usr/include -DPCRE_LIBRARIES=/data/data/com.termux/files/usr/lib -DLIBUV_INCLUDE_DIR=/data/data/com.termux/files/usr/include -DLIBUV_LIBRARIES=/data/data/com.termux/files/usr/lib -DLUAJIT_INCLUDE_DIR=/data/data/com.termux/files/usr/include/luajit-2.1 -DLUAJIT_LIBRARIES=/data/data/com.termux/files/usr/lib -DLIBLUV_INCLUDE_DIR=/data/data/com.termux/files/usr/include/luv -DLIBLUV_LIBRARIES=/data/data/com.termux/files/usr/lib -DWithOpenSSL=ON -DWithSharedOpenSSL=ON -DWithPCRE=ON -DWithLPEG=ON

Is there a work around to have ld not to result an error?

0komo avatar Sep 22 '23 11:09 0komo

I forgot, I also had patch for clang not to throw -Wincompatible-function-pointer-types.

--- luvi/deps/lua-openssl/src/ocsp.c	2023-09-21 20:43:36.658538386 +0800
+++ luvi.1/deps/lua-openssl/src/ocsp.c	2023-09-21 20:59:04.998538309 +0800
@@ -121,8 +121,15 @@
   BIO *bio = load_bio_object(L, 1);
   int pem = lua_gettop(L) > 1 ? auxiliar_checkboolean(L, 2) : 0;
 
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored"-Wincompatible-function-pointer-types"
+#endif
   OCSP_REQUEST *req = pem ? PEM_read_bio_OCSP_REQUEST(bio, NULL, NULL)
                       : d2i_OCSP_REQUEST_bio(bio, NULL);
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
   BIO_free(bio);
 
   if (req)
@@ -303,8 +310,15 @@
   BIO *bio = load_bio_object(L, 1);
   int pem = lua_gettop(L) > 1 ? auxiliar_checkboolean(L, 2) : 0;
 
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored"-Wincompatible-function-pointer-types"
+#endif
   OCSP_RESPONSE *res = pem ? PEM_read_bio_OCSP_RESPONSE(bio, NULL, NULL)
                       : d2i_OCSP_RESPONSE_bio(bio, NULL);
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
   if (res)
     PUSH_OBJECT(res, "openssl.ocsp_response");
   else

0komo avatar Sep 22 '23 12:09 0komo

upstream is https://github.com/zhaozg/lua-openssl

zhaozg avatar Sep 22 '23 12:09 zhaozg

upstream is https://github.com/zhaozg/lua-openssl

I'm building luvi from the v2.14.0 tag, should I update the local submodule to upstream?

0komo avatar Sep 22 '23 13:09 0komo