源码编译安装runc碰到的一个小坑

本文记录了在编译runc过程中遇到的依赖库错误及解决过程。主要问题是由于gcc版本过低导致的类型不匹配错误,通过升级gcc版本解决了问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

运行runc碰到的坑

go build -o runc .
#   github.com/seccomp/libseccomp-golang
Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/seccomp_internal.go:298: invalid operation: in.toNative() == *_Cvar_C_ARCH_BAD (mismatched types C.uint32_t and C.uint)
Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/seccomp_internal.go:328: invalid case *_Cvar_C_ARCH_X86 in switch on a (mismatched types C.uint and C.uint32_t)
Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/seccomp_internal.go:330: invalid case *_Cvar_C_ARCH_X86_64 in switch on a (mismatched types C.uint and C.uint32_t)
Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/seccomp_internal.go:332: invalid case *_Cvar_C_ARCH_X32 in switch on a (mismatched types C.uint and C.uint32_t)
Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/seccomp_internal.go:334: invalid case *_Cvar_C_ARCH_ARM in switch on a (mismatched types C.uint and C.uint32_t)
Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/seccomp_internal.go:336: invalid case *_Cvar_C_ARCH_NATIVE in switch on a (mismatched types C.uint and C.uint32_t)
Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/seccomp_internal.go:338: invalid case *_Cvar_C_ARCH_AARCH64 in switch on a (mismatched types C.uint and C.uint32_t)
Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/seccomp_internal.go:340: invalid case *_Cvar_C_ARCH_MIPS in switch on a (mismatched types C.uint and C.uint32_t)
Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/seccomp_internal.go:342: invalid case *_Cvar_C_ARCH_MIPS64 in switch on a (mismatched types C.uint and C.uint32_t)
Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/seccomp_internal.go:344: invalid case *_Cvar_C_ARCH_MIPS64N32 in switch on a (mismatched types C.uint and C.uint32_t)
Godeps/_workspace/src/github.com/seccomp/libseccomp-golang/seccomp_internal.go:344: too many errors
make: *** [all] Error 2

编译runc时,报错,很明显,是runc的一个依赖库github.com/seccomp/libseccomp-golang的错误。

于是单独编译安装该库,同样抛出 mismatched types C.uint32_t and C.uint 这个错误。

查看源码 seccomp_internal.go:298 可以发现in.toNative()返回的是C.uint32_t类型的值

const uint32_t C_ARCH_BAD = ARCH_BAD;

从上面可以看出 C.C_ARCH_BAD 反射过来也应该是uint32_t 类型的值。不应该报错才对。
但是实践发现,在我的机器上C.C_ARCH_BAD被反射成uint类型的。
于是找到 golang/go 并提了个issue golang/go#12599 对方答复,是我的gcc版本太低了 -_-!

于是只好把gcc从4.6.3升级到了4.8.1,没问题了

runc上的原始的issue链接:
https://github.com/opencontainers/runc/issues/256

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值