Commit d8847ef9 authored by John van Groningen's avatar John van Groningen
Browse files

use optimising linker

parent 1679d19a
......@@ -12,7 +12,7 @@ from EdFileMenu import Quit;
from EdFileMenu import OpenFile;
from EdProjectMenu import OpenFileOrProjectFile;
import pointer;
import elf_linker,pointer;
/* Macros used to select platform specific code.
Make sure only one of these macros is True.
......@@ -382,6 +382,11 @@ MakeCodeGenOptionsString genAsmOrCode {ci,cs,tp} t
= t;
};
accFiles3 f io0
:== let {
((r1,r2,r3),io2) = accFiles (\ io0 -> let { (r1,r2,r3,io1) = f io0 } in ((r1,r2,r3),io1) ) io0;
} in (r1,r2,r3,io2);
Link :: !WindowFun !Pathname !Pathname !(List Pathname) !(List Pathname) !ApplicationOptions !Processor !LinkOptions !(List Pathname) !(List Pathname) !ProgState !IO -> (!ProgIO,!Bool);
Link winfun path u_system_file_name paths defs
applicationOptions=:{ss,fs,fn,hs,em,heap_size_multiple,initial_heap_size,profiling,profiling601,memoryProfilingMinimumHeapSize}
......@@ -389,38 +394,56 @@ Link winfun path u_system_file_name paths defs
/* RWS FIXME: use abc... options */
abcLinkObjFilePaths abcLinkLibraryPaths
prog=:{editor={startupinfo={startupdir,linker_file_name,linker_begin_object_files,linker_libraries,linker_end_object_files},project}} io
| std_error_not_empty
= (winfun std_error_text prog io5,link_ok);
| std_out_not_empty
= (winfun std_out_text prog io5,link_ok);
= ((prog,io5),link_ok);
{}{
(u_startup_file_name,io1) = accFiles (MakeObjSystemPathname CurrentProcessor (MakeFullPathname system_directory_name startupModuleName)) io;
(u_reals_file_name,io2) =
# (u_startup_file_name,io1) = accFiles (MakeObjSystemPathname CurrentProcessor (MakeFullPathname system_directory_name startupModuleName)) io;
# (u_reals_file_name,io2) =
IF_SOLARIS
(accFiles (MakeObjSystemPathname CurrentProcessor (MakeFullPathname system_directory_name "_reals")) io1)
("", io1);
libCleanxv_a_path = MakeFullPathname system_directory_name "libCleanxv.a";
(link_ok,io3) = accFiles link io2;
((std_error_not_empty,std_error_text),io4) = accFiles (ReadFileAsText errors_file_name) io3;
((std_out_not_empty, std_out_text),io5) = accFiles (ReadFileAsText out_file_name) io4;
# defaultObjects
= if linkOptions.useDefaultSystemObjects
(IF_SOLARIS
[u_startup_file_name, u_reals_file_name, u_system_file_name]
[u_startup_file_name, u_system_file_name]
)
[];
# (linker_ok,ld_ok,linker_errors,io3) = accFiles3 (link defaultObjects) io2;
| not linker_ok
# linker_error_list = list_to_List linker_errors;
with {
list_to_List [] = Nil;
list_to_List [s:l] = s+++"\n" :! list_to_List l;
}
= (winfun (Text_StringsToText linker_error_list) prog io3,ld_ok);
# ((std_error_not_empty,std_error_text),io4) = accFiles (ReadFileAsText errors_file_name) io3;
# ((std_out_not_empty, std_out_text),io5) = accFiles (ReadFileAsText out_file_name) io4;
| std_error_not_empty
= (winfun std_error_text prog io5,ld_ok);
| std_out_not_empty
= (winfun std_out_text prog io5,ld_ok);
= ((prog,io5),ld_ok);
{}{
out_file_name = startupdir +++ "/out";
errors_file_name = startupdir +++ "/errors";
link files
link :: [String] *Files -> (!Bool,!Bool,![String],!*Files);
link defaultObjects files
# options_file_name = startupdir +++ "/_options.o";
# flags = ApplicationOptionsToFlags applicationOptions;
# option_file_contents = options_object_file_code flags hs ss heap_size_multiple initial_heap_size;
# (ok,files) = write_array_to_file option_file_contents options_file_name files;
| ok
# objectFileNames = defaultObjects ++ [options_file_name : StrictListToList paths ++ (StrictListToList linkOptions.extraObjectModules)];
# linker_tmp_object_file_name = startupdir +++ "/linker_tmp.o";
# (ok,linker_errors,files) = link_elf_files objectFileNames linker_tmp_object_file_name files;
| not ok
= (False,False,linker_errors,files);
# (error_code,error_n) = exec_with_redirect linker_file_name ["-s","-o",MakeExecPathname path :
linker_begin_object_files++objectFileNames++libraryFileNames++linker_end_object_files] out_file_name errors_file_name;
linker_begin_object_files++[linker_tmp_object_file_name]++libraryFileNames++linker_end_object_files] out_file_name errors_file_name;
// linker_begin_object_files++objectFileNames++libraryFileNames++linker_end_object_files] out_file_name errors_file_name;
| error_code==0 && error_n==0
= (True,files);
= (False,files);
= (False,files);
= (True,True,[],files);
= (True,False,[],files);
= (True,False,[],files);
startupModuleName
| not profiling
......@@ -428,21 +451,17 @@ Link winfun path u_system_file_name paths defs
| profiling601
= "_startupProfile601";
= "_startupProfile";
system_directory_name = RemoveFilename u_system_file_name;
defaultObjects
| linkOptions.useDefaultSystemObjects
= IF_SOLARIS
[u_startup_file_name, u_reals_file_name, u_system_file_name]
[u_startup_file_name, u_system_file_name];
= [];
// libCleanxv_a_path = MakeFullPathname system_directory_name "libCleanxv.a";
libraryFileNames
= defaultLibraries ++ (StrictListToList linkOptions.libraries);
defaultLibraries
| linkOptions.useDefaultLibraries
= [libCleanxv_a_path : linker_libraries]
// = [libCleanxv_a_path : linker_libraries]
= linker_libraries;
= [];
};
......
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