From nobody Wed May 03 20:11:58 2023 X-Original-To: ports-bugs@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 4QBSlg1nQHz49D4Q for ; Wed, 3 May 2023 20:11:59 +0000 (UTC) (envelope-from bugzilla-noreply@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 4QBSlg0f14z3pFf for ; Wed, 3 May 2023 20:11:59 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683144719; 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=Ar3RJMwRPXHrsa9pX+xGoxOv2ReFEPVEXkay+XXdMSc=; b=yQLlaNSchZHQlnC85fk7vHJK8d+5ynvU1pm+EKHki6ONO9+DMU1sDpUwh5gaevs2qy8VCw ntonYsLVGucyySOf7NPt1DlOv2DrlTatVqpzNQpSE5smpelxQbIweIpn0myHR399TA/zgU C4+uS7kpu0MqZsEK61h1U09BJkI0/qQkhUkG2ZF7hr9cMlOujZAE1wjQwBIArpYCvhOnub kfaQRcf/FfTiXBeenkw2thmXxy2R5UH46svkYL3q/m352hOY6mUO/PhwlwVWbHf/6ggede LNE/Bh6aSH8kw3GuGmd4qXxI+9tZzam1pKJwkMJK0Rz9gzvp9Hx5mS35xvEWbQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683144719; a=rsa-sha256; cv=none; b=yg8BTLFRuAThWjQKwYvcxU+i/C603w3RrjyFY685TgT5UYZEQFzorvuH4b9sIBnXNqsqKF uhyhSy0fq2E3Gh6lZXF1yI+U5jnKWAHmmglqZ2xjdY9uSoDNU/dTQr/t67n1YaYiW0nD/i 8EGLf0HeNTEuNdrHEJHXyumkTNtGKyoHdlZ1qpyVVKOSO2LPh9gTPpj9WyRfvMXqZGWk9U +78LUatswMXl4mxPL4W7I7k+BMjpkZSWieTdOBV1ej1AdPU5xrljFkxo2BvbRI2odMobyN oqbReOoyf0dGlrOxlJwFQbCpoLWL/FMhMi/OVVHdsS/0K7rc1M2dRN3OdNu2WQ== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 4QBSlf6rtjzkBG for ; Wed, 3 May 2023 20:11:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 343KBw1l034347 for ; Wed, 3 May 2023 20:11:58 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 343KBwWx034346 for ports-bugs@FreeBSD.org; Wed, 3 May 2023 20:11:58 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: ports-bugs@FreeBSD.org Subject: [Bug 271234] devel/libgit2: qsort_r/qsort_s issues on 14-CURRENT Date: Wed, 03 May 2023 20:11:58 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Ports & Packages X-Bugzilla-Component: Individual Port(s) X-Bugzilla-Version: Latest X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: dim@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: mfechner@FreeBSD.org X-Bugzilla-Flags: maintainer-feedback? X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter flagtypes.name Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Ports bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-ports-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-ports-bugs@freebsd.org X-BeenThere: freebsd-ports-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D271234 Bug ID: 271234 Summary: devel/libgit2: qsort_r/qsort_s issues on 14-CURRENT Product: Ports & Packages Version: Latest Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: Individual Port(s) Assignee: mfechner@FreeBSD.org Reporter: dim@FreeBSD.org Assignee: mfechner@FreeBSD.org Flags: maintainer-feedback?(mfechner@FreeBSD.org) During an exp-run for llvm 16 (see bug 271047), it turned out that devel/libgit2 failed to build with clang 16: /wrkdirs/usr/ports/devel/libgit2/work/libgit2-1.5.2/src/util/util.c:731:2= 8: error: incompatible function pointer types passing 'int (void *, const void= *, const void *)' to parameter of type 'int (*)(const void *, const void *, vo= id *)' [-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 libgi= t2'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: =20 /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=3Daf3c78886fd8d = 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 compar= ison 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 u= ses the correct comparison function type. * On 14.x, qsort_r(3) is a macro, and uses the POSIX comparison function ty= pe: '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. Possible fixes include: * Adding __FreeBSD_version check, although base commit af3c78886fd8d did not bump the version * Adding additional CMake logic to correctly work around the _Generic macro definition in 14.x's stdlib.h * Fixing CMake's check_prototype_definition() = to put parentheses around the checked function names * ... haven't thought or more possible fixes here, suggestions welcome Preferably, any fix should be upstreamable. --=20 You are receiving this mail because: You are the assignee for the bug.=