Browse Source

From 2c98a1c1a51ca092da696e731feddacd3dd87406 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Tue, 26 Nov 2019 09:20:25 -0500
Subject: [PATCH 80/83] weaking a common global variable for a unit

git-svn-id: branches/wasm@45957 -

nickysn 5 years ago
parent
commit
7e421eed3c
1 changed files with 7 additions and 2 deletions
  1. 7 2
      compiler/wasm/agwat.pas

+ 7 - 2
compiler/wasm/agwat.pas

@@ -682,8 +682,13 @@ implementation
         // the tool updates the symbol flags, so the linker
         // the tool updates the symbol flags, so the linker
         // is capable of producing an executable
         // is capable of producing an executable
         if Result then
         if Result then
-          if FindExe('wasmtool',true,t) then 
-            RequotedExecuteProcess(t,' --symbolauto '+ObjFileName)
+          if FindExe('wasmtool',true,t) then begin
+            if current_module.is_unit then
+              // making "common" global variables a week reference
+              RequotedExecuteProcess(t,' --weak "$__stack_top" --symbolauto '+ObjFileName)
+            else
+              RequotedExecuteProcess(t,' --symbolauto '+ObjFileName)
+          end
           else
           else
             Message1(exec_e_util_not_found,'wasmtool');
             Message1(exec_e_util_not_found,'wasmtool');
       end;
       end;