+2811
-53
lines changed Original file line number Diff line number Diff line change
@@ -2394,6 +2394,7 @@ asmcomp/asmlibrarian.cmx : \
2394
2394
asmcomp/asmlibrarian.cmi
2395
2395
asmcomp/asmlibrarian.cmi :
2396
2396
asmcomp/asmlink.cmo : \
2397
+
asmcomp/thread_sanitizer.cmi \
2397
2398
lambda/runtimedef.cmi \
2398
2399
utils/profile.cmi \
2399
2400
utils/misc.cmi \
@@ -2412,6 +2413,7 @@ asmcomp/asmlink.cmo : \
2412
2413
asmcomp/asmgen.cmi \
2413
2414
asmcomp/asmlink.cmi
2414
2415
asmcomp/asmlink.cmx : \
2416
+
asmcomp/thread_sanitizer.cmx \
2415
2417
lambda/runtimedef.cmx \
2416
2418
utils/profile.cmx \
2417
2419
utils/misc.cmx \
@@ -2596,6 +2598,7 @@ asmcomp/cmm_invariants.cmi : \
2596
2598
asmcomp/cmm.cmi
2597
2599
asmcomp/cmmgen.cmo : \
2598
2600
typing/types.cmi \
2601
+
asmcomp/thread_sanitizer.cmi \
2599
2602
middle_end/printclambda_primitives.cmi \
2600
2603
typing/primitive.cmi \
2601
2604
utils/misc.cmi \
@@ -2615,6 +2618,7 @@ asmcomp/cmmgen.cmo : \
2615
2618
asmcomp/cmmgen.cmi
2616
2619
asmcomp/cmmgen.cmx : \
2617
2620
typing/types.cmx \
2621
+
asmcomp/thread_sanitizer.cmx \
2618
2622
middle_end/printclambda_primitives.cmx \
2619
2623
typing/primitive.cmx \
2620
2624
utils/misc.cmx \
@@ -3185,6 +3189,22 @@ asmcomp/strmatch.cmx : \
3185
3189
asmcomp/strmatch.cmi : \
3186
3190
lambda/debuginfo.cmi \
3187
3191
asmcomp/cmm.cmi
3192
+
asmcomp/thread_sanitizer.cmo : \
3193
+
lambda/debuginfo.cmi \
3194
+
asmcomp/cmm_helpers.cmi \
3195
+
asmcomp/cmm.cmi \
3196
+
middle_end/backend_var.cmi \
3197
+
parsing/asttypes.cmi \
3198
+
asmcomp/thread_sanitizer.cmi
3199
+
asmcomp/thread_sanitizer.cmx : \
3200
+
lambda/debuginfo.cmx \
3201
+
asmcomp/cmm_helpers.cmx \
3202
+
asmcomp/cmm.cmx \
3203
+
middle_end/backend_var.cmx \
3204
+
parsing/asttypes.cmi \
3205
+
asmcomp/thread_sanitizer.cmi
3206
+
asmcomp/thread_sanitizer.cmi : \
3207
+
asmcomp/cmm.cmi
3188
3208
asmcomp/x86_ast.cmi :
3189
3209
asmcomp/x86_dsl.cmo : \
3190
3210
asmcomp/x86_proc.cmi \
Original file line number Diff line number Diff line change
@@ -366,6 +366,11 @@ Some of those changes will benefit all OCaml packages.
366
366
`ocamlmklib.opt` are no longer installed to `$BINDIR`.
367
367
(Xavier Leroy, review by Gabriel Scherer)
368
368
369
+
- #12114: Add ThreadSanitizer support
370
+
(Fabrice Buoro and Olivier Nicole, based on an initial work by Anmol Sahoo,
371
+
review by Damien Doligez, Sebastien Hinderer, Jacques-Henri Jourdan, Luc
372
+
Maranget, Guillaume Munch-Maccagnoni, Gabriel Scherer)
373
+
369
374
### Runtime system:
370
375
371
376
- #11589, #11903: Modify the GC pacing code to make sure the GC keeps
Original file line number Diff line number Diff line change
@@ -670,6 +670,7 @@ runtime_COMMON_C_SOURCES = \
670
670
str \
671
671
sync \
672
672
sys \
673
+
$(TSAN_NATIVE_RUNTIME_C_SOURCES) \
673
674
$(UNIX_OR_WIN32) \
674
675
weak
675
676
Original file line number Diff line number Diff line change
@@ -152,3 +152,9 @@ runtime_ASM_OBJECTS = $(addprefix runtime/,@runtime_asm_objects@)
152
152
153
153
# Platform-dependent module for ocamlyacc
154
154
ocamlyacc_WSTR_MODULE = @ocamlyacc_wstr_module@
155
+
156
+
# ThreadSanitizer support enabled
157
+
TSAN=@tsan@
158
+
# Contains TSan-specific runtime files, or nothing if TSan support is
159
+
# disabled
160
+
TSAN_NATIVE_RUNTIME_C_SOURCES = @tsan_native_runtime_c_sources@
Original file line number Diff line number Diff line change
@@ -210,9 +210,6 @@ WITH_OCAMLTEST=@ocamltest@
210
210
ASM_CFI_SUPPORTED=@asm_cfi_supported@
211
211
WITH_FRAME_POINTERS=@frame_pointers@
212
212
HEADER_RESERVED_BITS=@reserved_header_bits@
213
-
LIBUNWIND_AVAILABLE=@libunwind_available@
214
-
LIBUNWIND_INCLUDE_FLAGS=@libunwind_include_flags@
215
-
LIBUNWIND_LINK_FLAGS=@libunwind_link_flags@
216
213
WITH_FPIC=@fpic@
217
214
TARGET=@target@
218
215
HOST=@host@
Original file line number Diff line number Diff line change
@@ -322,16 +322,16 @@ int main (int argc, char *argv[]){
322
322
])
323
323
324
324
AC_DEFUN([OCAML_CHECK_LIBUNWIND], [
325
-
SAVED_CFLAGS="$CFLAGS"
325
+
SAVED_CPPFLAGS="$CPPFLAGS"
326
326
SAVED_LDFLAGS="$LDFLAGS"
327
-
CFLAGS="$CFLAGS $libunwind_include_flags"
328
-
LDFLAGS="$LDFLAGS $libunwind_link_flags"
327
+
CPPFLAGS="$CPPFLAGS $libunwind_cppflags"
328
+
LDFLAGS="$LDFLAGS $libunwind_ldflags"
329
329
AC_CHECK_HEADER([libunwind.h],
330
330
[AC_DEFINE([HAS_LIBUNWIND])
331
331
libunwind_available=true],
332
332
[libunwind_available=false])
333
333
LDFLAGS="$SAVED_LDFLAGS"
334
-
CFLAGS="$SAVED_CFLAGS"
334
+
CPPFLAGS="$SAVED_CPPFLAGS"
335
335
])
336
336
337
337
AC_DEFUN([OCAML_TEST_FLEXLINK], [
Original file line number Diff line number Diff line change
@@ -237,6 +237,7 @@ method class_of_operation op =
237
237
| Ifloatofint | Iintoffloat -> Op_pure
238
238
| Ispecific _ -> Op_other
239
239
| Idls_get -> Op_load Mutable
240
+
| Ireturn_addr -> Op_load Immutable
240
241
241
242
(* Operations that are so cheap that it isn't worth factoring them. *)
242
243
method is_cheap_operation op =
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ and instrument = function
97
97
98
98
(* these are base cases and have no logging *)
99
99
| Cconst_int _ | Cconst_natint _ | Cconst_float _
100
-
| Cconst_symbol _
100
+
| Cconst_symbol _ | Creturn_addr
101
101
| Cvar _ as c -> c
102
102
103
103
let instrument_function c dbg =
Original file line number Diff line number Diff line change
@@ -740,6 +740,9 @@ let emit_instr env fallthrough i =
740
740
I.mov (arg32 i 0) (res32 i 0)
741
741
| Lop (Idls_get) ->
742
742
I.mov (domain_field Domainstate.Domain_dls_root) (res i 0)
743
+
| Lop (Ireturn_addr) ->
744
+
let offset = frame_size env - 8 in
745
+
I.mov (mem64 QWORD offset RSP) (res i 0)
743
746
| Lreloadretaddr ->
744
747
()
745
748
| Lreturn ->
@@ -862,10 +865,17 @@ let emit_instr env fallthrough i =
862
865
emit_call "caml_reraise_exn";
863
866
record_frame env Reg.Set.empty (Dbg_raise i.dbg)
864
867
| Lambda.Raise_notrace ->
865
-
I.mov (domain_field Domainstate.Domain_exn_handler) rsp;
866
-
I.pop (domain_field Domainstate.Domain_exn_handler);
867
-
I.pop r11;
868
-
I.jmp r11
868
+
if Config.tsan then begin
869
+
(* TSan requires to signal function exits upon exceptions,
870
+
even with [Raise_notrace] *)
871
+
emit_call "caml_tsan_raise_notrace_exn";
872
+
record_frame env Reg.Set.empty (Dbg_raise i.dbg)
873
+
end else begin
874
+
I.mov (domain_field Domainstate.Domain_exn_handler) rsp;
875
+
I.pop (domain_field Domainstate.Domain_exn_handler);
876
+
I.pop r11;
877
+
I.jmp r11
878
+
end
869
879
end
870
880
871
881
let rec emit_all env fallthrough i =
Original file line number Diff line number Diff line change
@@ -513,6 +513,10 @@ module BR = Branch_relaxation.Make (struct
513
513
| Lop (Ispecific Imove32) -> 1
514
514
| Lop (Ispecific (Isignext _)) -> 1
515
515
| Lop (Idls_get) -> 1
516
+
| Lop (Ireturn_addr) ->
517
+
invalid_arg (
518
+
"Support for Ireturn_addr is not implemented on architecture "
519
+
^ Config.architecture)
516
520
| Lreloadretaddr -> 0
517
521
| Lreturn -> epilogue_size f
518
522
| Llabel _ -> 0
@@ -958,6 +962,10 @@ let emit_instr env i =
958
962
| Lop(Idls_get) ->
959
963
let offset = Domainstate.(idx_of_field Domain_dls_root) * 8 in
960
964
` ldr {emit_reg i.res.(0)}, [{emit_reg reg_domain_state_ptr}, {emit_int offset}]\n`
965
+
| Lop(Ireturn_addr) ->
966
+
invalid_arg (
967
+
"Support for Ireturn_addr is not implemented on architecture "
968
+
^ Config.architecture)
961
969
| Lreloadretaddr ->
962
970
()
963
971
| Lreturn ->
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4