Page MenuHomeFreeBSD

cross-build: fix bootstrap with clang 19 on glibc systems
Needs ReviewPublic

Authored by arichardson on Sep 14 2025, 9:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 12, 6:35 PM
Unknown Object (File)
Sat, Oct 11, 2:58 PM
Unknown Object (File)
Fri, Oct 10, 9:49 PM
Unknown Object (File)
Fri, Oct 10, 9:49 PM
Unknown Object (File)
Fri, Oct 10, 3:59 PM
Unknown Object (File)
Fri, Oct 10, 4:21 AM
Unknown Object (File)
Sat, Oct 4, 11:34 AM
Unknown Object (File)
Sat, Oct 4, 2:35 AM
Subscribers

Details

Reviewers
jrtc27
emaste
jhb
markj
Group Reviewers
krb5
Summary

glibc defines two versions of strerror_r, the char* returning one is used
when _GNU_SOURCE is defined. This triggers a -Wint-conversion error in
the krb5 strerror_r wrapper, but until clang 19 this was just a normal
warning, now it defaults to being an error.

/home/runner/work/freebsd-src/freebsd-src/crypto/krb5/src/util/support/strerror_r.c: In function ‘k5_strerror_r’:
/home/runner/work/freebsd-src/freebsd-src/crypto/krb5/src/util/support/strerror_r.c:94:12: warning: returning ‘char *’ from a function with return type ‘int’ makes integer from pointer without a cast [-Wint-conversion]

94 |     return strerror_r(errnum, buf, buflen);
   |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This was not caught by the GitHub CI since it still builds with clang 18
on the Linux runners. Add -Werror=int-conversion to the build flags to
catch errors like this in the future.

MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 67018
Build 63901: arc lint + arc unit

Event Timeline

krb5/include/autoconf.h
701

Don't we know how we're configuring krb5 and therefore which feature macros are being enabled? Can this not just be a __GLIBC__ check? Or even __gnu_linux__ which I think won't be set for musl and comes from the compiler itself, though Clang doesn't do the right thing there, it defines it for any Linux that's not Android, regardless of libc...

krb5/include/autoconf.h
701

We add -D_GNU_SOURCE, but this header is included before any other system headers so GLIBC will not be defined without features.h.

Looking at LLVM's OSTargets.h, it seems like gnu_linux is defined for everything other than Android, so we can't use that. I felt that including features.h was the least ugly workaround but happy if there is a better way. I haven't looked into what musl does, but I imagine it matches, so maybe we can just use linux?

Okay it looks like musl does not have the weird char* strerror_r: https://git.musl-libc.org/cgit/musl/tree/include/string.h#n66, so it will need to be conditional on glibc.