Skip to content

dockerfile: use lld linker for containerd build#5548

Merged
crazy-max merged 2 commits into
moby:masterfrom
crazy-max:containerd-lld
Nov 25, 2024
Merged

dockerfile: use lld linker for containerd build#5548
crazy-max merged 2 commits into
moby:masterfrom
crazy-max:containerd-lld

Conversation

@crazy-max
Copy link
Copy Markdown
Member

@crazy-max crazy-max commented Nov 23, 2024

closes #5546

@crazy-max crazy-max marked this pull request as ready for review November 23, 2024 10:35
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max merged commit 51fbdf3 into moby:master Nov 25, 2024
@crazy-max crazy-max deleted the containerd-lld branch November 25, 2024 09:40
@thaJeztah
Copy link
Copy Markdown
Member

@crazy-max is this something that should also be applied to our containerd-packaging repo instead of the workaround we currently have (to install binutils-gold)?

@crazy-max
Copy link
Copy Markdown
Member Author

@crazy-max is this something that should also be applied to our containerd-packaging repo instead of the workaround we currently have (to install binutils-gold)?

Either works but with cross comp, enforcing the linker is needed.

@tonistiigi
Copy link
Copy Markdown
Member

This still needs some investigation. It's a combination of Go hardcoding linker to gold if arm64 and dynamic linux binary target https://github.com/golang/go/blob/go1.23.3/src/cmd/link/internal/ld/lib.go#L1661-L1673 . -buildmode=pie in https://github.com/containerd/containerd/blob/v2.0.0/Makefile.linux#L25 is one thing that triggers dynamic binary in here but not fully clear to me if only this or what the condition is. Hardcoding gold in go seems very bad to me as gold is not a (multi-)cross-compiling linker, and likely would not work on non-native GOOS. In this case this hardcoding completely messes up the config that is provided by xx leaving situation where cross-compiling C compiler works flawlessly, but if the same compiler is used for Cgo then it fails. If this won't be fixed (removed) in Go we likely need some override in xx to override the config again (eg. with hardcoding CGO_LDFLAGS). I still would like some clear examples of what condition triggers this and what is the containerd difference. Just removing the -buildmode=pie didn't seem to solve it on its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants