-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"error: initializer element is not constant" when trying make julia #57440
Comments
It looks like we still document gcc >= 7.1, but since we don't test for that, it looks like that version didn't correctly handle this constexpr (AFAIK, they are considered an implementation-defined behavior, since C still has not yet standardized whether constants are allowed to be used, so it is not yet possible to define what it means to write standards-compliant code if it uses any constants). PRs welcome to alter that code to some form that will be accepted by GCC 7.5.0 though |
I'm not a C person, but there seem to be three ways around this: Make the variables non-static and localdiff --git a/src/gc-stock.c b/src/gc-stock.c
index 3d3bc9f485..3885e335c1 100644
--- a/src/gc-stock.c
+++ b/src/gc-stock.c
@@ -141,8 +141,6 @@
static uint64_t old_pause_time = 1e7; // 10 ms
static uint64_t old_mut_time = 1e9; // 1 second
static uint64_t old_heap_size = 0;
-static uint64_t old_alloc_diff = default_collect_interval;
-static uint64_t old_freed_diff = default_collect_interval;
static uint64_t gc_end_time = 0;
static int thrash_counter = 0;
static int thrashing = 0;
@@ -3028,6 +3026,8 @@
jl_gc_markqueue_t *mq = &ptls->gc_tls.mark_queue;
+ uint64_t old_alloc_diff = default_collect_interval;
+ uint64_t old_freed_diff = default_collect_interval;
uint64_t gc_start_time = jl_hrtime();
uint64_t mutator_time = gc_end_time == 0 ? old_mut_time : gc_start_time - gc_end_time;
uint64_t before_free_heap_size = jl_atomic_load_relaxed(&gc_heap_stats.heap_size);
`#define` the constantdiff --git a/src/gc-stock.c b/src/gc-stock.c
index 3d3bc9f485..425ae1ec86 100644
--- a/src/gc-stock.c
+++ b/src/gc-stock.c
@@ -123,13 +123,13 @@
// under this limit, but we will go above it rather than halting.
#ifdef _P64
typedef uint64_t memsize_t;
-static const size_t default_collect_interval = 5600 * 1024 * sizeof(void*);
+#define DEFAULT_COLLECT_INTERVAL (5600 * 1024 * sizeof(void*))
static size_t total_mem;
// We expose this to the user/ci as jl_gc_set_max_memory
static memsize_t max_total_memory = (memsize_t) 2 * 1024 * 1024 * 1024 * 1024 * 1024;
#else
typedef uint32_t memsize_t;
-static const size_t default_collect_interval = 3200 * 1024 * sizeof(void*);
+#define DEFAULT_COLLECT_INTERVAL (3200 * 1024 * sizeof(void*))
// Work really hard to stay within 2GB
// Alternative is to risk running out of address space
// on 32 bit architectures.
@@ -141,8 +141,8 @@
static uint64_t old_pause_time = 1e7; // 10 ms
static uint64_t old_mut_time = 1e9; // 1 second
static uint64_t old_heap_size = 0;
-static uint64_t old_alloc_diff = default_collect_interval;
-static uint64_t old_freed_diff = default_collect_interval;
+static uint64_t old_alloc_diff = DEFAULT_COLLECT_INTERVAL;
+static uint64_t old_freed_diff = DEFAULT_COLLECT_INTERVAL;
static uint64_t gc_end_time = 0;
static int thrash_counter = 0;
static int thrashing = 0;
@@ -1312,7 +1312,7 @@
}
n_pages_seen++;
// keep the last few pages around for a while
- if (n_pages_seen * GC_PAGE_SZ <= default_collect_interval) {
+ if (n_pages_seen * GC_PAGE_SZ <= DEFAULT_COLLECT_INTERVAL) {
push_lf_back(&tmp, pg);
continue;
}
@@ -3251,8 +3251,8 @@
// compute some guardrails values
uint64_t min_target_allocs = heap_size / 20; // minimum 5% of current heap
- if (min_target_allocs < default_collect_interval / 8) // unless the heap is small
- min_target_allocs = default_collect_interval / 8;
+ if (min_target_allocs < DEFAULT_COLLECT_INTERVAL / 8) // unless the heap is small
+ min_target_allocs = DEFAULT_COLLECT_INTERVAL / 8;
uint64_t max_target_allocs = overallocation(before_free_heap_size, heap_size, user_max);
if (max_target_allocs < min_target_allocs)
max_target_allocs = min_target_allocs;
@@ -3280,8 +3280,8 @@
}
// and set the heap detection threshold
target_heap = target_allocs + heap_size;
- if (target_heap < default_collect_interval) {
- target_heap = default_collect_interval;
+ if (target_heap < DEFAULT_COLLECT_INTERVAL) {
+ target_heap = DEFAULT_COLLECT_INTERVAL;
reason = " min heap";
}
jl_atomic_store_relaxed(&gc_heap_stats.heap_target, target_heap);
@@ -3686,8 +3686,8 @@
arraylist_new(&finalizer_list_marked, 0);
arraylist_new(&to_finalize, 0);
- jl_atomic_store_relaxed(&gc_heap_stats.heap_target, default_collect_interval);
- gc_num.interval = default_collect_interval;
+ jl_atomic_store_relaxed(&gc_heap_stats.heap_target, DEFAULT_COLLECT_INTERVAL);
+ gc_num.interval = DEFAULT_COLLECT_INTERVAL;
gc_num.allocd = 0;
gc_num.max_pause = 0;
gc_num.max_memory = 0;
anonymous enum hackdiff --git a/src/gc-stock.c b/src/gc-stock.c
index 3d3bc9f485..aec502e7d2 100644
--- a/src/gc-stock.c
+++ b/src/gc-stock.c
@@ -123,13 +123,13 @@
// under this limit, but we will go above it rather than halting.
#ifdef _P64
typedef uint64_t memsize_t;
-static const size_t default_collect_interval = 5600 * 1024 * sizeof(void*);
+enum { default_collect_interval = 5600 * 1024 * sizeof(void*) };
static size_t total_mem;
// We expose this to the user/ci as jl_gc_set_max_memory
static memsize_t max_total_memory = (memsize_t) 2 * 1024 * 1024 * 1024 * 1024 * 1024;
#else
typedef uint32_t memsize_t;
-static const size_t default_collect_interval = 3200 * 1024 * sizeof(void*);
+enum { default_collect_interval = 3200 * 1024 * sizeof(void*) };
// Work really hard to stay within 2GB
// Alternative is to risk running out of address space
// on 32 bit architectures. This keeps the variables scopes as they are, but maybe a bit too clever, and changes All three of these lead to a successful compilation of gc-stock.o, but I can't test them beyond that - because, after some linking, I run into (I believe unrelated) Segmentation fault errors and so don't end up with a successful julia build to test. Segmentation fault in expression starting at boot.jl:283
I can open a separate issue for this segfault if needed, and I can turn any of the diffs above into a PR if it seems like a usable solution. |
The |
After cloning in the latest
master
on my WSL OpenSUSE Tumbleweed, runningmake
results in:I have gcc and g++ both version 7.5.0, along with the other tools mentioned here.
The only other issues with this error that I can find are this (which I don't understand tbh), and this (which is about Clang pretending to be gcc, doesn't seem relevant here). Seeing as this doesn't seem a commonly reported error, what element of my setup is the likely reason for this, and how can I fix it?
The text was updated successfully, but these errors were encountered: