Skip to content

ucs: portability fixes for non-glibc / Clang environments#11354

Open
GenericRikka wants to merge 1 commit intoopenucx:masterfrom
GenericRikka:portability/ucs-misc
Open

ucs: portability fixes for non-glibc / Clang environments#11354
GenericRikka wants to merge 1 commit intoopenucx:masterfrom
GenericRikka:portability/ucs-misc

Conversation

@GenericRikka
Copy link
Copy Markdown
Contributor

UCS: portability fixes for non-glibc/Clang environments

This PR addresses a set of portability issues in the UCS layer that
prevent UCX from building cleanly with Clang and/or non-glibc libc
implementations such as FreeBSD libc or musl. All changes are confined
to UCS and have no effect on the wire protocol or ABI.

Changes

sys.h / log.c — portable hostname buffer size (UCS_HOST_NAME_MAX)

HOST_NAME_MAX is a Linux/glibc extension and is not defined by POSIX.
Introduce UCS_HOST_NAME_MAX derived from _POSIX_HOST_NAME_MAX (the
POSIX-mandated minimum of 255) with a fallback of 256, and use it
unconditionally in the hostname buffer in log.c. The <limits.h> and
<unistd.h> includes required to expose _POSIX_HOST_NAME_MAX are
added to sys.h.

compiler.hUCS_F_NOOPTIMIZE with Clang

Clang does not support GCC's __attribute__((optimize("O0"))) and
silently ignores it, producing no-op behaviour for UCS_F_NOOPTIMIZE.
Clang provides the equivalent __attribute__((optnone)). Restructure
the macro into a clean three-branch #if/#elif/#else so each
compiler gets the correct attribute.

float8.h — remove dependency on <ieee754.h>

<ieee754.h> defines union ieee754_double using C bitfields to
decompose double-precision floats. This header is a glibc extension
absent from other libc implementations. Replace the bitfield-based
access with portable memcpy-based helpers (ucs_double_to_words /
ucs_words_to_double) that inspect the IEEE 754 bit layout without
undefined behaviour, using FLOAT_WORDS_BIGENDIAN (already defined by
UCX's autoconf) for endianness.

aarch64/cpu.h — explicit <ucs/sys/ptr_arith.h> include

The AArch64 CPU header uses macros from ptr_arith.h but relied on
transitive inclusion. Add the direct include to make the dependency
explicit and guard against breakage if include order changes.

debug.c — explicit <signal.h> and <stdlib.h> includes

debug.c uses signal-related types and stdlib functions without
including the corresponding headers directly. Add explicit includes.

numa.c — replace __CPU_SETSIZE with UCS_CPU_SETSIZE

numa.c used the glibc-internal __CPU_SETSIZE (double-underscore
reserved namespace). UCX already defines UCS_CPU_SETSIZE in
<ucs/type/cpu_set.h>, which is available transitively via
<ucs/sys/sys.h>, already included by numa.c. Remove the
now-redundant fallback block and replace all three use sites with
UCS_CPU_SETSIZE. Using the UCX-internal constant is also semantically
correct: the NUMA CPU cache bound should align with UCX's own CPU set
abstraction, not the platform's reported CPU_SETSIZE.

@GenericRikka GenericRikka force-pushed the portability/ucs-misc branch from d927ab5 to 5cdc7f6 Compare April 19, 2026 00:04
Comment thread src/ucs/type/float8.h
#ifndef UCS_TYPE_FLOAT_H
#define UCS_TYPE_FLOAT_H

#include <ieee754.h>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can simply manually define union ieee754_double when it is missing, and avoid most of the changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants