Skip to content

Conversation

@archie2x
Copy link
Contributor

@archie2x archie2x commented Aug 21, 2024

Fixes:

u-root/cmds/core/init$ GOARCH={arm64,amd64} tinygo build -tags noasm
/usr/lib/go-1.22/src/syscall/exec_unix.go:282: linker could not find symbol syscall.runtime_BeforeExec
/usr/lib/go-1.22/src/syscall/exec_unix.go:308: linker could not find symbol syscall.runtime_AfterExec

I copied BigGo/src/runtime/proc.go for this, duplicating the //go:linkname

In BigGo, exec calls are serialized because of golang/go#19546 but uses a rwlock whose implementation would require a lot of file import from BigGo or a merge of tinygo/bigGo runtime against current policy. I may follow this up with a simple sync/Mutex.

@leongross ?

@leongross
Copy link
Contributor

I think you are addressing an important issue here, that has not been taken care of atm.
I tried to implement sth similar bit quite did not get it working, although this would be a great benefit.

@archie2x
Copy link
Contributor Author

I think you are addressing an important issue here, that has not been taken care of atm. I tried to implement sth similar bit quite did not get it working, although this would be a great benefit.

I saw your PR. I haven't pulled it / attempted to run it but I think it's missing these stubs for some reason? Does it work without them?

@archie2x archie2x marked this pull request as ready for review August 23, 2024 21:33
Copy link
Contributor

@leongross leongross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked out your changes and built the failing cmdlet switch_root with it and this works just fine.

For context: The previous errors were:

ld.lld: error: undefined symbol: syscall.runtime_BeforeExec
>>> referenced by exec_unix.go:279 (/usr/lib/golang/src/syscall/exec_unix.go:279)
>>>               /tmp/tinygo131981138/main.lto.main.o:(runtime.run$1$gowrapper)

ld.lld: error: undefined symbol: syscall.runtime_AfterExec
>>> referenced by exec_unix.go:305 (/usr/lib/golang/src/syscall/exec_unix.go:305)
>>>               /tmp/tinygo131981138/main.lto.main.o:(runtime.run$1$gowrapper)
failed to run tool: ld.lld
error: failed to link /tmp/tinygo131981138/main: exit status 1

Comment on lines +11 to +12
// Used in BigGo to serialize exec / thread creation. Stubbing to
// satisfy link.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this maybe before the function to generate the doc string?

@@ -0,0 +1,19 @@
// Copyright 2014 The Go Authors. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
// Copyright 2014 The Go Authors. All rights reserved.
// Copyright 2024 The Go Authors. All rights reserved.

@leongross
Copy link
Contributor

@aykevl @deadprogram

@leongross
Copy link
Contributor

On a kind of related note: #4384 implements the missing signals so the linker does not break the compilation

@leongross leongross mentioned this pull request Sep 2, 2024
@deadprogram
Copy link
Member

Thank you for the PR @archie2x and to @leongross for review. Now merging.

@deadprogram deadprogram merged commit e39358d into tinygo-org:dev Sep 4, 2024
@leongross
Copy link
Contributor

Thanks @deadprogram for merging.

@leongross leongross mentioned this pull request Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants