work around constant folding bug 61144 in gcc 4.9.0 and 4.9.1
previously we detected this bug in configure and issued advice for a workaround, but this turned out not to work. since then gcc 4.9.0 has appeared in several distributions, and now 4.9.1 has been released without a fix despite this being a wrong code generation bug which is supposed to be a release-blocker, per gcc policy. since the scope of the bug seems to affect only data objects (rather than functions) whose definitions are overridable, and there are only a very small number of these in musl, I am just changing them from const to volatile for the time being. simply removing the const would be sufficient to make gcc 4.9.1 work (the non-const case was inadvertently fixed as part of another change in gcc), and this would also be sufficient with 4.9.0 if we forced -O0 on the affected files or on the whole build. however it's cleaner to just remove all the broken compiler detection and use volatile, which will ensure that they are never constant-folded. the quality of a non-broken compiler's output should not be affected except for the fact that these objects are no longer const and thus possibly add a few bytes to data/bss. this change can be reconsidered and possibly reverted at some point in the future when the broken gcc versions are no longer relevant.
This commit is contained in:
parent
c463e11eda
commit
a6adb2bcd8
8 changed files with 9 additions and 30 deletions
|
|
@ -116,12 +116,12 @@ static int start(void *p)
|
|||
#define ROUND(x) (((x)+PAGE_SIZE-1)&-PAGE_SIZE)
|
||||
|
||||
/* pthread_key_create.c overrides this */
|
||||
static const size_t dummy = 0;
|
||||
static volatile size_t dummy = 0;
|
||||
weak_alias(dummy, __pthread_tsd_size);
|
||||
static void *const dummy_tsd[1] = { 0 };
|
||||
static void *dummy_tsd[1] = { 0 };
|
||||
weak_alias(dummy_tsd, __pthread_tsd_main);
|
||||
|
||||
static FILE *const dummy_file = 0;
|
||||
static FILE *volatile dummy_file = 0;
|
||||
weak_alias(dummy_file, __stdin_used);
|
||||
weak_alias(dummy_file, __stdout_used);
|
||||
weak_alias(dummy_file, __stderr_used);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "pthread_impl.h"
|
||||
|
||||
const size_t __pthread_tsd_size = sizeof(void *) * PTHREAD_KEYS_MAX;
|
||||
volatile size_t __pthread_tsd_size = sizeof(void *) * PTHREAD_KEYS_MAX;
|
||||
void *__pthread_tsd_main[PTHREAD_KEYS_MAX] = { 0 };
|
||||
|
||||
static void (*keys[PTHREAD_KEYS_MAX])(void *);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue