-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
cmd/link: Any plan to support to link libhugetlbfs on the Golang linker? #50549
Comments
I'm not sure I understand this. Could you explain what you'd like to do, like, what commands you'd want to run which is not currently available? What do you mean by "directly linked"? If I understand correctly, libhugetlbfs is a C library, so cgo needs to be involved to use it. Thanks. |
Yes, libhugetlbfs is a C library. If we use cgo to link this library, maybe only C code is mapped to hugepage. The external linker (such as ld or gold) can linker go.o, libhugetlbfs.so and the other libraries, then both Go code and C can be mapped to hugepage. While our goal is to make both the go code and c code use hugepages by the internal linker (Golang linker). Using the external linker: libhugetlb.so is linked. Using the internal linker: |
The Go runtime on Linux makes direct system calls. It does not use the C library. Linking against libhugetlbfs will not affect Go code. It will only affect C code. So I don't think there is anything to do here. |
Sorry for the late reply. I use the command "go build -a -ldflags='-extld=gcc "-extldflags=-zcommon-page-size=2097152 -zmax-page-size=2097152 -L/usr/lib64 -lhugetlbfs -fuse-ld=bfd" -linkmode=external -buildid=IdNone' demo.go", then run ./demo (demo.go are written by only go) We found that this go code is affect by C library (libhugetlbfs.so) |
When you build a Go program with |
As @ianlancetaylor said. I don't think we want to link with a C library for pure Go programs. If we want the text segment to be backed by hugepages, we should probably use some other mechanism instead of a C library. Thanks. |
Hi, everyone
I'm researching how to use the golang linker to link libhugetlbfs. And I find the C dynamic library cannot be directly linked except using cgo or directly using external linker (such as ld/gold/lld). I have two question as follows:
The text was updated successfully, but these errors were encountered: