-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: add runtime.fcntl link directives #4481
base: dev
Are you sure you want to change the base?
Conversation
aaf0e21
to
0dc68ce
Compare
//go:linkname syscall_fcntl runtime/runtime.fcntl | ||
func syscall_fcntl(fd, cmd, arg int32) (ret int32, errno int32) { | ||
// https://cs.opensource.google/go/go/+/master:src/runtime/os_linux.go;l=452?q=runtime.fcntl&ss=go%2Fgo | ||
r, _, err := Syscall6(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you trying to do a direct system call in syscall_libc.go? Syscall6
and the like are only supported on Windows and Linux, not on many other systems.
What about calling the libc function fcntl
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a wrapper to the libc sounds like a good idea.
src/runtime/os_linux.go
Outdated
func fcntl(fd, cmd, arg int32) (ret int32, errno int32){ | ||
return 0, 0 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bad idea. It should not just ignore the call and return without an error.
Is this intended to call syscall_fcntl
perhaps?
And then, any reason not to call the libc function instead (like with syscall_Getpagesize
for example).
@@ -212,6 +212,13 @@ func Truncate(path string, length int64) (err error) { | |||
return | |||
} | |||
|
|||
//go:linkname syscall_fcntl runtime/runtime.fcntl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant runtime.fcntl
?
//go:linkname syscall_fcntl runtime/runtime.fcntl | |
//go:linkname syscall_fcntl runtime.fcntl |
64826b3
to
d8e381e
Compare
I am perplexed by the linker's behavior. After reconsidering your design choices, what I want to do is the following:
I tried:
I realized it only worked when I defined |
d8e381e
to
560d34a
Compare
Signed-off-by: leongross <[email protected]>
Signed-off-by: leongross <[email protected]>
Signed-off-by: leongross <[email protected]>
560d34a
to
7a2e938
Compare
Building u-root commands with tinygo (see u-root/u-root#2979) returns linking errors for the system runtime function
runtime.fcntl
. This PR intends to fix this issue. Affected u-root cmdlets: