From nobody Sun May 14 19:25:11 2023 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QKCBb5fRsz4C2fb; Sun, 14 May 2023 19:25:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QKCBb547Qz3RK9; Sun, 14 May 2023 19:25:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684092311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Hf0Ga2aBbs+xwSWmH/0MdGwnTKOit1ZAnqWtDP+5NnA=; b=mQVAYwLPF2URP+XY0/GIeuhZA7XKkLQvagA2EEq8XLiQIL+VAljSeZoKGQHG4HaYpgC+Bb g/lyrfnjWhv4kV4i2cZOsbEuxP43GdYcL8veF49tODxqhvUeOtHPAVx1n+xOQOrTQfVLdp 1FGvbE9y0fy1YmplReNUuUM/SqgtpB2Vf/oUSWn3rKDqqjlubXl7VWWHjLJTQk0Lo2XBE7 Y9/B+hFc65yOJgdAflYEDD9ekPZ0CfNhNiXErC2N5oDlXdvy0/Ge9oE3+aqRR7WvCsd5xy 1pCTVjkbWMgUDgByQnUistDeqSlE2xNn9VwxQOXy8RmYMPNsEspvrazrVzqbfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684092311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Hf0Ga2aBbs+xwSWmH/0MdGwnTKOit1ZAnqWtDP+5NnA=; b=RsjaBUD/HN8mTpGy6EpM4KpZiBWqyUWmhoSTVQrxUZaec8hBQjS/EAmfwy95YCSutZkg6s A35auw1FnB02T5GQNG60lERnXcKUzVRi+h193M0sJHWgJ0GjQt54f0VhueP+1Z8FxesFKh Wg36pZ7bLvqsXJTWg8KnD+mauYsgUIpu2OxXCqTp/UEMhOgDhSdZnxav1ioW1v+hTleFQM eG54xnwagnsoNKv5la6VM5JKgTH5rSQOzcuMoa71ttf6Vncipw4RvuUhHYph7C0HT+9M+8 TWjHR7miHqUsYZ7c7pY+sWoiXdumXKeKjy2xLFS9T4KJBSrsEc75kOvRQM/j4A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684092311; a=rsa-sha256; cv=none; b=VGI5FWZuyUI6pU1cdFQchkaW9qlKBWXpncAJx59lw+d8fVKNetEdsYcJjumLo40j+FbQf/ 84p3uRKneD0MIuBspoab2B/QFQrOLYczuTJtIyVNJscr+z3RYz+e9OyGCA+RP2p6Z0ehr5 5S7I28iusADxHXTbxSB2scojbdIUw5YFDUUBh9mq0erh0D+avnc0+UBAxN1mI0cpi0yFps 04WAcoHHowvhkTbuo33L2CypvvxLej49L1fpgmEg76RQvJ302OswbuHeNYkDwu/QAwsJ+I owb7JMBm8MGxkr1vaQD4FRk5S5U5e/M56iZc7SzysDhzO2BGeOomvnRtxsRSsg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QKCBb48RXz191k; Sun, 14 May 2023 19:25:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34EJPBAn065592; Sun, 14 May 2023 19:25:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34EJPBX7065591; Sun, 14 May 2023 19:25:11 GMT (envelope-from git) Date: Sun, 14 May 2023 19:25:11 GMT Message-Id: <202305141925.34EJPBX7065591@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Dimitry Andric Subject: git: a62f1b5796b6 - main - devel/libgit2: fix build with clang 16 List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a62f1b5796b641bb502b33f7f073238a49dc4d0c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/ports/commit/?id=a62f1b5796b641bb502b33f7f073238a49dc4d0c commit a62f1b5796b641bb502b33f7f073238a49dc4d0c Author: Dimitry Andric AuthorDate: 2023-05-14 12:26:37 +0000 Commit: Dimitry Andric CommitDate: 2023-05-14 19:23:31 +0000 devel/libgit2: fix build with clang 16 Clang 16 has a new error about incompatible function types, which shows up when building devel/libgit2: /wrkdirs/usr/ports/devel/libgit2/work/libgit2-1.5.2/src/util/util.c:731:28: error: incompatible function pointer types passing 'int (void *, const void *, const void *)' to parameter of type 'int (*)(const void *, const void *, void *)' [-Wincompatible-function-pointer-types] qsort_s(els, nel, elsize, git__qsort_r_glue_cmp, &glue); ^~~~~~~~~~~~~~~~~~~~~ /usr/include/stdlib.h:397:11: note: passing argument to parameter here int (*)(const void *, const void *, void *), void *); ^ Clang is indeed right, as the version of qsort_s(3) in FreeBSD 13 and later has the 'void *payload' parameter last: errno_t qsort_s(void *, rsize_t, rsize_t, int (*)(const void *, const void *, void *), void *); This could be fixed by putting the arguments in the right place for qsort_s(3), but it turns out the rabbit hole goes a bit deeper: on 14-CURRENT, libgit2's CMake configuration is not able to detect qsort_r(3), which is actually why it chooses qsort_s(): -- Checking prototype qsort_r for GIT_QSORT_R_BSD -- Checking prototype qsort_r for GIT_QSORT_R_BSD - False -- Checking prototype qsort_r for GIT_QSORT_R_GNU -- Checking prototype qsort_r for GIT_QSORT_R_GNU - False -- Looking for qsort_s -- Looking for qsort_s - found The problem with the GIT_QSORT_R_BSD detection is due to the check in libgit2's src/CMakeLists.txt, where it does: check_prototype_definition(qsort_r "void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))" "" "stdlib.h" GIT_QSORT_R_BSD) and CMake attempts to define a function with a similar prototype in its test program, which then fails to compile, at least on 14-CURRENT: /wrkdirs/share/dim/ports/devel/libgit2/work/.build/CMakeFiles/CMakeScratch/TryCompile-tILE28/CheckPrototypeDefinition.c:14:6: error: expected identifier or '(' void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *)) { ^ /usr/include/stdlib.h:357:5: note: expanded from macro 'qsort_r' __generic(arg5, int (*)(void *, const void *, const void *), \\ ^ /usr/include/sys/cdefs.h:323:2: note: expanded from macro '__generic' _Generic(expr, t: yes, default: no) ^ This is because in https://cgit.freebsd.org/src/commit/?id=af3c78886fd8d Ed Schouten changed the prototype of qsort_r(3) to match POSIX, using a C11 _Generic macro. When CMake tries to compile its own custom definition of qsort_r, that fails with the above compile error, because the macro gets expanded in place of the function declaration. So the summarized situation is: * On 12.x and 13.x, qsort_r(3) is a plain function, and uses the old comparison function type: 'int (*compar)(void *thunk, const void *elem1, const void *elem2)'. Therefore, CMake detects GIT_QSORT_R_BSD, and libgit2's src/util/util.c uses the correct comparison function type. * On 14.x, qsort_r(3) is a macro, and uses the POSIX comparison function type: 'int (*compar)(const void *elem1, const void *elem2, void *thunk)'. Therefore, CMake fails to detect GIT_QSORT_R_BSD, and detects GIT_QSORT_S instead, and libgit2's src/util/util.c uses an incorrect comparison function type. I submitted https://github.com/libgit2/libgit2/pull/6555 and https://github.com/libgit2/libgit2/pull/6558 upstream to remedy the situation and correctly detect all qsort variants, and these were merged with a few minor changes. This is an adjusted version of the upstream commits that applies on top of libgit-1.5.2. PR: 271234 Approved by: mfechner (maintainer) MFH: 2023Q2 --- devel/libgit2/Makefile | 1 + devel/libgit2/files/patch-github-pr6555 | 145 ++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) diff --git a/devel/libgit2/Makefile b/devel/libgit2/Makefile index 68c9edb1607e..8d2a05ddd981 100644 --- a/devel/libgit2/Makefile +++ b/devel/libgit2/Makefile @@ -6,6 +6,7 @@ PORTNAME= libgit2 DISTVERSIONPREFIX= v DISTVERSION= 1.5.2 +PORTREVISION= 1 CATEGORIES= devel MAINTAINER= mfechner@FreeBSD.org diff --git a/devel/libgit2/files/patch-github-pr6555 b/devel/libgit2/files/patch-github-pr6555 new file mode 100644 index 000000000000..99856eb18372 --- /dev/null +++ b/devel/libgit2/files/patch-github-pr6555 @@ -0,0 +1,145 @@ +--- CMakeLists.txt.orig 2023-02-15 10:03:30 UTC ++++ CMakeLists.txt +@@ -96,7 +96,7 @@ include(CheckStructHasMember) + include(CheckFunctionExists) + include(CheckSymbolExists) + include(CheckStructHasMember) +-include(CheckPrototypeDefinition) ++include(CheckPrototypeDefinitionSafe) + include(AddCFlagIfSupported) + include(FindPkgLibraries) + include(FindThreads) +--- cmake/CheckPrototypeDefinitionSafe.cmake.orig 2023-05-14 12:22:20 UTC ++++ cmake/CheckPrototypeDefinitionSafe.cmake +@@ -0,0 +1,16 @@ ++include(CheckPrototypeDefinition) ++ ++function(check_prototype_definition_safe function prototype return header variable) ++ # temporarily save CMAKE_C_FLAGS and disable warnings about unused ++ # unused functions and parameters, otherwise they will always fail ++ # if ENABLE_WERROR is on ++ set(SAVED_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") ++ ++ disable_warnings(unused-function) ++ disable_warnings(unused-parameter) ++ ++ check_prototype_definition("${function}" "${prototype}" "${return}" "${header}" "${variable}") ++ ++ # restore CMAKE_C_FLAGS ++ set(CMAKE_C_FLAGS "${SAVED_CMAKE_C_FLAGS}") ++endfunction() +--- src/CMakeLists.txt.orig 2023-02-15 10:03:30 UTC ++++ src/CMakeLists.txt +@@ -58,15 +58,29 @@ add_feature_info(futimens GIT_USE_FUTIMENS "futimens s + + # qsort + +-check_prototype_definition(qsort_r +- "void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))" +- "" "stdlib.h" GIT_QSORT_R_BSD) ++# old-style FreeBSD qsort_r() has the 'context' parameter as the first argument ++# of the comparison function: ++check_prototype_definition_safe(qsort_r ++ "void (qsort_r)(void *base, size_t nmemb, size_t size, void *context, int (*compar)(void *, const void *, const void *))" ++ "" "stdlib.h" GIT_QSORT_BSD) + +-check_prototype_definition(qsort_r +- "void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)" +- "" "stdlib.h" GIT_QSORT_R_GNU) ++# GNU or POSIX qsort_r() has the 'context' parameter as the last argument of the ++# comparison function: ++check_prototype_definition_safe(qsort_r ++ "void (qsort_r)(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *context)" ++ "" "stdlib.h" GIT_QSORT_GNU) + +-check_function_exists(qsort_s GIT_QSORT_S) ++# C11 qsort_s() has the 'context' parameter as the last argument of the ++# comparison function, and returns an error status: ++check_prototype_definition_safe(qsort_s ++ "errno_t (qsort_s)(void *base, rsize_t nmemb, rsize_t size, int (*compar)(const void *, const void *, void *), void *context)" ++ "0" "stdlib.h" GIT_QSORT_C11) ++ ++# MSC qsort_s() has the 'context' parameter as the first argument of the ++# comparison function, and as the last argument of qsort_s(): ++check_prototype_definition_safe(qsort_s ++ "void (qsort_s)(void *base, size_t num, size_t width, int (*compare )(void *, const void *, const void *), void *context)" ++ "" "stdlib.h" GIT_QSORT_MSC) + + # random / entropy data + +--- src/features.h.in.orig 2023-02-15 10:03:30 UTC ++++ src/features.h.in +@@ -24,9 +24,10 @@ + #cmakedefine GIT_REGEX_PCRE2 + #cmakedefine GIT_REGEX_BUILTIN 1 + +-#cmakedefine GIT_QSORT_R_BSD +-#cmakedefine GIT_QSORT_R_GNU +-#cmakedefine GIT_QSORT_S ++#cmakedefine GIT_QSORT_BSD ++#cmakedefine GIT_QSORT_GNU ++#cmakedefine GIT_QSORT_C11 ++#cmakedefine GIT_QSORT_MSC + + #cmakedefine GIT_SSH 1 + #cmakedefine GIT_SSH_MEMORY_CREDENTIALS 1 +--- src/util/util.c.orig 2023-02-15 10:03:30 UTC ++++ src/util/util.c +@@ -18,7 +18,7 @@ + # endif + # include + +-# ifdef GIT_QSORT_S ++# ifdef GIT_QSORT_MSC + # include + # endif + #endif +@@ -673,7 +673,7 @@ size_t git__unescape(char *str) + return (pos - str); + } + +-#if defined(GIT_QSORT_S) || defined(GIT_QSORT_R_BSD) ++#if defined(GIT_QSORT_MSC) || defined(GIT_QSORT_BSD) + typedef struct { + git__sort_r_cmp cmp; + void *payload; +@@ -688,9 +688,11 @@ static int GIT_LIBGIT2_CALL git__qsort_r_glue_cmp( + #endif + + +-#if !defined(GIT_QSORT_R_BSD) && \ +- !defined(GIT_QSORT_R_GNU) && \ +- !defined(GIT_QSORT_S) ++#if !defined(GIT_QSORT_BSD) && \ ++ !defined(GIT_QSORT_GNU) && \ ++ !defined(GIT_QSORT_C11) && \ ++ !defined(GIT_QSORT_MSC) ++ + static void swap(uint8_t *a, uint8_t *b, size_t elsize) + { + char tmp[256]; +@@ -716,17 +718,20 @@ static void insertsort( + for (j = i; j > base && cmp(j, j - elsize, payload) < 0; j -= elsize) + swap(j, j - elsize, elsize); + } ++ + #endif + + void git__qsort_r( + void *els, size_t nel, size_t elsize, git__sort_r_cmp cmp, void *payload) + { +-#if defined(GIT_QSORT_R_BSD) ++#if defined(GIT_QSORT_GNU) ++ qsort_r(els, nel, elsize, cmp, payload); ++#elif defined(GIT_QSORT_C11) ++ qsort_s(els, nel, elsize, cmp, payload); ++#elif defined(GIT_QSORT_BSD) + git__qsort_r_glue glue = { cmp, payload }; + qsort_r(els, nel, elsize, &glue, git__qsort_r_glue_cmp); +-#elif defined(GIT_QSORT_R_GNU) +- qsort_r(els, nel, elsize, cmp, payload); +-#elif defined(GIT_QSORT_S) ++#elif defined(GIT_QSORT_MSC) + git__qsort_r_glue glue = { cmp, payload }; + qsort_s(els, nel, elsize, git__qsort_r_glue_cmp, &glue); + #else