From 699429e60f23ab0fa3bdd97b6326316be08791ad Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Sat, 21 Feb 2015 09:05:34 -0500 Subject: [PATCH] nsenter: noop reference to C constructor https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65134 Workaround suggested by iant Signed-off-by: Vincent Batts --- nsenter/nsenter.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nsenter/nsenter.go b/nsenter/nsenter.go index 880dca83..1c09c77e 100644 --- a/nsenter/nsenter.go +++ b/nsenter/nsenter.go @@ -10,3 +10,16 @@ void __attribute__((constructor)) init() { } */ import "C" + +// AlwaysFalse is here to stay false +// (and be exported so the compiler doesn't optimize out its reference) +var AlwaysFalse bool + +func init() { + if AlwaysFalse { + // by referencing this C init() in a noop test, it will ensure the compiler + // links in the C function. + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65134 + C.init() + } +}