2
0
Эх сурвалжийг харах

+ declare the three magic global variables (__tls_size, __tls_align, __tls_base), created by the linker, when WebAssembly multithreading is enabled

Nikolay Nikolov 3 жил өмнө
parent
commit
7475d22154

+ 11 - 0
compiler/wasm32/cpubase.pas

@@ -350,6 +350,17 @@ uses
       STACK_POINTER_SYM = '__stack_pointer';
       { The exception tag symbol, used for FPC exceptions }
       FPC_EXCEPTION_TAG_SYM = '__FPC_exception';
+      { Immutable global variable, created by the linker, when multithreading
+        support is enabled. Contains the total size (plus padding) of all the
+        threadvars, used by the program. }
+      TLS_SIZE_SYM = '__tls_size';
+      { Immutable global variable, created by the linker, when multithreading
+        support is enabled. Contains the alignment requirement for the thread
+        local block. }
+      TLS_ALIGN_SYM = '__tls_align';
+      { Mutable global variable, created by the linker, when multithreading
+        support is enabled. }
+      TLS_BASE_SYM = '__tls_base';
 
 {*****************************************************************************
                                   Helpers

+ 7 - 0
compiler/wasm32/nwasmutil.pas

@@ -98,6 +98,13 @@ implementation
 
       list.Concat(tai_globaltype.create(STACK_POINTER_SYM,wbt_i32,false));
 
+      if ts_wasm_threads in current_settings.targetswitches then
+        begin
+          list.Concat(tai_globaltype.create(TLS_SIZE_SYM,wbt_i32,true));
+          list.Concat(tai_globaltype.create(TLS_ALIGN_SYM,wbt_i32,true));
+          list.Concat(tai_globaltype.create(TLS_BASE_SYM,wbt_i32,false));
+        end;
+
       if ts_wasm_native_exceptions in current_settings.targetswitches then
         begin
           list.Concat(tai_tagtype.create(FPC_EXCEPTION_TAG_SYM, []));