-// +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.
}
`)
+ 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)
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")
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)