GNU bug report logs - #41467
Compiling extensions using Guile 3.0.2 headers doesn't work with clang without -std=c11

Previous Next

Package: guile;

Reported by: Vadim Zeitlin <vz-gnuguile <at> zeitlins.org>

Date: Fri, 22 May 2020 22:06:02 UTC

Severity: normal

To reply to this bug, email your comments to 41467 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#41467; Package guile. (Fri, 22 May 2020 22:06:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vadim Zeitlin <vz-gnuguile <at> zeitlins.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Fri, 22 May 2020 22:06:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Vadim Zeitlin <vz-gnuguile <at> zeitlins.org>
To: bug-guile <at> gnu.org
Subject: Compiling extensions using Guile 3.0.2 headers doesn't work with
 clang without -std=c11
Date: Fri, 22 May 2020 22:42:00 +0200
[Message part 1 (text/plain, INLINE)]
 Hello,

 I'm am not sure how useful this is because I don't know anything about
Guile, but I contribute to the SWIG project which generates Guile bindings
among other things and I noticed that one of the CI builds started failing
since the upgrade from 2.2.7 to 3.0.2 version due to the errors like this:

---------------------------------- >8 --------------------------------------
In file included from example_wrap.c:739:
In file included from /usr/local/Cellar/guile/3.0.2/include/guile/3.0/libguile.h:35:
In file included from /usr/local/Cellar/guile/3.0.2/include/guile/3.0/libguile/array-handle.h:27:
In file included from /usr/local/Cellar/guile/3.0.2/include/guile/3.0/libguile/numbers.h:29:
/usr/local/Cellar/guile/3.0.2/include/guile/3.0/libguile/print.h:79:3: error: redefinition of typedef 'scm_print_state' is a C11 feature [-Werror,-Wtypedef-redefinition]
} scm_print_state;
  ^
/usr/local/Cellar/guile/3.0.2/include/guile/3.0/libguile/scm.h:824:32: note: previous definition is here
typedef struct scm_print_state scm_print_state;
                               ^
In file included from example_wrap.c:739:
In file included from /usr/local/Cellar/guile/3.0.2/include/guile/3.0/libguile.h:38:
In file included from /usr/local/Cellar/guile/3.0.2/include/guile/3.0/libguile/async.h:25:
In file included from /usr/local/Cellar/guile/3.0.2/include/guile/3.0/libguile/threads.h:27:
/usr/local/Cellar/guile/3.0.2/include/guile/3.0/libguile/dynstack.h:37:3: error: redefinition of typedef 'scm_t_dynstack' is a C11 feature [-Werror,-Wtypedef-redefinition]
} scm_t_dynstack;
  ^
/usr/local/Cellar/guile/3.0.2/include/guile/3.0/libguile/scm.h:825:29: note: previous definition is here
typedef struct scm_dynstack scm_t_dynstack;
                            ^
---------------------------------- >8 --------------------------------------

(see e.g. https://travis-ci.org/github/swig/swig/jobs/683649601 for the
actual build output).

 We're going to work around this in SWIG by adding -std=c11 to the compiler
options, but it would probably be better to avoid this problem without it
too, unless Guile really requires C11.

 Best regards,
VZ
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#41467; Package guile. (Tue, 01 Aug 2023 01:40:02 GMT) Full text and rfc822 format available.

Message #8 received at 41467 <at> debbugs.gnu.org (full text, mbox):

From: Sevan Janiyan <venture37 <at> geeklan.co.uk>
To: 41467 <at> debbugs.gnu.org
Subject: Re: Compiling extensions using Guile 3.0.2 headers doesn't work with
 clang without -std=c11
Date: Tue, 1 Aug 2023 02:38:57 +0100
Hi,
Redefinitions are part of C11 and compilers which support C11 and 
default to C11 mode would have masked the issue which is why we are 
here. Because of the redefinitions, it is not possible to build Guile 
with older compilers which only support C99.
I hit this issue attempting to build Guile 3.0.9 with GCC 4.0.1.
The first error being
  CC       libgnu_la-regex.lo
In file included from ../libguile/threads.h:27,
                 from glthread/lock.h:27,
                 from regex_internal.h:56,
                 from regex.c:71:
../libguile/dynstack.h:37: error: redefinition of typedef 'scm_t_dynstack'
../libguile/scm.h:825: error: previous declaration of 'scm_t_dynstack' 
was here
In file included from ../libguile/smob.h:28,
                 from ../libguile/threads.h:29,
                 from glthread/lock.h:27,
                 from regex_internal.h:56,
                 from regex.c:71:
