소스 검색

Fix/libgit2 openssl3 linux (#8278)

* fix(libgit2): add OpenSSL 3.0+ compatibility flags for Linux

- Add OPENSSL_API_COMPAT=0x10100000L to fix compilation on Linux with OpenSSL 3.0+
- Resolves undefined reference to SSL_get1_peer_certificate error
- Affects Ubuntu 24.04+ and other modern Linux distributions

* feat(libcurl): prefer OpenSSL 3.0+ on Linux by default

- Automatically use openssl3 config on Linux systems
- Helps avoid conflicts with packages like libgit2 that use OpenSSL 3.0+
- Maintains backward compatibility for other platforms

* refactor: use package:add("defines") for OpenSSL compatibility

- Replace CMAKE_C_FLAGS/CMAKE_CXX_FLAGS approach with package:add("defines")
- Move OpenSSL 3.0+ compatibility define to on_load() function
- Improves flag preservation and follows xmake best practices
- Addresses automated code review feedback for more robust implementation

* fix: use opt.cxflags for OpenSSL 3.0+ defines during libgit2 compilation

- Move OPENSSL_API_COMPAT define from on_load to on_install
- Use opt.cxflags to apply defines during package compilation
- Remove incorrect package:add('defines') that only affected consumers

Addresses feedback from @SirLynix about proper compilation flag handling.

* fix(libgit2): resolve WASM pointer type conflicts and adjust llhttp dependency for cross compilation

* Update xmake.lua

---------

Co-authored-by: Saikari <[email protected]>
Master_Laplace 2 달 전
부모
커밋
bc88ef92e8
2개의 변경된 파일24개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 2
      packages/l/libcurl/xmake.lua
  2. 16 2
      packages/l/libgit2/xmake.lua

+ 8 - 2
packages/l/libcurl/xmake.lua

@@ -39,9 +39,15 @@ package("libcurl")
     -- we init all configurations in on_load, because package("curl") need it.
     on_load(function (package)
         if package:is_plat("linux", "bsd", "android", "cross") then
-            -- if no TLS backend has been enabled nor disabled, enable openssl by default
+            -- if no TLS backend has been enabled nor disabled, prefer openssl3 on modern systems
             if package:config("openssl") == nil and package:config("openssl3") == nil and package:config("mbedtls") == nil then
-                package:config_set("openssl", true)
+                -- Default to OpenSSL 3.0+ on Linux systems (Ubuntu 22.04+, Fedora 36+, etc.)
+                -- This helps avoid conflicts with other packages like libgit2 that use OpenSSL 3.0+
+                if package:is_plat("linux") then
+                    package:config_set("openssl3", true)
+                else
+                    package:config_set("openssl", true)
+                end
             end
         end
 

+ 16 - 2
packages/l/libgit2/xmake.lua

@@ -34,6 +34,7 @@ package("libgit2")
     end
 
     add_deps("pcre2", "llhttp")
+
     if not is_plat("macosx", "iphoneos") then
         add_deps("zlib")
     end
@@ -106,7 +107,7 @@ package("libgit2")
                 if package:is_plat("windows", "mingw", "msys") then
                     table.join2(links, {"ws2_32", "advapi32", "bcrypt"})
                 end
-    
+
                 io.replace("cmake/FindmbedTLS.cmake",
                     [["-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}"]],
                     table.concat(links, " "), {plain = true})
@@ -122,12 +123,25 @@ package("libgit2")
             "-DUSE_HTTP_PARSER=llhttp",
             "-DUSE_GSSAPI=OFF"
         }
+
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
         table.insert(configs, "-DUSE_SSH=" .. (package:config("ssh") and "ON" or "OFF"))
         table.insert(configs, "-DBUILD_CLI=" .. (package:config("tools") and "ON" or "OFF"))
         local opt = {}
         opt.packagedeps = {"pcre2"}
+
+        -- Fix OpenSSL 3.0+ compatibility on Linux
+        if package:is_plat("linux") and package:config("https") == "openssl3" then
+            opt.cxflags = {"-DOPENSSL_API_COMPAT=0x10100000L"}
+        end
+
+        -- Fix WASM Emscripten size_t/unsigned int pointer type conflicts
+        if package:is_plat("wasm") then
+            opt.cxflags = opt.cxflags or {}
+            table.insert(opt.cxflags, "-Wno-incompatible-pointer-types")
+        end
+
         if package:is_plat("mingw") then
             local mingw = import("detect.sdks.find_mingw")()
             local dlltool = assert(os.files(path.join(mingw.bindir, "*dlltool*"))[1], "dlltool not found!")
@@ -135,7 +149,7 @@ package("libgit2")
         end
         import("package.tools.cmake").install(package, configs, opt)
         if package:is_plat("linux") and linuxos.name() == "fedora" then
-            io.replace(path.join(package:installdir("lib/pkgconfig"), "libgit2.pc"), 
+            io.replace(path.join(package:installdir("lib/pkgconfig"), "libgit2.pc"),
                 "Requires.private: openssl ", "Requires.private: openssl3 ", {plain = true})
         end
     end)