@@ -13,6 +13,7 @@ import (
1313)
1414
1515type linuxCompiler struct {
16+ toolset string
1617}
1718
1819func (ci linuxCompiler ) Compile (path , objDir string , options * CompilerOptions ) error {
@@ -43,7 +44,7 @@ func (ci linuxCompiler) Compile(path, objDir string, options *CompilerOptions) e
4344
4445 args = append (args , path )
4546
46- cmd := exec .Command ("gcc" , args ... )
47+ cmd := exec .Command (ci . toolset , args ... )
4748
4849 if options .Verbose {
4950 log .Trace ("%s" , strings .Join (cmd .Args , " " ))
@@ -60,7 +61,7 @@ func (ci linuxCompiler) Compile(path, objDir string, options *CompilerOptions) e
6061func (ci linuxCompiler ) Link (objDir , outPath string , outType LinkType , options * CompilerOptions ) (string , error ) {
6162 args := make ([]string , 0 )
6263
63- exeName := "gcc"
64+ exeName := ci . toolset
6465
6566 switch outType {
6667 case LinkExe :
@@ -82,8 +83,11 @@ func (ci linuxCompiler) Link(objDir, outPath string, outType LinkType, options *
8283 } else {
8384 args = append (args , "-o" , outPath )
8485 args = append (args , "-std=c++17" )
85- args = append (args , "-static-libgcc" )
86- args = append (args , "-static-libstdc++" )
86+
87+ if ci .toolset == "gcc" {
88+ args = append (args , "-static-libgcc" )
89+ args = append (args , "-static-libstdc++" )
90+ }
8791
8892 if options .Static {
8993 args = append (args , "-static" )
@@ -93,16 +97,6 @@ func (ci linuxCompiler) Link(objDir, outPath string, outType LinkType, options *
9397 for _ , dir := range options .LinkDirectories {
9498 args = append (args , "-L" + dir )
9599 }
96-
97- // Add libraries to link
98- for _ , link := range options .LinkLibraries {
99- args = append (args , "-l" + link )
100- }
101-
102- // Add additional linker flags
103- for _ , flag := range options .LinkerFlags {
104- args = append (args , flag )
105- }
106100 }
107101
108102 filepath .Walk (objDir , func (path string , info os.FileInfo , err error ) error {
@@ -116,6 +110,21 @@ func (ci linuxCompiler) Link(objDir, outPath string, outType LinkType, options *
116110 return nil
117111 })
118112
113+ if outType != LinkLib {
114+ // Link to some common standard libraries
115+ args = append (args , "-lstdc++" )
116+
117+ // Add libraries to link
118+ for _ , link := range options .LinkLibraries {
119+ args = append (args , "-l" + link )
120+ }
121+
122+ // Add additional linker flags
123+ for _ , flag := range options .LinkerFlags {
124+ args = append (args , flag )
125+ }
126+ }
127+
119128 cmd := exec .Command (exeName , args ... )
120129
121130 if options .Verbose {
0 commit comments