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

From: Ludovic Courtès <[email-masked]>
Date: Wed, 18 Jan 2023 23:16:41 +0100

Hi Daniel,

lloda <[email-masked]> 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’.