Skip to content
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

libc/int/userns: add build tag to C file #4616

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Feb 5, 2025

This fixes k3s cross-compilation on Windows, broken by commit 1912d59 ("*: actually support joining a userns with a new container").

[@kolyshkin: commit message]

Fixes: 1912d59


As far as I can see, this is first mentioned in k3s-io/k3s#9332 a year ago but was never reported to runc 😞

Indeed, Go recognizes //go:build in C files, and also matches GOOS and GOARCH in file names even for .c files.

Also, I don't know how to reproduce it here (GOOS=windows CGO_ENABLED=1 go build ./libcontainer/... gives too many errors).

This fixes k3s cross-compilation on Windows, broken by commit
1912d59 ("*: actually support joining a userns with a new
container").

[@kolyshkin: commit message]

Fixes: 1912d59
Signed-off-by: Brad Davidson <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin kolyshkin added the backport/1.2-todo A PR in main branch which needs to be backported to release-1.2 label Feb 5, 2025
@kolyshkin kolyshkin marked this pull request as ready for review February 6, 2025 00:03
@kolyshkin
Copy link
Contributor Author

@brandond PTAL. Sorry if you have reported the issue before but we missed it. Also, if you can suggest a way to test this, that'd be great.

@brandond
Copy link

brandond commented Feb 6, 2025

I think the underlying issue is that runc isn't normally used on windows. On windows you use runhcs instead. However, K3s links in some of the runc libcontainer library code on windows, so we do need build tags on stuff that only works on linux.

I did ping @cyphar internally a while back but I haven't followed up.

@kolyshkin kolyshkin requested review from rata and cyphar February 6, 2025 01:07
Copy link
Member

@rata rata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

It seems surprising only this is needed, for sure we don't have this in nsexec.c and friends. I guess this depends on the includes the project is using and just this is what they miss right now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.2-todo A PR in main branch which needs to be backported to release-1.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants