-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/go: trimpath does not clean some CGO C filepaths #67011
Comments
I was not able to reproduce doing |
Hi, Running this docker file should show some path embeddings in the .rodata. FROM ubuntu:bionic
RUN apt-get update && apt-get install gcc-multilib git ca-certificates wget -yq --no-install-recommends
RUN git clone --branch master https://github.com/ethereum/go-ethereum.git && cd go-ethereum && git fetch
RUN wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz && \
rm -rf /usr/local/go && \
tar -C /usr/local -xzf go1.21.6.linux-amd64.tar.gz && \
export PATH=$PATH:/usr/local/go/bin
RUN cd go-ethereum && git fetch && git checkout 0d4c38865e9cda492e71221c4c429d9b1bec8ac5 && \
cd cmd/geth && CGO_ENABLED=1 /usr/local/go/bin/go build -trimpath .
RUN mv /go-ethereum/cmd/geth/geth /geth && readelf -p .rodata geth | grep /root/go/pkg >> full-paths.txt /# cat full-paths.txt
[9e5270] /root/go/pkg/mod/github.com/karalabe/hid@v1.0.1-0.20240306101548-573246063e52/libusb/libusb/libusbi.h
[9e52d8] /root/go/pkg/mod/github.com/karalabe/hid@v1.0.1-0.20240306101548-573246063e52/libusb/libusb/os/events_posix.c
[9e5348] /root/go/pkg/mod/github.com/karalabe/hid@v1.0.1-0.20240306101548-573246063e52/libusb/libusb/os/linux_netlink.c
[9e53b8] /root/go/pkg/mod/github.com/karalabe/hid@v1.0.1-0.20240306101548-573246063e52/libusb/libusb/os/linux_usbfs.c
[9e5428] /root/go/pkg/mod/github.com/karalabe/hid@v1.0.1-0.20240306101548-573246063e52/libusb/libusb/core.c
[9e54c0] /root/go/pkg/mod/github.com/karalabe/hid@v1.0.1-0.20240306101548-573246063e52/libusb/libusb/hotplug.c
[9e5528] /root/go/pkg/mod/github.com/karalabe/hid@v1.0.1-0.20240306101548-573246063e52/libusb/libusb/io.c |
It is indeed broken, but not natively on arch (even with -FROM ubuntu:bionic
+FROM ubuntu
RUN apt-get update && apt-get install gcc-multilib git ca-certificates wget -yq --no-install-recommends
RUN git clone --branch master https://github.com/ethereum/go-ethereum.git && cd go-ethereum && git fetch
-RUN wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz && \
+RUN wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz && \
rm -rf /usr/local/go && \
- tar -C /usr/local -xzf go1.21.6.linux-amd64.tar.gz && \
+ tar -C /usr/local -xzf go1.22.2.linux-amd64.tar.gz && \
export PATH=$PATH:/usr/local/go/bin
RUN cd go-ethereum && git fetch && git checkout 0d4c38865e9cda492e71221c4c429d9b1bec8ac5 && \
cd cmd/geth && CGO_ENABLED=1 /usr/local/go/bin/go build -trimpath .
RUN mv /go-ethereum/cmd/geth/geth /geth && readelf -p .rodata geth | grep /root/go/pkg >> full-paths.txt
|
cc |
Btw thx for the effort into reproducing this, it's tricky given it depends on other factors on the system than go and the source you are building but you nailed it with the docker file. 👍 🙂 |
I suppose the answer is to use a recent version of gcc. |
Go version
go version go1.21.6 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Compiled a go package containing C code dependencies using
-trimpath
flag.go version -m geth
What did you see happen?
Some C packages with full paths embedded in binaries.
What did you expect to see?
Relative, trimmed, paths for all C libraries.
The text was updated successfully, but these errors were encountered: