@@ -1544,12 +1544,12 @@ func (b *builder) build(a *action) (err error) {
1544
1544
}
1545
1545
1546
1546
// Assemble .s files.
1547
- for _ , file := range sfiles {
1548
- out := file [: len ( file ) - len ( ".s" )] + ".o"
1549
- if err := buildToolchain . asm ( b , a . p , obj , obj + out , file ); err != nil {
1547
+ if len ( sfiles ) > 0 {
1548
+ ofiles , err := buildToolchain . asm ( b , a . p , obj , sfiles )
1549
+ if err != nil {
1550
1550
return err
1551
1551
}
1552
- objects = append (objects , out )
1552
+ objects = append (objects , ofiles ... )
1553
1553
}
1554
1554
1555
1555
// NOTE(rsc): On Windows, it is critically important that the
@@ -2187,9 +2187,9 @@ type toolchain interface {
2187
2187
// cc runs the toolchain's C compiler in a directory on a C file
2188
2188
// to produce an output file.
2189
2189
cc (b * builder , p * Package , objdir , ofile , cfile string ) error
2190
- // asm runs the assembler in a specific directory on a specific file
2191
- // to generate the named output file .
2192
- asm (b * builder , p * Package , obj , ofile , sfile string ) error
2190
+ // asm runs the assembler in a specific directory on specific files
2191
+ // and returns a list of named output files .
2192
+ asm (b * builder , p * Package , obj string , sfiles [] string ) ([] string , error )
2193
2193
// pkgpath builds an appropriate path for a temporary package file.
2194
2194
pkgpath (basedir string , p * Package ) string
2195
2195
// pack runs the archive packer in a specific directory to create
@@ -2226,8 +2226,8 @@ func (noToolchain) gc(b *builder, p *Package, archive, obj string, asmhdr bool,
2226
2226
return "" , nil , noCompiler ()
2227
2227
}
2228
2228
2229
- func (noToolchain ) asm (b * builder , p * Package , obj , ofile , sfile string ) error {
2230
- return noCompiler ()
2229
+ func (noToolchain ) asm (b * builder , p * Package , obj string , sfiles [] string ) ([] string , error ) {
2230
+ return nil , noCompiler ()
2231
2231
}
2232
2232
2233
2233
func (noToolchain ) pkgpath (basedir string , p * Package ) string {
@@ -2324,15 +2324,18 @@ func (gcToolchain) gc(b *builder, p *Package, archive, obj string, asmhdr bool,
2324
2324
return ofile , output , err
2325
2325
}
2326
2326
2327
- func (gcToolchain ) asm (b * builder , p * Package , obj , ofile , sfile string ) error {
2327
+ func (gcToolchain ) asm (b * builder , p * Package , obj string , sfiles [] string ) ([] string , error ) {
2328
2328
// Add -I pkg/GOOS_GOARCH so #include "textflag.h" works in .s files.
2329
2329
inc := filepath .Join (goroot , "pkg" , "include" )
2330
- sfile = mkAbs (p .Dir , sfile )
2331
- args := []interface {}{buildToolExec , tool ("asm" ), "-o" , ofile , "-trimpath" , b .work , "-I" , obj , "-I" , inc , "-D" , "GOOS_" + goos , "-D" , "GOARCH_" + goarch , buildAsmflags , sfile }
2330
+ ofile := obj + "asm.o"
2331
+ args := []interface {}{buildToolExec , tool ("asm" ), "-o" , ofile , "-trimpath" , b .work , "-I" , obj , "-I" , inc , "-D" , "GOOS_" + goos , "-D" , "GOARCH_" + goarch , buildAsmflags }
2332
+ for _ , sfile := range sfiles {
2333
+ args = append (args , mkAbs (p .Dir , sfile ))
2334
+ }
2332
2335
if err := b .run (p .Dir , p .ImportPath , nil , args ... ); err != nil {
2333
- return err
2336
+ return nil , err
2334
2337
}
2335
- return nil
2338
+ return [] string { ofile }, nil
2336
2339
}
2337
2340
2338
2341
// toolVerify checks that the command line args writes the same output file
@@ -2599,15 +2602,24 @@ func (tools gccgoToolchain) gc(b *builder, p *Package, archive, obj string, asmh
2599
2602
return ofile , output , err
2600
2603
}
2601
2604
2602
- func (tools gccgoToolchain ) asm (b * builder , p * Package , obj , ofile , sfile string ) error {
2603
- sfile = mkAbs (p .Dir , sfile )
2604
- defs := []string {"-D" , "GOOS_" + goos , "-D" , "GOARCH_" + goarch }
2605
- if pkgpath := gccgoCleanPkgpath (p ); pkgpath != "" {
2606
- defs = append (defs , `-D` , `GOPKGPATH=` + pkgpath )
2605
+ func (tools gccgoToolchain ) asm (b * builder , p * Package , obj string , sfiles []string ) ([]string , error ) {
2606
+ var ofiles []string
2607
+ for _ , sfile := range sfiles {
2608
+ ofile := obj + sfile [:len (sfile )- len (".s" )] + ".o"
2609
+ ofiles = append (ofiles , ofile )
2610
+ sfile = mkAbs (p .Dir , sfile )
2611
+ defs := []string {"-D" , "GOOS_" + goos , "-D" , "GOARCH_" + goarch }
2612
+ if pkgpath := gccgoCleanPkgpath (p ); pkgpath != "" {
2613
+ defs = append (defs , `-D` , `GOPKGPATH=` + pkgpath )
2614
+ }
2615
+ defs = tools .maybePIC (defs )
2616
+ defs = append (defs , b .gccArchArgs ()... )
2617
+ err := b .run (p .Dir , p .ImportPath , nil , tools .compiler (), "-xassembler-with-cpp" , "-I" , obj , "-c" , "-o" , ofile , defs , sfile )
2618
+ if err != nil {
2619
+ return nil , err
2620
+ }
2607
2621
}
2608
- defs = tools .maybePIC (defs )
2609
- defs = append (defs , b .gccArchArgs ()... )
2610
- return b .run (p .Dir , p .ImportPath , nil , tools .compiler (), "-xassembler-with-cpp" , "-I" , obj , "-c" , "-o" , ofile , defs , sfile )
2622
+ return ofiles , nil
2611
2623
}
2612
2624
2613
2625
func (gccgoToolchain ) pkgpath (basedir string , p * Package ) string {
0 commit comments