From nobody Fri Jun 21 15:52:48 2024 X-Original-To: dev-commits-src-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 4W5MM43F8Sz5Nsrd; Fri, 21 Jun 2024 15:52:48 +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 4W5MM42jkJz41Zn; Fri, 21 Jun 2024 15:52:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718985168; 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=Sz0kO/qa7G5Ud2xlf2f0iVZt41Hr8KZmFsvf9Diw3hc=; b=Icedzj13xo1s8HaEj5TJVaXiA7l1OtA/W/wbcFn2+4GzxETg+KA2acPocFdtYTkxrkjecx Cf1AHhVrQsdvKm3GW2HgmLaajnuK6g85XAskCO96jFA86ZtdnsG+m40sdyoM86C54aXGy/ Q95CHkz2gMci5X1U0hJqe78KKC9yfx7tlS9qSTC3Ji9k3y2HGQNvofMFB0kCzc6fqIBq+S Heu8ODXzHqDlTU5U9FTQzYassnvg0hC/3qV2vDNmDqHCaDLZHhGSD+hw/SzDTa3rE5SssR TG6GCJJ1dEboKCx9RF4L+PHS9JNR4zn+NcCUPJJhMiGSTTMjYm7B+p6gkii45w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718985168; a=rsa-sha256; cv=none; b=QAs+nEp3ICbPi5wpd2AT+ouDG+clao7DOwvPRJmuBH2UX7Yo2RswkFmRg+BThkLz6SKuYn xQr03cKfEctiAErHawyC7lhHWzH5Fx2yBVtuvgcOfOAtmwWF2Mg1704ahsVZTUuOE1lLxh O6zLkEGFBIXvRsn9aF9AA0XPyt2nSEmjQKm9QH62OAAgYU9nereGCb01h3vc4cCrMxpnib 60jygWEFdU8nAM5mW+YV/cgA4CP2luFK1KSgH20rO8SiKCebnBAvq71x7qhIO65FzfyMY+ 9LZf9NyXaydPp1zyKuDilrJrwEQ/q09LigXuO3vGOxtsQr21ZsvoEplCQ0vuCg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718985168; 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=Sz0kO/qa7G5Ud2xlf2f0iVZt41Hr8KZmFsvf9Diw3hc=; b=OzIu4veOus15a0L4lQGmVs0DWqyqSFCl2hIiN+cAReKDFNiUylX06QFc3H/Va71HQ541pA h9zTjxXI0Fwnn5p5gl4MUQ9rXCg9cC5VBZWF9HileaUWqp+RCL2hwYbOZrbSgNtJOTcbsq fa+WJCKV6ZoPF4aCcH50yF6gWQpcHZqEcQws6c79+llKxWY7fSGZswSpfAZwtE2xhiMFUM 3UntclJBc/OwmNxAeJJBgnogVh1g627xvrMRpS0c4w+WmaxSu0YXGNEy91nhncbrgIkHSA tW6rc6Izqnfob25FjQ/ZezS8bm2skl18i6Tc30gyICRSYFdsh57imle4G7KONA== 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 4W5MM42K9HzDq0; Fri, 21 Jun 2024 15:52:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45LFqmeG097645; Fri, 21 Jun 2024 15:52:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45LFqmtP097642; Fri, 21 Jun 2024 15:52:48 GMT (envelope-from git) Date: Fri, 21 Jun 2024 15:52:48 GMT Message-Id: <202406211552.45LFqmtP097642@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 4a86b26b84be - main - stdlib: Support compiling with tinyc by omitting compat qsort code List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4a86b26b84be2888c70a04f216734bf1456ee766 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4a86b26b84be2888c70a04f216734bf1456ee766 commit 4a86b26b84be2888c70a04f216734bf1456ee766 Author: Warner Losh AuthorDate: 2024-06-21 15:48:41 +0000 Commit: Warner Losh CommitDate: 2024-06-21 15:53:07 +0000 stdlib: Support compiling with tinyc by omitting compat qsort code TinyC doesn't support the .symver assembler directive. Add a generic way to signal this and use that not to define __sym_() macros that use it. Only use the __sym_* macros in headers when they are defined (which currently is only for the qsort_r compat code. Not supporting this for tcc is fine: It's an edge case for legacy binaries / code anyway which isn't relevant to tinyc. Sponsored by: Netflix Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D45651 --- include/stdlib.h | 17 ++++++++++------- sys/sys/cdefs.h | 13 +++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/include/stdlib.h b/include/stdlib.h index c1c8ab5eebb3..db339688cb78 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -330,23 +330,26 @@ __uint64_t * parameter, and both are different from the ones expected by the historical * FreeBSD qsort_r() interface. * - * Apply a workaround where we explicitly link against the historical - * interface, qsort_r@FBSD_1.0, in case when qsort_r() is called with - * the last parameter with a function pointer that exactly matches the - * historical FreeBSD qsort_r() comparator signature, so applications - * written for the historical interface can continue to work without - * modification. + * Apply a workaround where we explicitly link against the historical interface, + * qsort_r@FBSD_1.0, in case when qsort_r() is called with the last parameter + * with a function pointer that exactly matches the historical FreeBSD qsort_r() + * comparator signature, so applications written for the historical interface + * can continue to work without modification. Toolchains that don't support + * symbol versioning don't define __sym_compat, so only provide this symbol in + * supported environments. */ +#ifdef __sym_compat #if defined(__generic) || defined(__cplusplus) void __qsort_r_compat(void *, size_t, size_t, void *, int (*)(void *, const void *, const void *)); __sym_compat(qsort_r, __qsort_r_compat, FBSD_1.0); #endif +#endif #if defined(__generic) && !defined(__cplusplus) #define qsort_r(base, nel, width, arg4, arg5) \ __generic(arg5, int (*)(void *, const void *, const void *), \ __qsort_r_compat, qsort_r)(base, nel, width, arg4, arg5) -#elif defined(__cplusplus) +#elif defined(__cplusplus) && defined(__sym_compat) __END_DECLS extern "C++" { static inline void qsort_r(void *base, size_t nmemb, size_t size, diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 43d179b82020..419fc260f200 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -90,9 +90,18 @@ #define __compiler_membar() __asm __volatile(" " : : : "memory") #define __CC_SUPPORTS___INLINE 1 +#define __CC_SUPPORTS_SYMVER 1 #endif /* __GNUC__ */ +/* + * TinyC pretends to be gcc 9.3. This is generally good enough to support + * everything FreeBSD... except for the .symver assembler directive. + */ +#ifdef __TINYC__ +#undef __CC_SUPPORTS_SYMVER +#endif + /* * The __CONCAT macro is used to concatenate parts of symbol names, e.g. * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. @@ -369,10 +378,12 @@ __asm__(".section .gnu.warning." #sym); \ __asm__(".asciz \"" msg "\""); \ __asm__(".previous") +#ifdef __CC_SUPPORTS_SYMVER #define __sym_compat(sym,impl,verid) \ __asm__(".symver " #impl ", " #sym "@" #verid) #define __sym_default(sym,impl,verid) \ __asm__(".symver " #impl ", " #sym "@@@" #verid) +#endif #else #define __weak_reference(sym,alias) \ __asm__(".weak alias"); \ @@ -381,10 +392,12 @@ __asm__(".section .gnu.warning.sym"); \ __asm__(".asciz \"msg\""); \ __asm__(".previous") +#ifdef __CC_SUPPORTS_SYMVER #define __sym_compat(sym,impl,verid) \ __asm__(".symver impl, sym@verid") #define __sym_default(impl,sym,verid) \ __asm__(".symver impl, sym@@@verid") +#endif #endif /* __STDC__ */ #define __GLOBL(sym) __asm__(".globl " __XSTRING(sym))