Commit acb86aa0 authored by Diederik van Arkel's avatar Diederik van Arkel
Browse files

code gen support for generate via assembly;

add stack size settings for MachO executable
parent eec4a939
...@@ -368,25 +368,26 @@ where ...@@ -368,25 +368,26 @@ where
/* Generates code for the given file: /* Generates code for the given file:
*/ */
SwitchDebugMachO tp symbolic_machO normal :== case toString tp of
// "PowerPC_MachO" -> symbolic_machO
_ -> normal
CodeGen :: !String !(WindowFun *(PSt .l)) !CodeGenerateAsmOrCode !Pathname !Bool !CodeGenOptions !ApplicationOptions !Pathname !*(PSt .l) CodeGen :: !String !(WindowFun *(PSt .l)) !CodeGenerateAsmOrCode !Pathname !Bool !CodeGenOptions !ApplicationOptions !Pathname !*(PSt .l)
-> (!*(PSt .l), !Pathname, !Bool) -> (!*(PSt .l), !Pathname, !Bool)
CodeGen cgen` wf genAsmOrCode path timeprofile cgo=:{tp} ao startupdir ps CodeGen cgen` wf genAsmOrCode path timeprofile cgo=:{tp} ao startupdir ps
// # (cgen_ok,cgen) = mangleGenerator cgen` startupdir # genAsmOrCode` = SwitchDebugMachO tp AsmGeneration genAsmOrCode
# (cgen_ok,cgen,name,signature) = mangleGenerator cgen` startupdir # (cgen_ok,cgen,name,signature) = mangleGenerator cgen` startupdir
| not cgen_ok | not cgen_ok
# ps = wf [cgen] ps # ps = wf [cgen] ps
= (ps, "", False) = (ps, "", False)
// # (objpath,ps) = accFiles (MakeObjSystemPathname tp path) ps
# objpath = MakeObjSystemPathname tp path # objpath = MakeObjSystemPathname tp path
path_without_suffix = RemoveSuffix path path_without_suffix = RemoveSuffix path
command = cgen /*"cg"*/ +++ MakeCodeGenOptionsString genAsmOrCode /*False*/timeprofile cgo command = cgen +++ MakeCodeGenOptionsString genAsmOrCode` timeprofile cgo
+++ " " +++ (quoted_string path_without_suffix) +++ " " +++ (quoted_string path_without_suffix)
+++ " > out \xb3 errors" +++ " > out \xb3 errors"
errorsfilename = startupdir +++ toString dirseparator +++ "errors" errorsfilename = startupdir +++ toString dirseparator +++ "errors"
// # signature = CleanCompilerSignature // XOXOXOX
// # name = CleanCompilerName // XOXOXOX
# (error_code,error_n,output_string) # (error_code,error_n,output_string)
= send_command_to_clean_compiler_cg signature name command Wait = send_command_to_clean_compiler_cg signature name command Wait
| error_code <> 0 | error_code <> 0
...@@ -410,7 +411,23 @@ CodeGen cgen` wf genAsmOrCode path timeprofile cgo=:{tp} ao startupdir ps ...@@ -410,7 +411,23 @@ CodeGen cgen` wf genAsmOrCode path timeprofile cgo=:{tp} ao startupdir ps
, False , False
) )
= (ps,objpath,error_n==0) = SwitchDebugMachO tp
(case genAsmOrCode of
AsmGeneration -> (ps,objpath,True)
_
# assembly_file_name = to_unix_path (RemoveSuffix objpath+++".a");
# object_file_name = to_unix_path objpath;
# (r1,r2) = send_command_to_application False "EXEC"
( "/usr/bin/as '"
+++ assembly_file_name
+++ "' -o '"
+++ object_file_name
+++ "'"
+++ " -g" // for symbolic debugging info...
)
-> (ps,objpath,r1==r1)
)
(ps,objpath,True)
StartCodeGenerator :: !String !(WindowFun *(PSt .l)) !CodeGenerateAsmOrCode !Pathname !Int !Bool !CodeGenOptions !ApplicationOptions !Pathname !*(PSt .l) StartCodeGenerator :: !String !(WindowFun *(PSt .l)) !CodeGenerateAsmOrCode !Pathname !Int !Bool !CodeGenOptions !ApplicationOptions !Pathname !*(PSt .l)
-> (!Bool,!Pathname,!*(PSt .l)) -> (!Bool,!Pathname,!*(PSt .l))
...@@ -516,6 +533,8 @@ Link linker` winfun path ...@@ -516,6 +533,8 @@ Link linker` winfun path
+++ " -o '" +++ " -o '"
+++ to_unix_path path +++ to_unix_path path
+++ "'" +++ "'"
// +++ " -g" // for debugging syms
+++ if (ss > standard_mosx_stack) (" -stack-size " +++ stack_size) ""
); );
| r1==r1 | r1==r1
...@@ -532,6 +551,40 @@ Link linker` winfun path ...@@ -532,6 +551,40 @@ Link linker` winfun path
| errlines<>0 | errlines<>0
= (winfun errtext ps,link_ok) = (winfun errtext ps,link_ok)
= (ps,link_ok) = (ps,link_ok)
where
stack_size = hex_int (roundup_to_multiple ss 4096)
standard_mosx_stack = 0x080000 // 512K
// from ExtInt module in pc linker
roundup_to_multiple s m :== (s + (dec m)) bitand (~m);
hexdigit :: !Int -> Char;
hexdigit i
| i<10
= toChar (toInt '0'+i);
= toChar (toInt 'A'+i-10);
hex :: !Int -> String;
hex i
#! i1
=(i bitand 0xf0) >> 4;
#! i2
=i bitand 0xf;
= toString (hexdigit i1)+++toString (hexdigit i2);
hex_int :: !Int -> String;
hex_int i
#! b0
= hex (i bitand 0x000000ff);
#! b1
= hex ((i bitand 0x0000ff00) >> 8);
#! b2
= hex ((i bitand 0x00ff0000) >> 16);
#! b3
= hex ((i bitand 0xff000000) >> 24);
= /*"0x" +++ */ b3 +++ b2 +++ b1 +++ b0;
//
isMachOObject object = equal_suffix ".o" object isMachOObject object = equal_suffix ".o" object
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment