Skip to content

Commit 48d741f

Browse files
aykevldeadprogram
authored andcommitted
compiler: emit an error when the actual arch doesn't match GOARCH
See: #4959 This makes sure to emit an error instead of generating inline assembly, which leads to hard-to-debug linker errors. Instead, it will now produce errors like the following: # golang.org/x/sys/unix ../../../../pkg/mod/golang.org/x/[email protected]/unix/affinity_linux.go:20:23: system calls are not supported: target emulates a linux/arm system on wasm32 ../../../../pkg/mod/golang.org/x/[email protected]/unix/fcntl.go:17:29: system calls are not supported: target emulates a linux/arm system on wasm32 ../../../../pkg/mod/golang.org/x/[email protected]/unix/fcntl.go:32:24: system calls are not supported: target emulates a linux/arm system on wasm32
1 parent 35e6b8a commit 48d741f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

compiler/syscall.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ func (b *builder) createRawSyscall(call *ssa.CallCommon) (llvm.Value, error) {
7474
return b.CreateCall(fnType, target, args, ""), nil
7575

7676
case b.GOARCH == "arm" && b.GOOS == "linux":
77+
if arch := b.archFamily(); arch != "arm" {
78+
// Some targets pretend to be linux/arm for compatibility but aren't
79+
// actually such a system. Make sure we emit an error instead of
80+
// creating inline assembly that will fail to compile.
81+
// See: https://github.com/tinygo-org/tinygo/issues/4959
82+
return llvm.Value{}, b.makeError(call.Pos(), "system calls are not supported: target emulates a linux/arm system on "+arch)
83+
}
84+
7785
// Implement the EABI system call convention for Linux.
7886
// Source: syscall(2) man page.
7987
args := []llvm.Value{}

0 commit comments

Comments
 (0)