Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions disassembler/objdump/diassembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os/exec"
"path/filepath"

"github.com/ChainSafe/vm-compat/common"
"github.com/ChainSafe/vm-compat/disassembler"
)

Expand Down Expand Up @@ -66,18 +65,15 @@ func generateSourceAssembly(target string, goos, arch string) (string, error) {
return "", err
}

// Find the module root of the target file
modRoot, err := common.FindGoModuleRoot(absPath)
if err != nil {
return "", fmt.Errorf("failed to find go module root: %w", err)
}
mainPackageDir := filepath.Dir(absPath)

//nolint:gosec
buildCmd := exec.Command("go", "build", "-o", tempFile, absPath)
buildCmd.Dir = modRoot // Set the working directory to the module root
buildCmd := exec.Command("go", "build", "-o", tempFile, "./")
buildCmd.Dir = mainPackageDir // Set the working directory to the main package
buildCmd.Env = append(os.Environ(),
fmt.Sprintf("GOOS=%s", goos),
fmt.Sprintf("GOARCH=%s", arch),
"GO111MODULE=off",
)
if arch == "mips" {
buildCmd.Env = append(buildCmd.Env, "GOMIPS=softfloat")
Expand Down
3 changes: 3 additions & 0 deletions e2e_tests/testdata/hello/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module hello

go 1.22.2
7 changes: 7 additions & 0 deletions e2e_tests/testdata/hello/hello.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func hello() {
fmt.Println("Hello World!")
}
5 changes: 5 additions & 0 deletions e2e_tests/testdata/hello/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package main

func main() {
hello()
}
Loading