[all-commits] [llvm/llvm-project] 43c26b: [libc] don't over include stdlib in the hdr declar...

Nick Desaulniers via All-commits all-commits at lists.llvm.org
Mon Apr 22 11:51:22 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 43c26bbc425dbd8caee311a0d5e4d90c8e71d0d8
      https://github.com/llvm/llvm-project/commit/43c26bbc425dbd8caee311a0d5e4d90c8e71d0d8
  Author: Nick Desaulniers <nickdesaulniers at users.noreply.github.com>
  Date:   2024-04-22 (Mon, 22 Apr 2024)

  Changed paths:
    M libc/src/stdlib/bsearch.h

  Log Message:
  -----------
  [libc] don't over include stdlib in the hdr declaring bsearch (#89471)

When building overlay mode with GCC in release mode, glibc's stdlib.h
contains
an extern inline declaration of bsearch. This breaks our use of the
gnu::alias
function attribute in LLVM_LIBC_FUNCTION with GCC because GCC checks
that the
aliasee is defined in the same TU (clang does not).

We're looking at also potentially updating our definition of
LLVM_LIBC_FUNCTION
from libc/src/__support/common.h. Upon testing, I was able to get
-Wnonnull-compare diagnostics from GCC in our definition of bsearch
because
glibc declares bsearch with the fugly nonnull function attribute.

There's more we can do here though to improve our implementation of
bsearch.
7.24.5.1 says:

    Pointer arguments on such a call shall still have valid values, as
    described in 7.1.4.

We could also use either function attributes or parameter attributes to
denote
these should not be null (for users/callers) and perhaps still check for
non-null explicitly under some yet to be discussed hardening
configurations in
the future.

Link: #60481
Link:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-nonnull-function-attribute



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list