diff --git a/disassembler/objdump/diassembler.go b/disassembler/objdump/diassembler.go index 78b0846..cbb88b3 100644 --- a/disassembler/objdump/diassembler.go +++ b/disassembler/objdump/diassembler.go @@ -7,7 +7,6 @@ import ( "os/exec" "path/filepath" - "github.com/ChainSafe/vm-compat/common" "github.com/ChainSafe/vm-compat/disassembler" ) @@ -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") diff --git a/e2e_tests/testdata/hello/go.mod b/e2e_tests/testdata/hello/go.mod new file mode 100644 index 0000000..853b93f --- /dev/null +++ b/e2e_tests/testdata/hello/go.mod @@ -0,0 +1,3 @@ +module hello + +go 1.22.2 diff --git a/e2e_tests/testdata/hello/hello.go b/e2e_tests/testdata/hello/hello.go new file mode 100644 index 0000000..f4adb47 --- /dev/null +++ b/e2e_tests/testdata/hello/hello.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func hello() { + fmt.Println("Hello World!") +} diff --git a/e2e_tests/testdata/hello/main.go b/e2e_tests/testdata/hello/main.go new file mode 100644 index 0000000..0a4df15 --- /dev/null +++ b/e2e_tests/testdata/hello/main.go @@ -0,0 +1,5 @@ +package main + +func main() { + hello() +}