unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#41467: Compiling extensions using Guile 3.0.2 headers doesn't work with clang without -std=c11
@ 2020-05-22 20:42 Vadim Zeitlin
  2023-08-01  1:38 ` Sevan Janiyan
  0 siblings, 1 reply; 4+ messages in thread
From: Vadim Zeitlin @ 2020-05-22 20:42 UTC (permalink / raw)
  To: 41467

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2145 bytes --]

 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

[-- Attachment #2: Type: APPLICATION/PGP-SIGNATURE, Size: 196 bytes --]

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

* bug#41467: Compiling extensions using Guile 3.0.2 headers doesn't work with clang without -std=c11
  2020-05-22 20:42 bug#41467: Compiling extensions using Guile 3.0.2 headers doesn't work with clang without -std=c11 Vadim Zeitlin
@ 2023-08-01  1:38 ` Sevan Janiyan
  2023-08-01 11:11   ` Sevan Janiyan
  0 siblings, 1 reply; 4+ messages in thread
From: Sevan Janiyan @ 2023-08-01  1:38 UTC (permalink / raw)
  To: 41467

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





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

* bug#41467: Compiling extensions using Guile 3.0.2 headers doesn't work with clang without -std=c11
  2023-08-01  1:38 ` Sevan Janiyan
@ 2023-08-01 11:11   ` Sevan Janiyan
  2023-08-01 11:22     ` Sevan Janiyan
  0 siblings, 1 reply; 4+ messages in thread
From: Sevan Janiyan @ 2023-08-01 11:11 UTC (permalink / raw)
  To: 41467

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)






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

* bug#41467: Compiling extensions using Guile 3.0.2 headers doesn't work with clang without -std=c11
  2023-08-01 11:11   ` Sevan Janiyan
@ 2023-08-01 11:22     ` Sevan Janiyan
  0 siblings, 0 replies; 4+ messages in thread
From: Sevan Janiyan @ 2023-08-01 11:22 UTC (permalink / raw)
  To: 41467

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





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

end of thread, other threads:[~2023-08-01 11:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-22 20:42 bug#41467: Compiling extensions using Guile 3.0.2 headers doesn't work with clang without -std=c11 Vadim Zeitlin
2023-08-01  1:38 ` Sevan Janiyan
2023-08-01 11:11   ` Sevan Janiyan
2023-08-01 11:22     ` Sevan Janiyan

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