unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#15739: Doesn't support clang as well as it could.
@ 2013-10-27 19:53 Matt Sicker
  2013-11-28 19:35 ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Matt Sicker @ 2013-10-27 19:53 UTC (permalink / raw)
  To: 15739

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]

There are plenty of macros that only check for GNU GCC and don't bother
checking support from other popular compilers. For example, in
libguile/__scm.h, the macros SCM_NORETURN, SCM_UNUSED, SCM_EXPECT, and many
more, all only check for GCC support. Most (if not all) of these language
extensions are supported by Clang, and usually using the same exact syntax!

I'll submit a patch that adds Clang support to these macros. See <
http://clang.llvm.org/docs/LanguageExtensions.html> for the documentation
about this.

-- 
Matt Sicker <boards@gmail.com>

[-- Attachment #2: Type: text/html, Size: 773 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15741: Patch for bug #15739
@ 2013-10-27 22:10 Matt Sicker
  2013-11-01 22:00 ` bug#15739: Doesn't support clang as well as it could Mark H Weaver
  0 siblings, 1 reply; 6+ messages in thread
From: Matt Sicker @ 2013-10-27 22:10 UTC (permalink / raw)
  To: 15741


[-- Attachment #1.1: Type: text/plain, Size: 405 bytes --]

I noticed that clang reports to be GCC version 4.2, so most of what I
thought might be wrong wasn't. Therefore, the patch was far easier and
smaller than I expected. This isn't too high a priority, but it does add
support for clang where the code would normally check for GCC 4.3+. Clang
even supports C++ static_assert supposedly, so there's a check for that as
well.

-- 
Matt Sicker <boards@gmail.com>

[-- Attachment #1.2: Type: text/html, Size: 535 bytes --]

[-- Attachment #2: 0001-Updated-a-couple-compiler-checks-to-support-clang.patch --]
[-- Type: application/octet-stream, Size: 2856 bytes --]

From 2b02509f53a247784b4bb0be96061e46b53b0c4e Mon Sep 17 00:00:00 2001
From: Matt Sicker <boards@gmail.com>
Date: Sun, 27 Oct 2013 16:54:06 -0500
Subject: [PATCH] Updated a couple compiler checks to support clang.

* lib/poll.c [__clang__]: Same functionality as GCC 4.3+ for ignoring
  the (nfd < 0) tests.
* lib/verify.h [__has_feature(c_static_assert)]: Enables
  _GL_HAVE__STATIC_ASSERT when clang feature is available for C.
* lib/verify.h [__has_feature(cxx_static_assert)]: Enables
* _GL_HAVE_STATIC_ASSERT when clang feature is available for C++.
* See bug #15739
---
 lib/poll.c   |  4 ++--
 lib/verify.h | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/poll.c b/lib/poll.c
index 2767f5a..3b82522 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU Lesser General Public License along
    with this program; if not, see <http://www.gnu.org/licenses/>.  */
 
-/* Tell gcc not to warn about the (nfd < 0) tests, below.  */
-#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+/* Tell gcc (or clang) not to warn about the (nfd < 0) tests, below.  */
+#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ || defined __clang__
 # pragma GCC diagnostic ignored "-Wtype-limits"
 #endif
 
diff --git a/lib/verify.h b/lib/verify.h
index 40b8ef5..d04e8b2 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -20,23 +20,29 @@
 #ifndef _GL_VERIFY_H
 # define _GL_VERIFY_H
 
+/* Compatibility for non-clang compilers */
+# ifndef __has_feature
+#  define __has_feature(x) 0
+# endif
 
 /* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11.
    This is supported by GCC 4.6.0 and later, in C mode, and its use
    here generates easier-to-read diagnostics when verify (R) fails.
+   This is supported by clang when the c_static_assert feature is set.
 
    Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11.
    This will likely be supported by future GCC versions, in C++ mode.
+   This is supported by clang when the cxx_static_assert feature is set.
 
    Use this only with GCC.  If we were willing to slow 'configure'
    down we could also use it with other compilers, but since this
    affects only the quality of diagnostics, why bother?  */
-# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined __cplusplus
+# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || __has_feature(c_static_assert)) && !defined __cplusplus
 #  define _GL_HAVE__STATIC_ASSERT 1
 # endif
 /* The condition (99 < __GNUC__) is temporary, until we know about the
    first G++ release that supports static_assert.  */
-# if (99 < __GNUC__) && defined __cplusplus
+# if ((99 < __GNUC__) || __has_feature(cxx_static_assert)) && defined __cplusplus
 #  define _GL_HAVE_STATIC_ASSERT 1
 # endif
 
-- 
1.8.4.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#15739: Doesn't support clang as well as it could.
  2013-10-27 22:10 bug#15741: Patch for bug #15739 Matt Sicker
@ 2013-11-01 22:00 ` Mark H Weaver
  0 siblings, 0 replies; 6+ messages in thread
From: Mark H Weaver @ 2013-11-01 22:00 UTC (permalink / raw)
  To: Matt Sicker; +Cc: 15739-done

Hi Matt,

Matt Sicker <boards@gmail.com> writes:
> I noticed that clang reports to be GCC version 4.2, so most of what I
> thought might be wrong wasn't. Therefore, the patch was far easier and
> smaller than I expected. This isn't too high a priority, but it does
> add support for clang where the code would normally check for GCC
> 4.3+. Clang even supports C++ static_assert supposedly, so there's a
> check for that as well.
>
> -- 
> Matt Sicker <boards@gmail.com> 
>
>
> From 2b02509f53a247784b4bb0be96061e46b53b0c4e Mon Sep 17 00:00:00 2001
> From: Matt Sicker <boards@gmail.com>
> Date: Sun, 27 Oct 2013 16:54:06 -0500
> Subject: [PATCH] Updated a couple compiler checks to support clang.
>
> * lib/poll.c [__clang__]: Same functionality as GCC 4.3+ for ignoring
>   the (nfd < 0) tests.
> * lib/verify.h [__has_feature(c_static_assert)]: Enables
>   _GL_HAVE__STATIC_ASSERT when clang feature is available for C.
> * lib/verify.h [__has_feature(cxx_static_assert)]: Enables
> * _GL_HAVE_STATIC_ASSERT when clang feature is available for C++.

Both of these files are part of gnulib.  As a matter of policy, we do
not change those files in our repository.  Instead we update from
gnulib's repository from time to time.

Can you please send this problem report and patch to
<bug-gnulib@gnu.org> ?

I'm closing this bug, since there's nothing for us to do in Guile.  If
you find any clang-related problems in Guile itself, please let us know.

     Thanks,
       Mark





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15739: Doesn't support clang as well as it could.
  2013-10-27 19:53 Matt Sicker
@ 2013-11-28 19:35 ` Ludovic Courtès
  2013-12-01  1:30   ` Matt Sicker
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2013-11-28 19:35 UTC (permalink / raw)
  To: Matt Sicker; +Cc: 15739

Hi,

Matt Sicker <boards@gmail.com> skribis:

> There are plenty of macros that only check for GNU GCC and don't bother
> checking support from other popular compilers. For example, in
> libguile/__scm.h, the macros SCM_NORETURN, SCM_UNUSED, SCM_EXPECT, and many
> more, all only check for GCC support. Most (if not all) of these language
> extensions are supported by Clang, and usually using the same exact syntax!

Doesn’t Clang still define __GNUC__?  If it does, then it has to behave
like GCC, and thus nothing Clang-specific needs to be added.

Ludo’.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15739: Doesn't support clang as well as it could.
  2013-11-28 19:35 ` Ludovic Courtès
@ 2013-12-01  1:30   ` Matt Sicker
  2013-12-01 22:09     ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Matt Sicker @ 2013-12-01  1:30 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 15739

[-- Attachment #1: Type: text/plain, Size: 296 bytes --]

On 28 November 2013 13:35, Ludovic Courtès <ludo@gnu.org> wrote:
>
> Doesn’t Clang still define __GNUC__?  If it does, then it has to behave
> like GCC, and thus nothing Clang-specific needs to be added.
>

Yeah, turns out it's a different issue.

-- 
Matt Sicker <boards@gmail.com>

[-- Attachment #2: Type: text/html, Size: 757 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15739: Doesn't support clang as well as it could.
  2013-12-01  1:30   ` Matt Sicker
@ 2013-12-01 22:09     ` Ludovic Courtès
  0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2013-12-01 22:09 UTC (permalink / raw)
  To: Matt Sicker; +Cc: 15739-done

Matt Sicker <boards@gmail.com> skribis:

> On 28 November 2013 13:35, Ludovic Courtès <ludo@gnu.org> wrote:
>>
>> Doesn’t Clang still define __GNUC__?  If it does, then it has to behave
>> like GCC, and thus nothing Clang-specific needs to be added.
>>
>
> Yeah, turns out it's a different issue.

Thanks for letting us know.  I’m closing the bug now.

Ludo’.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-12-01 22:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-27 22:10 bug#15741: Patch for bug #15739 Matt Sicker
2013-11-01 22:00 ` bug#15739: Doesn't support clang as well as it could Mark H Weaver
  -- strict thread matches above, loose matches on Subject: below --
2013-10-27 19:53 Matt Sicker
2013-11-28 19:35 ` Ludovic Courtès
2013-12-01  1:30   ` Matt Sicker
2013-12-01 22:09     ` Ludovic Courtès

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).