../libguile/print.h:79: error: redefinition of typedef 'scm_print_state'
../libguile/scm.h:824: error: previous declaration of 'scm_print_state' 
was here
make[4]: *** [libgnu_la-regex.lo] Error 1

There's more issues after addressing these. I will follow up with a 
patch of what I took out for the build to succeed (not necessarily 
correct but to highlight where the issues are).


Sevan




Information forwarded to bug-guile <at> gnu.org:
bug#41467; Package guile. (Tue, 01 Aug 2023 11:12:01 GMT) Full text and rfc822 format available.

Message #11 received at 41467 <at> debbugs.gnu.org (full text, mbox):

From: Sevan Janiyan <venture37 <at> geeklan.co.uk>
To: 41467 <at> debbugs.gnu.org
Subject: Re: Compiling extensions using Guile 3.0.2 headers doesn't work with
 clang without -std=c11
Date: Tue, 1 Aug 2023 12:11:28 +0100
On 01/08/2023 02:38, Sevan Janiyan wrote:
> There's more issues after addressing these. I will follow up with a 
> patch of what I took out for the build to succeed (not necessarily 
> correct but to highlight where the issues are).

Here's the changes related to redefinitions I made in order to be able 
to mostly compile Guile 3.0.9 with GCC 4.0.1 on PowerPC Mac OS X 10.4. I 
say mostly as I'm not sure if there are further redefinition issues 
since I'm currently stuck with issues related to the supplied 
32-bit-big-endian image and regenerating it.

The MAX macro in socket.h conflicts with the MAX macro in the system 
header files.

diff -ur /tmp/guile-3.0.9/libguile/dynstack.h ./libguile/dynstack.h
--- /tmp/guile-3.0.9/libguile/dynstack.h	2018-09-22 21:51:40.000000000 +0100
+++ ./libguile/dynstack.h	2023-07-26 16:47:37.000000000 +0100
@@ -28,7 +28,7 @@
 #include "libguile/scm.h"



-
+#undef scm_t_dynstack;
 typedef struct scm_dynstack
 {
   scm_t_bits *base;
diff -ur /tmp/guile-3.0.9/libguile/foreign.h ./libguile/foreign.h
--- /tmp/guile-3.0.9/libguile/foreign.h	2022-01-10 16:58:37.000000000 +0000
+++ ./libguile/foreign.h	2023-07-26 17:33:42.000000000 +0100
@@ -22,6 +22,7 @@

 #include "libguile/gc.h"
 #include "libguile/snarf.h"
+#include "libguile/print.h"

 /* A "foreign pointer" is a wrapped C pointer.  It is represented by a
    cell whose second word is a pointer.  The first word has the
diff -ur /tmp/guile-3.0.9/libguile/pairs.h ./libguile/pairs.h
--- /tmp/guile-3.0.9/libguile/pairs.h	2018-09-22 21:51:40.000000000 +0100
+++ ./libguile/pairs.h	2023-07-26 17:30:00.000000000 +0100
@@ -200,6 +200,7 @@
 #endif

 #ifdef BUILDING_LIBGUILE
+/*
 #ifndef HAVE_GC_IS_HEAP_PTR
 static int
 GC_is_heap_ptr (void *ptr)
@@ -207,6 +208,7 @@
   return GC_base (ptr) != NULL;
 }
 #endif
+*/

 static inline int
 scm_is_mutable_pair (SCM x)
diff -ur /tmp/guile-3.0.9/libguile/programs.h ./libguile/programs.h
--- /tmp/guile-3.0.9/libguile/programs.h	2018-09-22 21:51:40.000000000 +0100
+++ ./libguile/programs.h	2023-07-26 17:32:06.000000000 +0100
@@ -21,6 +21,7 @@
 #define _SCM_PROGRAMS_H_

 #include <libguile/gc.h>
+#include <libguile/print.h>

 /*
  * Programs
diff -ur /tmp/guile-3.0.9/libguile/scm.h ./libguile/scm.h
--- /tmp/guile-3.0.9/libguile/scm.h	2020-05-27 21:48:00.000000000 +0100
+++ ./libguile/scm.h	2023-07-26 16:48:30.000000000 +0100
@@ -821,8 +821,8 @@
 #endif

 typedef struct scm_dynamic_state scm_t_dynamic_state;
-typedef struct scm_print_state scm_print_state;
-typedef struct scm_dynstack scm_t_dynstack;
+/* typedef struct scm_print_state scm_print_state;
+typedef struct scm_dynstack scm_t_dynstack; */
 typedef int32_t scm_t_wchar;
 struct scm_frame;
 struct scm_vm;
diff -ur /tmp/guile-3.0.9/libguile/socket.c ./libguile/socket.c
--- /tmp/guile-3.0.9/libguile/socket.c	2022-10-21 16:39:38.000000000 +0100
+++ ./libguile/socket.c	2023-07-26 17:14:20.000000000 +0100
@@ -774,7 +774,7 @@
    proc is the name of the original procedure.
    size returns the size of the structure allocated.  */

-#define MAX(A, B) ((A) >= (B) ? (A) : (B))
+#define AMAX(A, B) ((A) >= (B) ? (A) : (B))

 static struct sockaddr *
 scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg,
@@ -864,7 +864,7 @@
 	   connect/bind etc., to fail.  sun_path is always the last
 	   member of the structure.  */
 	addr_size = sizeof (struct sockaddr_un)
-	  + MAX (0, c_address_size + 1 - (sizeof soka->sun_path));
+	  + AMAX (0, c_address_size + 1 - (sizeof soka->sun_path));
 	soka = (struct sockaddr_un *) scm_malloc (addr_size);
 	memset (soka, 0, addr_size);
 	soka->sun_family = AF_UNIX;
diff -ur /tmp/guile-3.0.9/libguile/strings.h ./libguile/strings.h
--- /tmp/guile-3.0.9/libguile/strings.h	2022-02-04 10:15:39.000000000 +0000
+++ ./libguile/strings.h	2023-07-26 17:43:11.000000000 +0100
@@ -26,6 +26,7 @@
 #include <libguile/error.h>
 #include "libguile/inline.h"
 #include <libguile/snarf.h>
+#include <libguile/print.h>




diff -ur /tmp/guile-3.0.9/libguile/threads.h ./libguile/threads.h
--- /tmp/guile-3.0.9/libguile/threads.h	2020-02-08 14:11:34.000000000 +0000
+++ ./libguile/threads.h	2023-07-26 16:41:30.000000000 +0100
@@ -28,6 +28,7 @@
 #include "libguile/iselect.h"
 #include "libguile/smob.h"
 #include "libguile/vm.h"
+#include "libguile/scm.h"

 #if SCM_USE_PTHREAD_THREADS
 #include "libguile/pthread-threads.h"
diff -ur /tmp/guile-3.0.9/libguile/vm.h ./libguile/vm.h
--- /tmp/guile-3.0.9/libguile/vm.h	2019-12-14 17:28:57.000000000 +0000
+++ ./libguile/vm.h	2023-07-26 17:36:53.000000000 +0100
@@ -24,6 +24,7 @@

 #include <libguile/gc.h>
 #include <libguile/programs.h>
+#include <libguile/dynstack.h>

 #define SCM_VM_REGULAR_ENGINE 0
 #define SCM_VM_DEBUG_ENGINE 1
diff -ur /tmp/guile-3.0.9/libguile/weak-set.c ./libguile/weak-set.c
--- /tmp/guile-3.0.9/libguile/weak-set.c	2020-03-27 11:33:32.000000000 +0000
+++ ./libguile/weak-set.c	2023-07-26 17:46:25.000000000 +0100
@@ -165,6 +165,7 @@
     return size - origin + k;
 }

+/*
 #ifndef HAVE_GC_MOVE_DISAPPEARING_LINK
 static void
 GC_move_disappearing_link (void **from, void **to)
@@ -173,6 +174,7 @@
   SCM_I_REGISTER_DISAPPEARING_LINK (to, *to);
 }
 #endif
+*/

 static void
 move_weak_entry (scm_t_weak_entry *from, scm_t_weak_entry *to)





Information forwarded to bug-guile <at> gnu.org:
bug#41467; Package guile. (Tue, 01 Aug 2023 11:23:02 GMT) Full text and rfc822 format available.

Message #14 received at 41467 <at> debbugs.gnu.org (full text, mbox):

From: Sevan Janiyan <venture37 <at> geeklan.co.uk>
To: 41467 <at> debbugs.gnu.org
Subject: Re: Compiling extensions using Guile 3.0.2 headers doesn't work with
 clang without -std=c11
Date: Tue, 1 Aug 2023 12:22:25 +0100
On 01/08/2023 12:11, Sevan Janiyan wrote:
> The MAX macro in socket.h conflicts with the MAX macro in the system 
> header files.

Forgot to mention, the header inclusions in the diff are because 
scm_t_dynstack & scm_t_dynstack typedefs were commented out of 
libguile/scm.h (resolving the redefinition).


Sevan




This bug report was last modified 1 year and 317 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.