@sir @espectalll The ideal compiler would not do a syscall, but a single call to libc, though. syscalls are not stable on most OSes and the proper abstraction is libc. The idea of using syscalls directly is a Linuxism that unfortunately is widely spread in the Go community and resulted in binaries that break when you update your OS on e.g. macOS or OpenBSD. Please don’t spread the misinformation that it’s good to call syscalls directly.

@js @sir I mean, other than the assembly version I don't think any binary is not using a libc, I don't think that's the message AT ALL

@js @espectalll @sir Well it can avoid it, sure, with the correct build flags (don’t remember off the top of my head) but as soon as I used net package it turned it from a static binary into a libc-using dynamic binary.

You can tell it to build a static binary, in which case it starts to use its own DNS resolver and such. For my own use, that’s a downside as then it cannot resolve winbind or avahi hostnames, or user info provided from LDAP, or similar.

$ cat tmp.go

package main import ( "fmt" "net" ) func main() { net.Dial("tcp", "www.google.com:80") b := []byte{'A', 'b'} fmt.Printf("%s\n", b) }

$ ldd tmp

linux-vdso.so.1 (0x00007ffd04d83000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f92bceb3000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f92bccf3000) /lib64/ld-linux-x86-64.so.2 (0x00007f92bcef6000)

(Initial tmp.go didn’t have the use of net package so it actually did produce a static binary.)

Sign in to participate in the conversation
Mastodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!