[MacPorts] #66087: got fails to build: Undefined symbols: "_memset_s"
MacPorts
noreply at macports.org
Fri Oct 28 03:23:28 UTC 2022
#66087: got fails to build: Undefined symbols: "_memset_s"
---------------------------+----------------------
Reporter: barracuda156 | Owner: artkiver
Type: defect | Status: assigned
Priority: Normal | Milestone:
Component: ports | Version: 2.8.0
Resolution: | Keywords:
Port: got |
---------------------------+----------------------
Comment (by barracuda156):
Replying to [comment:6 kencu]:
> the other way to approach this is for upstream to test for and only use
memset_s if the symbol exists, otherwise fall back (presumably) to memset.
`samba4` has this:
{{{
#ifndef HAVE_MEMSET_S
# ifndef RSIZE_MAX
# define RSIZE_MAX (SIZE_MAX >> 1)
# endif
int rep_memset_s(void *dest, size_t destsz, int ch, size_t count)
{
if (dest == NULL) {
return EINVAL;
}
if (destsz > RSIZE_MAX ||
count > RSIZE_MAX ||
count > destsz) {
return ERANGE;
}
#if defined(HAVE_MEMSET_EXPLICIT)
memset_explicit(dest, destsz, ch, count);
#else /* HAVE_MEMSET_EXPLICIT */
memset(dest, ch, count);
# if defined(HAVE_GCC_VOLATILE_MEMORY_PROTECTION)
/* See http://llvm.org/bugs/show_bug.cgi?id=15495 */
__asm__ volatile("" : : "g"(dest) : "memory");
# endif /* HAVE_GCC_VOLATILE_MEMORY_PROTECTION */
#endif /* HAVE_MEMSET_EXPLICIT */
return 0;
}
#endif /* HAVE_MEMSET_S */
}}}
And `postgresql` has:
{{{
#if defined(HAVE_MEMSET_S)
void
explicit_bzero(void *buf, size_t len)
{
(void) memset_s(buf, len, 0, len);
}
#elif defined(WIN32)
void
explicit_bzero(void *buf, size_t len)
{
(void) SecureZeroMemory(buf, len);
}
#else
/*
* Indirect call through a volatile pointer to hopefully avoid dead-store
* optimisation eliminating the call. (Idea taken from OpenSSH.) We
can't
* assume bzero() is present either, so for simplicity we define our own.
*/
static void
bzero2(void *buf, size_t len)
{
memset(buf, 0, len);
}
static void (*volatile bzero_p) (void *, size_t) = bzero2;
void
explicit_bzero(void *buf, size_t len)
{
bzero_p(buf, len);
}
#endif
}}}
Anything is this usable? A check for HAVE_MEMSET_S is easily added to
configure.
--
Ticket URL: <https://trac.macports.org/ticket/66087#comment:7>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list