Просмотр исходного кода

* static/shared linking updates

peter 27 лет назад
Родитель
Сommit
cc64a929aa
8 измененных файлов с 254 добавлено и 174 удалено
  1. 34 46
      compiler/assemble.pas
  2. 33 18
      compiler/files.pas
  3. 49 28
      compiler/link.pas
  4. 12 35
      compiler/parser.pas
  5. 73 27
      compiler/pmodules.pas
  6. 14 9
      compiler/ppu.pas
  7. 25 9
      compiler/symppu.inc
  8. 14 2
      compiler/systems.pas

+ 34 - 46
compiler/assemble.pas

@@ -31,25 +31,24 @@ const
 {$ifdef tp}
   AsmOutSize=1024;
 {$else}
-  AsmOutSize=10000;
+  AsmOutSize=32768;
 {$endif}
 
 type
   PAsmList=^TAsmList;
   TAsmList=object
   {filenames}
-    path     : dirstr;
+    path     : pathstr;
     name     : namestr;
-    asmfile,
+    asmfile,             { current .s and .o file }
     objfile,
-    srcfile,
     as_bin   : string;
   {outfile}
     AsmSize,
     outcnt   : longint;
     outbuf   : array[0..AsmOutSize-1] of char;
     outfile  : file;
-    Constructor Init(const fn:string);
+    Constructor Init;
     Destructor Done;
     Function  FindAssembler:string;
     Function  CallAssembler(const command,para:string):Boolean;
@@ -67,12 +66,11 @@ type
     procedure WriteAsmList;virtual;
   end;
 
-Procedure GenerateAsm(const fn:string);
-Procedure OnlyAsm(const fn:string);
+Procedure GenerateAsm;
+Procedure OnlyAsm;
 
 var
   SmartLinkFilesCnt : longint;
-Function SmartLinkPath(const s:string):string;
 
 Implementation
 
@@ -107,20 +105,6 @@ uses
   ;
 
 
-{*****************************************************************************
-                               SmartLink Helpers
-*****************************************************************************}
-
-Function SmartLinkPath(const s:string):string;
-var
-    p : dirstr;
-    n : namestr;
-    e : extstr;
-begin
-  FSplit(s,p,n,e);
-  SmartLinkPath:=FixFileName(n+target_info.smartext);
-end;
-
 {*****************************************************************************
                                   TAsmList
 *****************************************************************************}
@@ -191,10 +175,10 @@ begin
   if cs_asm_leave in aktglobalswitches then
    exit;
   if cs_asm_extern in aktglobalswitches then
-   AsmRes.AddDeleteCommand(asmfile)
+   AsmRes.AddDeleteCommand(AsmFile)
   else
    begin
-     assign(g,asmfile);
+     assign(g,AsmFile);
      {$I-}
       erase(g);
      {$I+}
@@ -364,28 +348,29 @@ begin
 end;
 
 
-Constructor TAsmList.Init(const fn:string);
+Constructor TAsmList.Init;
 var
-  ext : extstr;
-  i   : word;
+  i : word;
 begin
-{Create filenames for easier access}
-  fsplit(fn,path,name,ext);
-  srcfile:=fn;
-  asmfile:=path+name+target_info.asmext;
-  objfile:=path+name+target_info.objext;
+{ load start values }
+
+  asmfile:=current_module^.asmfilename^;
+  objfile:=current_module^.objfilename^;
+  name:=FixFileName(current_module^.modulename^);
   OutCnt:=0;
-{Smartlinking}
   SmartLinkFilesCnt:=0;
+{ Which path will be used ? }
   if (cs_smartlink in aktmoduleswitches) then
    begin
-     path:=SmartLinkPath(name);
+     path:=current_module^.path^+FixFileName(current_module^.modulename^)+target_info.smartext;
      {$I-}
       mkdir(path);
      {$I+}
      i:=ioresult;
-   end;
-  path:=FixPath(path);
+     path:=FixPath(path);
+   end
+  else
+   path:=current_module^.path^;
 end;
 
 
@@ -398,34 +383,34 @@ end;
                      Generate Assembler Files Main Procedure
 *****************************************************************************}
 
-Procedure GenerateAsm(const fn:string);
+Procedure GenerateAsm;
 var
   a : PAsmList;
 begin
   case aktoutputformat of
 {$ifdef i386}
   {$ifndef NoAg386Att}
-        as_o : a:=new(pi386attasmlist,Init(fn));
+        as_o : a:=new(pi386attasmlist,Init);
   {$endif NoAg386Att}
   {$ifndef NoAg386Nsm}
  as_nasmcoff,
   as_nasmelf,
-  as_nasmobj : a:=new(pi386nasmasmlist,Init(fn));
+  as_nasmobj : a:=new(pi386nasmasmlist,Init);
   {$endif NoAg386Nsm}
   {$ifndef NoAg386Int}
-     as_tasm : a:=new(pi386intasmlist,Init(fn));
+     as_tasm : a:=new(pi386intasmlist,Init);
   {$endif NoAg386Int}
 {$endif}
 {$ifdef m68k}
   {$ifndef NoAg68kGas}
      as_o,
-   as_gas : a:=new(pm68kgasasmlist,Init(fn));
+   as_gas : a:=new(pm68kgasasmlist,Init);
   {$endif NoAg86KGas}
   {$ifndef NoAg68kMot}
-   as_mot : a:=new(pm68kmotasmlist,Init(fn));
+   as_mot : a:=new(pm68kmotasmlist,Init);
   {$endif NoAg86kMot}
   {$ifndef NoAg68kMit}
-   as_mit : a:=new(pm68kmitasmlist,Init(fn));
+   as_mit : a:=new(pm68kmitasmlist,Init);
   {$endif NoAg86KMot}
 {$endif}
   else
@@ -439,11 +424,11 @@ begin
 end;
 
 
-Procedure OnlyAsm(const fn:string);
+Procedure OnlyAsm;
 var
   a : PAsmList;
 begin
-  a:=new(pasmlist,Init(fn));
+  a:=new(pasmlist,Init);
   a^.DoAssemble;
   dispose(a,Done);
 end;
@@ -452,7 +437,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.16  1998-08-14 21:56:30  peter
+  Revision 1.17  1998-08-17 09:17:43  peter
+    * static/shared linking updates
+
+  Revision 1.16  1998/08/14 21:56:30  peter
     * setting the outputfile using -o works now to create static libs
 
   Revision 1.15  1998/08/14 18:16:09  peter

+ 33 - 18
compiler/files.pas

@@ -126,7 +126,8 @@ unit files;
           objfilename,              { fullname of the objectfile }
           asmfilename,              { fullname of the assemblerfile }
           ppufilename,              { fullname of the ppufile }
-          libfilename,              { fullname of the libraryfile/exefile }
+          staticlibfilename,        { fullname of the static libraryfile }
+          sharedlibfilename,        { fullname of the shared libraryfile }
           exefilename,              { fullname of the exefile }
           asmprefix,                { prefix for the smartlink asmfiles }
           mainsource    : pstring;  { name of the main sourcefile }
@@ -229,13 +230,13 @@ unit files;
 
        { unit flags }
        uf_init           = $1;
-       uf_has_dbx        = $2;
-       uf_has_browser    = $4;
-       uf_in_library     = $8;
-       uf_shared_library = $10;
-       uf_big_endian     = $20;
-       uf_smartlink      = $40;
-       uf_finalize       = $80;
+       uf_finalize       = $2;
+       uf_big_endian     = $4;
+       uf_has_dbx        = $8;
+       uf_has_browser    = $10;
+       uf_in_library     = $20;
+       uf_static_library = $40;
+       uf_shared_library = $80;
 {$endif}
 
     var
@@ -410,7 +411,8 @@ unit files;
          stringdispose(objfilename);
          stringdispose(asmfilename);
          stringdispose(ppufilename);
-         stringdispose(libfilename);
+         stringdispose(staticlibfilename);
+         stringdispose(sharedlibfilename);
          stringdispose(exefilename);
          stringdispose(path);
          fsplit(fn,p,n,e);
@@ -422,7 +424,8 @@ unit files;
          { lib and exe could be loaded with a file specified with -o }
          if OutputFile<>'' then
           s:=OutputFile;
-         libfilename:=stringdup(s+target_os.staticlibext);
+         staticlibfilename:=stringdup(target_os.libprefix+s+target_os.staticlibext);
+         sharedlibfilename:=stringdup(target_os.libprefix+s+target_os.sharedlibext);
          exefilename:=stringdup(s+target_os.exeext);
       end;
 
@@ -489,12 +492,19 @@ unit files;
         do_compile:=false;
         if (flags and uf_in_library)=0 then
          begin
-           if (flags and uf_smartlink)<>0 then
+           if (flags and uf_static_linked)<>0 then
             begin
-              objfiletime:=getnamedfiletime(libfilename^);
+              objfiletime:=getnamedfiletime(staticlibfilename^);
               if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then
                 do_compile:=true;
             end
+           else
+            if (flags and uf_shared_linked)<>0 then
+             begin
+               objfiletime:=getnamedfiletime(sharedlibfilename^);
+               if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then
+                do_compile:=true;
+             end
            else
             begin
             { the objectfile should be newer than the ppu file }
@@ -548,7 +558,7 @@ unit files;
            singlepathstring:=FixPath(copy(unitpath,start,i-start));
            delete(unitpath,start,i-start+1);
          { Check for PPL file }
-           if not (cs_link_static in aktglobalswitches) then
+           if not Found then
             begin
               Found:=UnitExists(target_info.unitlibext);
               if Found then
@@ -558,7 +568,7 @@ unit files;
                End;
              end;
          { Check for PPU file }
-           if not (cs_link_dynamic in aktglobalswitches) and not Found then
+           if not Found then
             begin
               Found:=UnitExists(target_info.unitext);
               if Found then
@@ -869,14 +879,15 @@ unit files;
          ppufilename:=nil;
          objfilename:=nil;
          asmfilename:=nil;
-         libfilename:=nil;
+         staticlibfilename:=nil;
+         sharedlibfilename:=nil;
          exefilename:=nil;
          { go32v2 has the famous 8.3 limit ;) }
 {$ifdef go32v2}
          asmprefix:=stringdup('as');
 {$else}
          asmprefix:=stringdup(Lower(n));
-{$endif}        
+{$endif}
 
          path:=nil;
          setfilename(p+n);
@@ -933,7 +944,8 @@ unit files;
         stringdispose(objfilename);
         stringdispose(asmfilename);
         stringdispose(ppufilename);
-        stringdispose(libfilename);
+        stringdispose(staticlibfilename);
+        stringdispose(sharedlibfilename);
         stringdispose(exefilename);
         stringdispose(path);
         stringdispose(modulename);
