From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: Re: fixes for Clang builtins when compiling Emacs on Fedora
Date: Tue, 18 Aug 2020 01:37:20 +0200 [thread overview]
Message-ID: <2538007.71trb2julv@omega> (raw)
In-Reply-To: <5e607e6f-ee3a-41bc-67eb-cdc0571d00d0@cs.ucla.edu>
Hi Paul,
> I had a couple of problems with the recent Clang-related fixes on Fedora 31 when
> building Emacs, and worked around them by installing the attached patches
Yes, things are a bit more complicated in practice than in theory... I have just
completed the testing on FreeBSD 12, and will test on OpenBSD and macOS next.
> + libc-config: avoid Clang’s __diagnose_if__
> + * lib/cdefs.h (__warndecl, __warnattr, __errordecl):
> + For now, do not use __diagnose_if__ here, as this fails
> + on Fedora 31 with Clang 9.0.1, with diagnostic
> + "/usr/include/bits/stdio2.h:263:9: error: fgets called with bigger
> + size than length of destination buffer
This is a pity, because these user-defined diagnostics are useful, and
clang does not have __attribute__((__warning__ ...)) that GCC has.
This piece of code in stdio2.h looks like this:
extern char *__REDIRECT (__fgets_chk_warn,
(char *__restrict __s, size_t __size, int __n,
FILE *__restrict __stream), __fgets_chk)
__wur __warnattr ("fgets called with bigger size than length "
"of destination buffer");
__fortify_function __wur char *
fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
{
if (__bos (__s) != (size_t) -1)
{
if (!__builtin_constant_p (__n) || __n <= 0)
return __fgets_chk (__s, __bos (__s), __n, __stream);
if ((size_t) __n > __bos (__s))
return __fgets_chk_warn (__s, __bos (__s), __n, __stream); // <=== line 263
}
return __fgets_alias (__s, __n, __stream);
}
Most likely the cause is that __bos (__s) currently evaluates to 0,
because I did not port the __bos macro, because the corresponding
attribute works differently in clang than in GCC
<https://clang.llvm.org/docs/AttributeReference.html#alloc-size>.
If you have time to finish this corner of clang support, please go
ahead!
> + Avoid Clang’s __builtin_assume, as clang 9.0.1 -Wassume can
> + generate a bogus diagnostic "the argument to '__builtin_assume' has
> + side effects that will be discarded" even when the argument has no
> + side effects. */
Do you have a test case, that we could check on clang 10 and on future
clang versions?
Bruno
next prev parent reply other threads:[~2020-08-17 23:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-17 22:02 fixes for Clang builtins when compiling Emacs on Fedora Paul Eggert
2020-08-17 23:37 ` Bruno Haible [this message]
2020-08-18 1:10 ` Paul Eggert
2020-08-22 10:30 ` Clang __built_assume Bruno Haible
2020-08-22 17:32 ` Paul Eggert
2020-08-22 23:01 ` Clang __builtin_assume Bruno Haible
2020-08-23 13:46 ` clang's __diagnose_if__ and glibc fortify Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2538007.71trb2julv@omega \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
--cc=eggert@cs.ucla.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).