summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Leroy <xavierleroy@users.noreply.github.com>2018-05-16 16:46:55 +0200
committerDavid Allsopp <david.allsopp@metastack.com>2022-12-12 10:19:09 +0000
commitead74c13d7c3698f966cd6f40331a91b844d2074 (patch)
treef8f3f5010522582f92ffd47e70ef83c5d31e132c
parent5facd7513877dd884aa4036233a633550a48a1a9 (diff)
downloadocaml-ead74c13d7c3698f966cd6f40331a91b844d2074.tar.gz
Declare variables 'extern' in <caml/major_gc.h> and <caml/intext.h>
GPR #1770. * In <caml/major_gc.h> declare some variables 'extern' The variables in question are caml_major_ring, caml_major_ring_index, and caml_major_work_credit. It is correct C code to declare those variables in the .h without a storage class, in which case they are treated as "common" variables by the linker. However, this causes problems with Clang's address sanitizer: it increases the size of the common variable when it is used, but leaves it unchanged when it is not. As a consequence, the linker sees several occurrences of a "common" variable with different sizes. The linker does the right thing and takes the "max" of the sizes, but not without printing an annoying warning, which is then reported as suspicious behavior by ocamltest. This commit puts "extern" storage class on the incriminated variables in <caml/major_gc.h>, consistently with the other GC variables. * In <caml/intext.h> declare `caml_code_fragments_table` as extern And add proper declaration in byterun/fix_code.c and asmrun/startup.c (the places where this table is initialized). Same reasons as above. (cherry picked from commit 1161b772c14063565c12f0f979db84a9fc57dd58)
-rw-r--r--asmrun/startup.c1
-rw-r--r--byterun/caml/intext.h2
-rw-r--r--byterun/caml/major_gc.h6
-rw-r--r--byterun/fix_code.c1
4 files changed, 6 insertions, 4 deletions
diff --git a/asmrun/startup.c b/asmrun/startup.c
index b9467036e5..27a3d1b28c 100644
--- a/asmrun/startup.c
+++ b/asmrun/startup.c
@@ -45,6 +45,7 @@
extern int caml_parser_trace;
char * caml_code_area_start, * caml_code_area_end;
+struct ext_table caml_code_fragments_table;
/* Initialize the atom table and the static data and code area limits. */
diff --git a/byterun/caml/intext.h b/byterun/caml/intext.h
index 673c6fc0a1..f67c98b5bd 100644
--- a/byterun/caml/intext.h
+++ b/byterun/caml/intext.h
@@ -196,7 +196,7 @@ struct code_fragment {
CAMLextern struct code_fragment * caml_extern_find_code(char *addr);
-struct ext_table caml_code_fragments_table;
+extern struct ext_table caml_code_fragments_table;
#endif /* CAML_INTERNALS */
diff --git a/byterun/caml/major_gc.h b/byterun/caml/major_gc.h
index 98909c0ac8..deb3353c75 100644
--- a/byterun/caml/major_gc.h
+++ b/byterun/caml/major_gc.h
@@ -64,9 +64,9 @@ extern uintnat total_heap_size;
extern char *caml_gc_sweep_hp;
extern int caml_major_window;
-double caml_major_ring[Max_major_window];
-int caml_major_ring_index;
-double caml_major_work_credit;
+extern double caml_major_ring[Max_major_window];
+extern int caml_major_ring_index;
+extern double caml_major_work_credit;
extern double caml_gc_clock;
/* [caml_major_gc_hook] is called just between the end of the mark
diff --git a/byterun/fix_code.c b/byterun/fix_code.c
index 09581cfae8..4bc53572cc 100644
--- a/byterun/fix_code.c
+++ b/byterun/fix_code.c
@@ -38,6 +38,7 @@
code_t caml_start_code;
asize_t caml_code_size;
unsigned char * caml_saved_code;
+struct ext_table caml_code_fragments_table;
/* Read the main bytecode block from a file */