@@ -1024,7 +1036,10 @@ unit files;
 end.
 {
   $Log$
-  Revision 1.34  1998-08-14 21:56:31  peter
+  Revision 1.35  1998-08-17 09:17:44  peter
+    * static/shared linking updates
+
+  Revision 1.34  1998/08/14 21:56:31  peter
     * setting the outputfile using -o works now to create static libs
 
   Revision 1.33  1998/08/11 14:09:08  peter

+ 49 - 28
compiler/link.pas

@@ -46,12 +46,12 @@ Type
        function  FindLibraryFile(s:string;const ext:string) : string;
        Procedure AddObject(const S : String);
        Procedure AddStaticLibrary(const S : String);
-       Procedure AddSharedLibrary(const S : String);
+       Procedure AddSharedLibrary(S : String);
        Function  FindLinker:String;      { Find linker, sets Name }
        Function  DoExec(const command,para:string;info,useshell:boolean):boolean;
        Function  WriteResponseFile:Boolean;
        Function  MakeExecutable:boolean;
-       Procedure MakeStaticLibrary(const path:string;filescnt:longint);
+       Procedure MakeStaticLibrary(filescnt:longint);
        Procedure MakeSharedLibrary;
      end;
      PLinker=^TLinker;
@@ -191,8 +191,17 @@ begin
 end;
 
 
-Procedure TLinker.AddSharedLibrary(const S:String);
+Procedure TLinker.AddSharedLibrary(S:String);
 begin
+{ remove prefix 'lib' }
+  if Copy(s,1,length(target_os.libprefix))=target_os.libprefix then
+   Delete(s,1,length(target_os.libprefix));
+{ remove extension if any }
+
+  if Copy(s,length(s)-length(target_os.sharedlibext)+1,length(target_os.sharedlibext))=target_os.sharedlibext then
+   Delete(s,length(s)-length(target_os.sharedlibext)+1,length(target_os.sharedlibext)+1);
+{ ready to be inserted }
+
   SharedLibFiles.Insert (S);
 end;
 
@@ -232,7 +241,7 @@ begin
   if cs_link_extern in aktglobalswitches then
    begin
      if info then
-      AsmRes.AddLinkCommand(Command,Para,current_module^.libfilename^)
+      AsmRes.AddLinkCommand(Command,Para,current_module^.exefilename^)
      else
       AsmRes.AddLinkCommand(Command,Para,'');
    end;
@@ -291,7 +300,7 @@ begin
 { Fix command line options }
   If not SharedLibFiles.Empty then
    LinkOptions:='-dynamic-linker='+DynamicLinker+' '+LinkOptions;
-  if Strip then
+  if Strip and not(cs_debuginfo in aktmoduleswitches) then
    LinkOptions:=LinkOptions+target_link.stripopt;
 
 { Open linkresponse and write header }
@@ -376,9 +385,7 @@ function TLinker.MakeExecutable:boolean;
 var
   bindbin    : string[80];
   bindfound  : boolean;
-  i          : longint;
   s          : string;
-  dummy      : file;
   success    : boolean;
 begin
 {$ifdef linux}
@@ -419,26 +426,27 @@ begin
    end;
 {Remove ReponseFile}
   if (success) and not(cs_link_extern in aktglobalswitches) then
-   begin
-     assign(dummy,LinkResName);
-     {$I-}
-      erase(dummy);
-     {$I+}
-     i:=ioresult;
-   end;
+   RemoveFile(LinkResName);
   MakeExecutable:=success;   { otherwise a recursive call to link method }
 end;
 
 
-Procedure TLinker.MakeStaticLibrary(const path:string;filescnt:longint);
+Procedure TLinker.MakeStaticLibrary(filescnt:longint);
+{
+  FilesCnt holds the amount of .o files created, if filescnt=0 then
+  no smartlinking is used
+}
 var
+  smartpath,
   s,
   arbin   : string;
   arfound : boolean;
   cnt     : longint;
   i       : word;
-  f       : file;
 begin
+  smartpath:=current_module^.path^+FixPath(FixFileName(current_module^.modulename^)+target_info.smartext);
+{ find ar binary }
+
   arbin:=FindExe(target_ar.arbin,arfound);
   if (not arfound) and not(cs_link_extern in aktglobalswitches) then
    begin
@@ -446,38 +454,51 @@ begin
      aktglobalswitches:=aktglobalswitches+[cs_link_extern];
    end;
   s:=target_ar.arcmd;
-  Replace(s,'$LIB',current_module^.libfilename^);
-  Replace(s,'$FILES',FixPath(path)+current_module^.asmprefix^+'*'+target_info.objext);
+  Replace(s,'$LIB',current_module^.staticlibfilename^);
+  if filescnt=0 then
+   Replace(s,'$FILES',current_module^.objfilename^)
+  else
+
+   Replace(s,'$FILES',smartpath+current_module^.asmprefix^+'*'+target_info.objext);
   DoExec(arbin,s,false,true);
 { Clean up }
   if not(cs_asm_leave in aktglobalswitches) and not(cs_link_extern in aktglobalswitches) then
    begin
-     for cnt:=1to filescnt do
+     if filescnt=0 then
+      RemoveFile(current_module^.objfilename^)
+     else
       begin
-        assign(f,FixPath(path)+current_module^.asmprefix^+tostr(cnt)+target_info.objext);
+
+        for cnt:=1 to filescnt do
+         RemoveFile(smartpath+current_module^.asmprefix^+tostr(cnt)+target_info.objext);
         {$I-}
-         erase(f);
+         rmdir(smartpath);
         {$I+}
         i:=ioresult;
-      end;
-     {$I-}
-      rmdir(path);
-     {$I+}
-     i:=ioresult;
+      end;      
    end;
 end;
 
 
 Procedure TLinker.MakeSharedLibrary;
+var
+  s : string;
 begin
-  DoExec(FindLinker,' -shared -o '+current_module^.libfilename^+' link.res',false,false);
+  s:=' -shared -o $LIB $FILES';
+  Replace(s,'$LIB',current_module^.sharedlibfilename^);
+  Replace(s,'$FILES',current_module^.objfilename^);
+  if DoExec(FindLinker,s,false,false) then
+   RemoveFile(current_module^.objfilename^);
 end;
 
 
 end.
 {
   $Log$
-  Revision 1.18  1998-08-14 21:56:34  peter
+  Revision 1.19  1998-08-17 09:17:47  peter
+    * static/shared linking updates
+
+  Revision 1.18  1998/08/14 21:56:34  peter
     * setting the outputfile using -o works now to create static libs
 
   Revision 1.17  1998/08/14 18:16:08  peter

+ 12 - 35
compiler/parser.pas

@@ -132,9 +132,7 @@ unit parser;
          oldaktoutputformat : tasm;
          oldaktoptprocessor : tprocessors;
          oldaktasmmode      : tasmmode;
-
-      label
-         done;
+        
 
       begin
          inc(compile_level);
@@ -252,45 +250,21 @@ unit parser;
          { reset lexical level }
          lexlevel:=0;
 
-         { parse source }
+         { If the compile level > 1 we get a nice "unit expected" error
+           message if we are trying to use a program as unit.}
          if (token=_UNIT) or (compile_level>1) then
            begin
              current_module^.is_unit:=true;
-           { If the compile level > 1 we get a nice "unit expected" error
-             message if we are trying to use a program as unit.}
              proc_unit;
-             if current_module^.compiled then
-               goto done;
            end
          else
-           begin
-             proc_program(token=_LIBRARY);
-           end;
+           proc_program(token=_LIBRARY);
+        
 
-         if status.errorcount=0 then
-           begin
-             GenerateAsm(filename);
-
-             if (cs_smartlink in aktmoduleswitches) then
-               Linker.MakeStaticLibrary(SmartLinkPath(FileName),SmartLinkFilesCnt);
-
-           { add the files for the linker from current_module, this must be
-             after the makestaticlibrary, because it will add the library
-             name (PFV) }
-             Linker.AddModuleFiles(current_module);
-
-           { Check linking  => we are at first level in compile }
-             if (compile_level=1) then
-              begin
-                if (cs_link_deffile in aktglobalswitches) then
-                 deffile.writefile;
-                if (not current_module^.is_unit) then
-                 Linker.MakeExecutable;
-              end;
-           end
-         else
+         if status.errorcount>0 then
            Message1(unit_f_errors_in_unit,tostr(status.errorcount));
-done:
+        
+
          { clear memory }
 {$ifdef Splitheap}
          if testsplit then
@@ -398,7 +372,10 @@ done:
 end.
 {
   $Log$
-  Revision 1.36  1998-08-14 21:56:36  peter
+  Revision 1.37  1998-08-17 09:17:49  peter
+    * static/shared linking updates
+
+  Revision 1.36  1998/08/14 21:56:36  peter
     * setting the outputfile using -o works now to create static libs
 
   Revision 1.35  1998/08/12 19:22:09  peter

+ 73 - 27
compiler/pmodules.pas

@@ -38,7 +38,7 @@ unit pmodules;
     uses
        cobjects,verbose,comphook,systems,globals,
        symtable,aasm,hcodegen,
-       link,assemble,import
+       link,assemble,import,gendef
 {$ifndef OLDPPU}
        ,ppu
 {$endif OLDPPU}
@@ -50,17 +50,38 @@ unit pmodules;
 {$endif}
        ,scanner,pbase,psystem,pdecl,psub,parser;
 
+    procedure create_objectfile;
+      begin
+        { create the .s file and assemble it }
+        GenerateAsm;
+
+        { When creating a library call the linker. And insert the output
+          of the linker files }
+        if (cs_create_staticlib in aktmoduleswitches) then
+         Linker.MakeStaticLibrary(SmartLinkFilesCnt)
+        else
+         if (cs_create_sharedlib in aktmoduleswitches) then
+          Linker.MakeSharedLibrary;
+        { add the files for the linker from current_module }
+        Linker.AddModuleFiles(current_module);
+      end;
 
-    procedure setlinkerfile;
+
+    procedure insertobjectfile;
+    { Insert the used object file for this unit in the used list for this unit }
       begin
-      { Add Object File }
-        if (cs_smartlink in aktmoduleswitches) then
-          current_module^.linkstaticlibs.insert(current_module^.libfilename^)
+        if (cs_create_staticlib in aktmoduleswitches) then
+         current_module^.linkstaticlibs.insert(current_module^.staticlibfilename^)
+        else
+         if (cs_create_sharedlib in aktmoduleswitches) then
+          current_module^.linksharedlibs.insert(current_module^.sharedlibfilename^)
         else
           current_module^.linkofiles.insert(current_module^.objfilename^);
       end;
 
 
+
+
     procedure insertsegment;
 
         procedure fixseg(p:paasmoutput;sec:tsection);
@@ -89,6 +110,7 @@ unit pmodules;
         fixseg(consts,sec_data);
       end;
 
+
     procedure insertheap;
       begin
          if (cs_smartlink in aktmoduleswitches) then
@@ -265,7 +287,7 @@ unit pmodules;
            begin
            { only reassemble ? }
              if (current_module^.do_assemble) then
-              OnlyAsm(current_module^.asmfilename^);
+              OnlyAsm;
            { add the files for the linker }
              Linker.AddModuleFiles(current_module);
            end;
@@ -814,16 +836,7 @@ unit pmodules;
 
          { a unit compiled at command line must be inside the loaded_unit list }
          if (compile_level=1) then
-           begin
-              loaded_units.insert(current_module);
-              if cs_createlib in initmoduleswitches then
-                begin
-                current_module^.flags:=current_module^.flags or uf_in_library;
-                if cs_shared_lib in initmoduleswitches then
-                  current_module^.flags:=current_module^.flags or uf_shared_library;
-                end;
-           end;
-
+           loaded_units.insert(current_module);
 
          { insert qualifier for the system unit (allows system.writeln) }
          if not(cs_compilesystem in aktmoduleswitches) then
@@ -971,9 +984,6 @@ unit pmodules;
 {$endif dummy}
          consume(POINT);
 
-         { add files which need to be linked }
-         setlinkerfile;
-
          { size of the static data }
          datasize:=symtablestack^.datasize;
 
@@ -983,12 +993,12 @@ unit pmodules;
 {$ifdef GDB}
          { add all used definitions even for implementation}
          if (cs_debuginfo in aktmoduleswitches) then
-            begin
-                  { all types }
-                  punitsymtable(symtablestack)^.concattypestabto(debuglist);
-                  { and all local symbols}
-                  symtablestack^.concatstabto(debuglist);
-            end;
+          begin
+            { all types }
+            punitsymtable(symtablestack)^.concattypestabto(debuglist);
+            { and all local symbols}
+            symtablestack^.concatstabto(debuglist);
+          end;
 {$endif GDB}
 
          current_module^.in_implementation:=false;
@@ -1001,6 +1011,10 @@ unit pmodules;
          symtablestack^.symtabletype:=unitsymtable;
          punitsymtable(symtablestack)^.is_stab_written:=false;
 
+         { insert own objectfile }
+         insertobjectfile;
+        
+
          {Write out the unit if the compile was succesfull.}
          if status.errorcount=0 then
           writeunitas(current_module^.ppufilename^,punitsymtable(symtablestack));
@@ -1013,12 +1027,21 @@ unit pmodules;
            end;
          inc(datasize,symtablestack^.datasize);
 
+         { leave when we got an error }
+         if status.errorcount>0 then
+          exit;
+        
+
          { generate imports }
          if current_module^.uses_imports then
           importlib^.generatelib;
 
          { finish asmlist by adding segment starts }
          insertsegment;
+        
+
+         { assemble }
+         create_objectfile;
       end;
 
 
@@ -1122,7 +1145,10 @@ unit pmodules;
 
          consume(POINT);
 
-         setlinkerfile;
+         { leave when we got an error }
+         if status.errorcount>0 then
+          exit;
+        
 
          { insert heap }
          insertheap;
@@ -1137,12 +1163,32 @@ unit pmodules;
 
          { finish asmlist by adding segment starts }
          insertsegment;
+
+         { insert own objectfile }
+         insertobjectfile;
+        
+
+         { assemble and link }
+         create_objectfile;
+                
+
+         { create the executable when we are at level 1 }
+         if (compile_level=1) then
+          begin
+            if (cs_link_deffile in aktglobalswitches) then
+             deffile.writefile;
+            if (not current_module^.is_unit) then
+             Linker.MakeExecutable;
+          end;
       end;
 
 end.
 {
   $Log$
-  Revision 1.39  1998-08-14 21:56:37  peter
+  Revision 1.40  1998-08-17 09:17:50  peter
+    * static/shared linking updates
+
+  Revision 1.39  1998/08/14 21:56:37  peter
     * setting the outputfile using -o works now to create static libs
 
   Revision 1.38  1998/08/10 14:50:13  peter

+ 14 - 9
compiler/ppu.pas

@@ -88,14 +88,16 @@ const
   ibwidestringdef = 56;
 
 { unit flags }
-  uf_init           = $1;
-  uf_has_dbx        = $2;
-  uf_has_browser    = $4;
-  uf_big_endian     = $8;
-  uf_in_library     = $10;
-  uf_shared_library = $20;
-  uf_smartlink      = $40;
-  uf_finalize       = $80;
+  uf_init          = $1;
+  uf_finalize      = $2;
+  uf_big_endian    = $4;
+  uf_has_dbx       = $8;
+  uf_has_browser   = $10;
+  uf_smartlink     = $20;
+  uf_in_library    = $40; { is the file in another file than <ppufile>.* ? }
+  uf_static_linked = $80;
+  uf_shared_linked = $100;
+
 
 type
 {$ifdef m68k}
@@ -760,7 +762,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.8  1998-08-11 15:31:40  peter
+  Revision 1.9  1998-08-17 09:17:51  peter
+    * static/shared linking updates
+
+  Revision 1.8  1998/08/11 15:31:40  peter
     * write extended to ppu file
     * new version 0.99.7
 

+ 25 - 9
compiler/symppu.inc

@@ -180,12 +180,20 @@
        { create unit flags }
          with Current_Module^ do
           begin
-            if cs_smartlink in aktmoduleswitches then
+            if cs_create_staticlib in aktmoduleswitches then
              begin
-               flags:=flags or uf_smartlink;
-               if SplitName(ppufilename^)<>SplitName(libfilename^) then
+               flags:=flags or uf_static_linked;
+               if SplitName(ppufilename^)<>SplitName(staticlibfilename^) then
+                 flags:=flags or uf_in_library;
+             end;
+            if cs_create_sharedlib in aktmoduleswitches then
+             begin
+               flags:=flags or uf_shared_linked;
+               if SplitName(ppufilename^)<>SplitName(sharedlibfilename^) then
                  flags:=flags or uf_in_library;
              end;
+            if cs_smartlink in aktmoduleswitches then
+             flags:=flags or uf_smartlink;
             if use_dbx then
              flags:=flags or uf_has_dbx;
             if target_os.endian=en_big_endian then
@@ -315,7 +323,7 @@
     procedure readsourcefiles;
       var
         temp,hs       : string;
-        incfile_found : boolean;
+{        incfile_found : boolean; }
         ppufiletime,
         source_time   : longint;
 {$ifdef UseBrowser}
@@ -344,18 +352,23 @@
             begin
               { check the date of the source files }
               Source_Time:=GetNamedFileTime(current_module^.path^+hs);
-              if Source_Time=-1 then
+              { search for include files in the includepathlist, this
+                can't be done, becuase a .inc file with the same name as
+                used by a unit will cause the unit to recompile which is
+                not the intention (PFV) }
+            { if Source_Time=-1 then
                 begin
-                { search for include files in the includepathlist }
                   temp:=search(hs,includesearchpath,incfile_found);
                   if incfile_found then
                    begin
                      hs:=temp+hs;
                      Source_Time:=GetNamedFileTime(hs);
                    end;
+
                 end
-              else
-                hs:=current_module^.path^+hs;
+
+              else }
+              hs:=current_module^.path^+hs;
               if Source_Time=-1 then
                begin
                  current_module^.sources_avail:=false;
@@ -697,7 +710,10 @@
 
 {
   $Log$
-  Revision 1.11  1998-08-16 20:32:49  peter
+  Revision 1.12  1998-08-17 09:17:53  peter
+    * static/shared linking updates
+
+  Revision 1.11  1998/08/16 20:32:49  peter
     * crcs of used units are not important for the current crc, reduces the
       amount of recompiles
 

+ 14 - 2
compiler/systems.pas

@@ -99,7 +99,6 @@ unit systems;
        );
 
 
-
        tosinfo = record
           name      : string[30];
           sharedlibext,
@@ -108,6 +107,7 @@ unit systems;
           pasext,
           exeext,
           scriptext : string[4];
+          libprefix : string[3];
           Cprefix   : string[2];
           newline   : string[2];
           endian    : tendian;
@@ -205,6 +205,7 @@ implementation
             pasext       : '.PAS';
             exeext       : '';      { No .exe, the linker only output a.out ! }
             scriptext    : '.BAT';
+            libprefix    : '';
             Cprefix      : '_';
             newline      : #13#10;
             endian       : endian_little;
@@ -218,6 +219,7 @@ implementation
             pasext       : '.PAS';
             exeext       : '.EXE';
             scriptext    : '.BAT';
+            libprefix    : '';
             Cprefix      : '_';
             newline      : #13#10;
             endian       : endian_little;
@@ -231,6 +233,7 @@ implementation
             pasext       : '.pas';
             exeext       : '';
             scriptext    : '.sh';
+            libprefix    : 'lib';
             Cprefix      : '';
             newline      : #10;
             endian       : endian_little;
@@ -244,6 +247,7 @@ implementation
             pasext       : '.pp';
             exeext       : '.exe';
             scriptext    : '.cmd';
+            libprefix    : '';
             Cprefix      : '_';
             newline      : #13#10;
             endian       : endian_little;
@@ -257,6 +261,7 @@ implementation
             pasext       : '.pas';
             exeext       : '.exe';
             scriptext    : '.bat';
+            libprefix    : 'lib';
             Cprefix      : '_';
             newline      : #13#10;
             endian       : endian_little;
@@ -272,6 +277,7 @@ implementation
             pasext       : '.pas';
             exeext       : '';
             scriptext    : '';
+            libprefix    : '';
             Cprefix      : '';
             newline      : #10;
             endian       : en_big_endian;
@@ -285,6 +291,7 @@ implementation
             pasext       : '.pas';
             exeext       : '.tpp';
             scriptext    : '';
+            libprefix    : '';
             Cprefix      : '';
             newline      : #10;
             endian       : en_big_endian;
@@ -298,6 +305,7 @@ implementation
             pasext       : '.pas';
             exeext       : '.tpp';
             scriptext    : '';
+            libprefix    : '';
             Cprefix      : '';
             newline      : #13;
             endian       : en_big_endian;
@@ -311,6 +319,7 @@ implementation
             pasext       : '.pas';
             exeext       : '';
             scriptext    : '.sh';
+            libprefix    : 'lib';
             Cprefix      : '';
             newline      : #10;
             endian       : en_big_endian;
@@ -866,7 +875,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.23  1998-06-25 08:48:20  florian
+  Revision 1.24  1998-08-17 09:17:54  peter
+    * static/shared linking updates
+
+  Revision 1.23  1998/06/25 08:48:20  florian
     * first version of rtti support
 
   Revision 1.22  1998/06/17 14:10:21  peter