diff -r 706e93959a9c -r 4e4f134b6e26 ObjectFileLoader.st --- a/ObjectFileLoader.st Fri Sep 02 17:35:56 2016 +0100 +++ b/ObjectFileLoader.st Tue Sep 06 06:59:40 2016 +0200 @@ -2665,107 +2665,107 @@ osType := OperatingSystem getOSType. osType = #win32 ifTrue:[ - self activityNotification:'generating shared object'. - ParserFlags linkArgs isNil ifTrue:[ - ld := self linkCommand , ' ' , baseFileName , '.obj'. - ld := ld - , ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL' - , ' /OUT:' , baseFileName , '.dll ' + self activityNotification:'generating shared object'. + ParserFlags linkArgs isNil ifTrue:[ + ld := self linkCommand , ' ' , baseFileName , '.obj'. + ld := ld + , ' /NOPACK /NOLOGO /DEBUG /MACHINE:I386 /DLL' + , ' /OUT:' , baseFileName , '.dll ' "/ , ' /DEF:' , baseFileName , '.def'. - ] ifFalse:[ + ] ifFalse:[ "/ libDir := ParserFlags libDirectory. "/ (libDir notNil and:[libDir asFilename exists]) ifFalse:[ - ParserFlags useBorlandC ifTrue:[ - libDirBasename := 'lib\bc' - ] ifFalse:[ - ParserFlags useVisualC ifTrue:[ - libDirBasename := 'lib\vc' - ] ifFalse:[ - (ParserFlags useMingw32 or:[ParserFlags useMingw64]) ifTrue:[ - libDirBasename := 'lib\mingw' - ] ifFalse:[ - libDirBasename := 'lib\vc' - ] - ] - ]. - homeDir := Smalltalk packagePath detect:[:p | (p asFilename / 'stx' / libDirBasename) exists] ifNone:nil. - homeDir notNil ifTrue:[ - libDir := (homeDir asFilename / 'stx' / libDirBasename) pathName - ]. - libDir isNil ifTrue:[ - "/ some fallback - libDir := #( '..' - '..\..' - '..\..\..' - '..\..\stx' - '..\..\..\stx' - ) detect:[:p | (p asFilename / libDirBasename) exists] ifNone:nil. - - libDir isNil ifTrue:[ - LastError := errorMessage := 'could not locate directory where .lib files are (',libDirBasename,')'. - ObjectFileLoadError raiseRequestErrorString:errorMessage. - ^ nil - ]. - ]. + ParserFlags useBorlandC ifTrue:[ + libDirBasename := 'lib\bc' + ] ifFalse:[ + ParserFlags useVisualC ifTrue:[ + libDirBasename := 'lib\vc' + ] ifFalse:[ + (ParserFlags useMingw32 or:[ParserFlags useMingw64]) ifTrue:[ + libDirBasename := 'lib\mingw' + ] ifFalse:[ + libDirBasename := 'lib\vc' + ] + ] + ]. + homeDir := Smalltalk packagePath detect:[:p | (p asFilename / 'stx' / libDirBasename) exists] ifNone:nil. + homeDir notNil ifTrue:[ + libDir := (homeDir asFilename / 'stx' / libDirBasename) pathName + ]. + libDir isNil ifTrue:[ + "/ some fallback + libDir := #( '..' + '..\..' + '..\..\..' + '..\..\stx' + '..\..\..\stx' + ) detect:[:p | (p asFilename / libDirBasename) exists] ifNone:nil. + + libDir isNil ifTrue:[ + LastError := errorMessage := 'could not locate directory where .lib files are (',libDirBasename,')'. + ObjectFileLoadError raiseRequestErrorString:errorMessage. + ^ nil + ]. + ]. "/ ]. - ParserFlags useBorlandC ifTrue:[ - ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). - ld := ld , ' c0d32.obj ' , baseFileName , '.obj '. - ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '. - ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). - ld := ld , ' ',libDir,'\cs32i.lib,,'. - ] ifFalse:[ - ParserFlags useVisualC ifTrue:[ - "/ todo: fix for correct link libs - ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). - ld := ld , ' c0d32.obj ' , baseFileName , '.obj '. - ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '. - ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). - ld := ld , ' ',libDir,'\cs32i.lib,,'. - ] ifFalse:[ - (ParserFlags useMingw64 or:[ParserFlags useMingw32]) ifTrue:[ - ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). - ld := ld , ' -shared -o ',baseFileName,'.dll '. - ld := ld , baseFileName,'.obj '. - ld := ld , libDir,'\librun.lib '. - ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). - ] ifFalse:[ - ObjectFileLoadError raiseRequestErrorString:'for dynamic objects, only borlandC is (currently) supported'. - LastError := 'for dynamic objects, only borlandC is (currently) supported'. - ^ nil - ] - ] - ] - ]. - - outfile := (baseFileName , '.out'). - (Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[ - Transcript showCR:('executing: ',ld). - ]. - - ok := OperatingSystem executeCommand:(ld , ' >' , outfile). - ok ifFalse:[ - output := (baseFileName , '.out') asFilename contentsOfEntireFile. - Transcript showCR:output; endEntry. - Transcript showCR:'Failed linkCommand:'. - Transcript showCR:ld. - Transcript showCR:'ParserFlags are:'. - Transcript showCR:ParserFlags. - ]. - - #('.obj' '.out' '.tds' '.ilc' '.ild' - '.ilf' '.ils' '.lib' '.map' '.def' '.o') do:[:eachSuffix| - (baseFileName , eachSuffix) asFilename delete. - ]. - - ok ifFalse:[ - LastError := output. - "/ ObjectFileLoadError raiseRequestErrorString:'link failed'. - ^ nil - ]. - oFileName := (baseFileName , self sharedLibraryExtension) asFilename name. - ^ oFileName + ParserFlags useBorlandC ifTrue:[ + ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). + ld := ld , ' c0d32.obj ' , baseFileName , '.obj '. + ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '. + ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). + ld := ld , ' ',libDir,'\cs32i.lib,,'. + ] ifFalse:[ + ParserFlags useVisualC ifTrue:[ + "/ todo: fix for correct link libs + ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). + ld := ld , ' c0d32.obj ' , baseFileName , '.obj '. + ld := ld , ',' , baseFileName , '.dll,,',libDir,'\librun.lib '. + ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). + ld := ld , ' ',libDir,'\cs32i.lib,,'. + ] ifFalse:[ + (ParserFlags useMingw64 or:[ParserFlags useMingw32]) ifTrue:[ + ld := self linkCommand , ' ' , (ParserFlags linkArgs bindWith:baseFileName). + ld := ld , ' -shared -o ',baseFileName,'.dll '. + ld := ld , baseFileName,'.obj '. + ld := ld , libDir,'\librun.lib '. + ld := ld , (ParserFlags searchedLibraries asStringCollection asStringWith: $ ). + ] ifFalse:[ + ObjectFileLoadError raiseRequestErrorString:'for dynamic objects, only borlandC is (currently) supported'. + LastError := 'for dynamic objects, only borlandC is (currently) supported'. + ^ nil + ] + ] + ] + ]. + + outfile := (baseFileName , '.out'). + (Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[ + Transcript showCR:('executing: ',ld). + ]. + + ok := OperatingSystem executeCommand:(ld , ' >' , outfile) showWindow:false. + ok ifFalse:[ + output := (baseFileName , '.out') asFilename contentsOfEntireFile. + Transcript showCR:output; endEntry. + Transcript showCR:'Failed linkCommand:'. + Transcript showCR:ld. + Transcript showCR:'ParserFlags are:'. + Transcript showCR:ParserFlags. + ]. + + #('.obj' '.out' '.tds' '.ilc' '.ild' + '.ilf' '.ils' '.lib' '.map' '.def' '.o') do:[:eachSuffix| + (baseFileName , eachSuffix) asFilename delete. + ]. + + ok ifFalse:[ + LastError := output. + "/ ObjectFileLoadError raiseRequestErrorString:'link failed'. + ^ nil + ]. + oFileName := (baseFileName , self sharedLibraryExtension) asFilename name. + ^ oFileName ]. "/ UNIX systems @@ -2776,113 +2776,113 @@ fmt := ObjectFileLoader loadableBinaryObjectFormat. (fmt == #elf or:[ fmt == #macho ]) ifTrue:[ - " - link it to a shared object with 'ld -shared' - " - needSharedObject := true. - ld := self linkCommand ? 'cc'. - ldArg := self linkSharedArgs. - ldArg isNil ifTrue:[ - "/ some default - ExternalAddress pointerSize == 4 ifTrue:[ - ldArg := '-m32 -shared'. - ] ifFalse:[ - ldArg := '--shared'. - ] - ] + " + link it to a shared object with 'ld -shared' + " + needSharedObject := true. + ld := self linkCommand ? 'cc'. + ldArg := self linkSharedArgs. + ldArg isNil ifTrue:[ + "/ some default + ExternalAddress pointerSize == 4 ifTrue:[ + ldArg := '-m32 -shared'. + ] ifFalse:[ + ldArg := '--shared'. + ] + ] ]. osType = #irix ifTrue:[ - " - link it to a shared object with 'ld -shared' - " - needSharedObject := true. - ldArg := self linkSharedArgs ? '-shared'. + " + link it to a shared object with 'ld -shared' + " + needSharedObject := true. + ldArg := self linkSharedArgs ? '-shared'. ]. osType = #'sys5_4' ifTrue:[ - " - link it to a shared object with 'ld -G' - " - needSharedObject := true. - ldArg := self linkSharedArgs ? '-G'. + " + link it to a shared object with 'ld -G' + " + needSharedObject := true. + ldArg := self linkSharedArgs ? '-G'. ]. osType = #solaris ifTrue:[ - " - link it to a shared object with 'ld -G -B dynamic' - " - needSharedObject := true. - ldArg := self linkSharedArgs ? '-G -Bdynamic'. + " + link it to a shared object with 'ld -G -B dynamic' + " + needSharedObject := true. + ldArg := self linkSharedArgs ? '-G -Bdynamic'. ]. osType = #hpux ifTrue:[ - " - link it to a shared object with 'ld -b -B immediate' - " - needSharedObject := true. - ldArg := self linkSharedArgs ? '-b -B immediate'. + " + link it to a shared object with 'ld -b -B immediate' + " + needSharedObject := true. + ldArg := self linkSharedArgs ? '-b -B immediate'. ]. osType = #aix ifTrue:[ - self activityNotification:'create export file'. - - "/ create an exports file. - expFileName := './' , baseFileName , '.exp'. - [ - expFile := expFileName asFilename writeStream. - expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension). - expFile cr. - expFile nextPutAll:'_' , baseFileName , '_Init'. - expFile close. - ] on:FileStream openErrorSignal do:[:ex| "do nothing"]. - - self activityNotification:'generating shared object'. - - " - link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE' - " - needSharedObject := true. - ld := 'cc'. - librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'. - librunExpFileName isNil ifTrue:[ - LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'. - ^ nil - ]. - - ldArg := '-bI:' , librunExpFileName , - ' -bE:' , baseFileName , '.exp' , - ' -bM:SRE -e _' , baseFileName , '_Init'. + self activityNotification:'create export file'. + + "/ create an exports file. + expFileName := './' , baseFileName , '.exp'. + [ + expFile := expFileName asFilename writeStream. + expFile nextPutAll:'#!! ./' , baseFileName , (self sharedLibraryExtension). + expFile cr. + expFile nextPutAll:'_' , baseFileName , '_Init'. + expFile close. + ] on:FileStream openErrorSignal do:[:ex| "do nothing"]. + + self activityNotification:'generating shared object'. + + " + link it to a shared object with 'cc -bI:...librun.exp -bE -bMSRE' + " + needSharedObject := true. + ld := 'cc'. + librunExpFileName := Smalltalk getSystemFileName:'lib/librun_aix.exp'. + librunExpFileName isNil ifTrue:[ + LastError := 'missing exports file: ''lib/librun_aix.exp'' - cannot link'. + ^ nil + ]. + + ldArg := '-bI:' , librunExpFileName , + ' -bE:' , baseFileName , '.exp' , + ' -bM:SRE -e _' , baseFileName , '_Init'. ]. oFileName := baseFileName , self objectFileExtension. needSharedObject ifTrue:[ - self activityNotification:'generating shared object'. - - soFileName := baseFileName , self sharedLibraryExtension. - OperatingSystem removeFile:soFileName. - ld := ld , ' ' , ldArg , ' ', (ParserFlags linkArgs ? '') , - ' -o ' , soFileName , ' ' , oFileName , ' ', - ((ParserFlags searchedLibraries ? #()) asStringCollection asStringWith: $ ). - - (Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[ - Transcript showCR:('linking with: ',ld). - ]. - ok := OperatingSystem executeCommand:(ld , ' >errorOutput 2>&1'). - - ok ifFalse:[ - output := 'errorOutput' asFilename contentsOfEntireFile. - Transcript showCR:'linker error message:'. - Transcript showCR:output. - Transcript showCR:'linker command:'. - Transcript showCR:ld; endEntry. - ]. - - OperatingSystem removeFile:oFileName. - expFileName notNil ifTrue:[ - OperatingSystem removeFile:expFileName - ]. - ^ soFileName. + self activityNotification:'generating shared object'. + + soFileName := baseFileName , self sharedLibraryExtension. + OperatingSystem removeFile:soFileName. + ld := ld , ' ' , ldArg , ' ', (ParserFlags linkArgs ? '') , + ' -o ' , soFileName , ' ' , oFileName , ' ', + ((ParserFlags searchedLibraries ? #()) asStringCollection asStringWith: $ ). + + (Verbose or:[ STCCompilerInterface verbose ]) ifTrue:[ + Transcript showCR:('linking with: ',ld). + ]. + ok := OperatingSystem executeCommand:(ld , ' >errorOutput 2>&1'). + + ok ifFalse:[ + output := 'errorOutput' asFilename contentsOfEntireFile. + Transcript showCR:'linker error message:'. + Transcript showCR:output. + Transcript showCR:'linker command:'. + Transcript showCR:ld; endEntry. + ]. + + OperatingSystem removeFile:oFileName. + expFileName notNil ifTrue:[ + OperatingSystem removeFile:expFileName + ]. + ^ soFileName. ]. "