github.com/opencontainers/runc@v1.2.0-rc.1.0.20240520010911-492dc558cdd6/libcontainer/nsenter/nsenter_gccgo.go (about)

     1  //go:build linux && gccgo
     2  // +build linux,gccgo
     3  
     4  package nsenter
     5  
     6  /*
     7  #cgo CFLAGS: -Wall
     8  extern void nsexec();
     9  void __attribute__((constructor)) init(void) {
    10  	nsexec();
    11  }
    12  */
    13  import "C"
    14  
    15  // AlwaysFalse is here to stay false
    16  // (and be exported so the compiler doesn't optimize out its reference)
    17  var AlwaysFalse bool
    18  
    19  func init() {
    20  	if AlwaysFalse {
    21  		// by referencing this C init() in a noop test, it will ensure the compiler
    22  		// links in the C function.
    23  		// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65134
    24  		C.init()
    25  	}
    26  }