bug#60234: Build failure on mac os 12.6 / gcc 12.2

2023-01-20 Thread Ludovic Courtès
Hi Daniel,

lloda  skribis:

> .../libguile/threads.h:194:43: error: 'scm_i_current_thread' is defined with 
> tls model global-dynamic
>   194 | SCM_INTERNAL SCM_THREAD_LOCAL scm_thread *scm_i_current_thread;
>   |   ^
> .../libguile/threads.c:357:30: note: previously defined here as local-dynamic
>   357 | SCM_THREAD_LOCAL scm_thread *scm_i_current_thread = NULL;
>
> Simply repeating SCM_INTERNAL in the .c fixes it...

The problem is that ‘SCM_INTERNAL’ is synonymous with ‘extern’, which
makes no sense for a definition (threads.c:357), so rightfully GCC
GNU/Linux rightfully complains:

--8<---cut here---start->8---
  CC   libguile_3.0_la-threads.lo
threads.c:358:43: warning: 'scm_i_current_thread' initialized and declared 
'extern'
  358 | SCM_INTERNAL SCM_THREAD_LOCAL scm_thread *scm_i_current_thread = NULL;
  |   ^~~~
--8<---cut here---end--->8---

It’s just a warning, but still not looking good.

Is there something else at play, such as a ‘-ftls-model’ flag being
passed to GCC somehow (info “(gcc) Code Gen Options")?

If not, should we have:

  #define SCM_THREAD_LOCAL \
__thread __attribute__ ((__tls_model__ ("global-dynamic")))

instead (info "(gcc) Common Variable Attributes")?

Would that work with Clang?

Ludo’.





bug#60234: Build failure on mac os 12.6 / gcc 12.2

2023-01-20 Thread lloda


> On 18 Jan 2023, at 23:16, Ludovic Courtès  > wrote:
> 
> Hi Daniel,
> 
> lloda mailto:ll...@sarc.name>> skribis:
> 
>> .../libguile/threads.h:194:43: error: 'scm_i_current_thread' is defined with 
>> tls model global-dynamic
>> 194 | SCM_INTERNAL SCM_THREAD_LOCAL scm_thread *scm_i_current_thread;
>> |   ^
>> .../libguile/threads.c:357:30: note: previously defined here as local-dynamic
>> 357 | SCM_THREAD_LOCAL scm_thread *scm_i_current_thread = NULL;
>> 
>> Simply repeating SCM_INTERNAL in the .c fixes it...
> 
> The problem is that ‘SCM_INTERNAL’ is synonymous with ‘extern’, which
> makes no sense for a definition (threads.c:357), so rightfully GCC
> GNU/Linux rightfully complains:
> 
> --8<---cut here---start->8---
> CC   libguile_3.0_la-threads.lo
> threads.c:358:43: warning: 'scm_i_current_thread' initialized and declared 
> 'extern'
> 358 | SCM_INTERNAL SCM_THREAD_LOCAL scm_thread *scm_i_current_thread = NULL;
> |   ^~~~
> --8<---cut here---end--->8---
> 
> It’s just a warning, but still not looking good.

Hi,

Agreed, I had the same warning on mac os. Looked like the least bad choice...

> Is there something else at play, such as a ‘-ftls-model’ flag being
> passed to GCC somehow (info “(gcc) Code Gen Options")?
> 
> If not, should we have:
> 
> #define SCM_THREAD_LOCAL \
>   __thread __attribute__ ((__tls_model__ ("global-dynamic")))
> 
> instead (info "(gcc) Common Variable Attributes")?
> 
> Would that work with Clang?
> 
> Ludo’.

I don't seem to have any such flags.

The attribute does fix the issue on mac os with gcc 12.

I hadn't tried clang before, but I did now, and clang 14 works fine with or 
without the attribute. So the fix would only be for gcc.

Thanks

 Daniel

bug#60971: build failure of v3.0.9rc1 on mac os 12.6

2023-01-20 Thread lloda



Hello,

v3.0.9rc1 fails on mac os 12.6.2 & gcc 12.2 or clang 14, same error in either 
case. gcc's error is:


CC   libguile_3.0_la-posix.lo
In file included from ../../../src/guile4/libguile/posix.c:82:
../../../src/guile4/libguile/posix.c:109:9: error: lvalue required as unary '&' 
operand
  109 | verify (WEXITSTATUS (W_EXITCODE (127, 0)) == 127);
  | ^~~
../../../src/guile4/lib/verify.h:213:57: note: in definition of macro 
'_GL_VERIFY'
  213 | # define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC)
  | ^
../../../src/guile4/libguile/posix.c:109:1: note: in expansion of macro 'verify'
  109 | verify (WEXITSTATUS (W_EXITCODE (127, 0)) == 127);
  | ^~
../../../src/guile4/libguile/posix.c:109:9: error: expression in static 
assertion is not an integer
  109 | verify (WEXITSTATUS (W_EXITCODE (127, 0)) == 127);
  | ^~~
../../../src/guile4/lib/verify.h:213:57: note: in definition of macro 
'_GL_VERIFY'
  213 | # define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC)
  | ^
../../../src/guile4/libguile/posix.c:109:1: note: in expansion of macro 'verify'
  109 | verify (WEXITSTATUS (W_EXITCODE (127, 0)) == 127);
  | ^~


The problematic section in libguile/posix.c

...

#if HAVE_SYS_WAIT_H
# include 
#endif
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif

#ifndef W_EXITCODE
/* Macro for constructing a status value.  Found in glibc.  */
# ifdef _WIN32/* see Gnulib's posix-w32.h */
#  define W_EXITCODE(ret, sig)   (ret)
# else
#  define W_EXITCODE(ret, sig)   ((ret) << 8 | (sig))
# endif
#endif
verify (WEXITSTATUS (W_EXITCODE (127, 0)) == 127);
...

adding -o .libs/libguile_3.0_la-posix.i -E to the build line shows line 109 as

_Static_assert ( (((*(int *)&((( 127 ) << 8 | ( 0  >> 8) & 0x00ff) == 
127, "verify (" "WEXITSTATUS (W_EXITCODE (127, 0)) == 127" ")");
^

forcing redefinition of WEXITSTATUS shows the previous definition at 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/wait.h

...

#if defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE)
#define _W_INT(i)   (i)
#else
#define _W_INT(w)   (*(int *)&(w))  /* convert union wait to int */   
<- problem
#define WCOREFLAG   0200
#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */

/* These macros are permited, as they are in the implementation namespace */
#define _WSTATUS(x) (_W_INT(x) & 0177)
#define _WSTOPPED   0177/* _WSTATUS if process is stopped */

/*
 * [XSI] The  header shall define the following macros for
 * analysis of process status values
 */
#if __DARWIN_UNIX03
#define WEXITSTATUS(x)  ((_W_INT(x) >> 8) & 0x00ff)
#else /* !__DARWIN_UNIX03 */
#define WEXITSTATUS(x)  (_W_INT(x) >> 8)
#endif /* !__DARWIN_UNIX03 */
/* 0x13 == SIGCONT */
#define WSTOPSIG(x) (_W_INT(x) >> 8)
#define WIFCONTINUED(x) (_WSTATUS(x) == _WSTOPPED && WSTOPSIG(x) == 0x13)
#define WIFSTOPPED(x)   (_WSTATUS(x) == _WSTOPPED && WSTOPSIG(x) != 0x13)
#define WIFEXITED(x)(_WSTATUS(x) == 0)
#define WIFSIGNALED(x)  (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
#define WTERMSIG(x) (_WSTATUS(x))
#if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
#define WCOREDUMP(x)(_W_INT(x) & WCOREFLAG)

#define W_EXITCODE(ret, sig)((ret) << 8 | (sig))
#define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED)
#endif /* (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */

...

so that's the problem, but I'm not sure what the solution is. The way it's
written, W_EXITCODE() is always going to give up a number...

Thanks

  Daniel