]> Cypherpunks.ru repositories - gostls13.git/blobdiff - test/linkobj.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / linkobj.go
index 023996aa30952a6453c8e3fbc3575676f60922a8..85570269eb5c5ee7e075e04838c5e309530be0e1 100644 (file)
@@ -1,6 +1,7 @@
-// +build !nacl,!js,gc
 // run
 
+//go:build !nacl && !js && gc && !wasip1
+
 // Copyright 2016 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
@@ -65,6 +66,11 @@ func main() {
                }
        `)
 
+       stdlibimportcfg, err := os.ReadFile(os.Getenv("STDLIB_IMPORTCFG"))
+       if err != nil {
+               fatalf("listing stdlib export files: %v", err)
+       }
+
        // two rounds: once using normal objects, again using .a files (compile -pack).
        for round := 0; round < 2; round++ {
                pkg := "-pack=" + fmt.Sprint(round)
@@ -75,10 +81,13 @@ func main() {
                        o = "a"
                }
 
+               importcfg := string(stdlibimportcfg) + "\npackagefile p1=p1." + o + "\npackagefile p2=p2." + o
+               os.WriteFile("importcfg", []byte(importcfg), 0644)
+
                // inlining is disabled to make sure that the link objects contain needed code.
-               run("go", "tool", "compile", "-p=p1", pkg, "-D", ".", "-I", ".", "-l", "-o", "p1."+o, "-linkobj", "p1.lo", "p1.go")
-               run("go", "tool", "compile", "-p=p2", pkg, "-D", ".", "-I", ".", "-l", "-o", "p2."+o, "-linkobj", "p2.lo", "p2.go")
-               run("go", "tool", "compile", "-p=main", pkg, "-D", ".", "-I", ".", "-l", "-o", "p3."+o, "-linkobj", "p3.lo", "p3.go")
+               run("go", "tool", "compile", "-p=p1", pkg, "-D", ".", "-importcfg=importcfg", "-l", "-o", "p1."+o, "-linkobj", "p1.lo", "p1.go")
+               run("go", "tool", "compile", "-p=p2", pkg, "-D", ".", "-importcfg=importcfg", "-l", "-o", "p2."+o, "-linkobj", "p2.lo", "p2.go")
+               run("go", "tool", "compile", "-p=main", pkg, "-D", ".", "-importcfg=importcfg", "-l", "-o", "p3."+o, "-linkobj", "p3.lo", "p3.go")
 
                cp("p1."+o, "p1.oo")
                cp("p2."+o, "p2.oo")
@@ -91,7 +100,7 @@ func main() {
                        fatalf("link p2.o failed but not for package main:\n%s", out)
                }
 
-               run("go", "tool", "link", "-L", ".", "-o", "a.out.exe", "p3."+o)
+               run("go", "tool", "link", "-importcfg=importcfg", "-o", "a.out.exe", "p3."+o)
                out = run("./a.out.exe")
                if !strings.Contains(out, "hello from p1\nhello from p2\nhello from main\n") {
                        fatalf("running main, incorrect output:\n%s", out)