Skip to content

Commit e9944d0

Browse files
committed
Disable systemd in static build
This fix tries to address the warnings caused by static build with go 1.9. As systemd needs dlopen/dlclose, the following warnings will be generated for static build in go 1.9: ``` root@f4b077232050:/go/src/github.com/opencontainers/runc# make static CGO_ENABLED=1 go build -tags "seccomp cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit="1c81e2a794c6e26a4c650142ae8893c47f619764" -X main.version=1.0.0-rc4+dev " -o runc . /tmp/go-link-113476657/000007.o: In function `_cgo_a5acef59ed3f_Cfunc_dlopen': /tmp/go-build/github.com/opencontainers/runc/vendor/github.com/coreos/pkg/dlopen/_obj/cgo-gcc-prolog:76: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking ``` This fix disables systemd when `static_build` flag is on (apply_nosystemd.go is used instead). This fix also fixes a small bug in `apply_nosystemd.go` for return value. Signed-off-by: Yong Tang <[email protected]>
1 parent d5b43c3 commit e9944d0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

libcontainer/cgroups/systemd/apply_nosystemd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build !linux
1+
// +build !linux static_build
22

33
package systemd
44

@@ -43,7 +43,7 @@ func (m *Manager) GetStats() (*cgroups.Stats, error) {
4343
}
4444

4545
func (m *Manager) Set(container *configs.Config) error {
46-
return nil, fmt.Errorf("Systemd not supported")
46+
return fmt.Errorf("Systemd not supported")
4747
}
4848

4949
func (m *Manager) Freeze(state configs.FreezerState) error {

libcontainer/cgroups/systemd/apply_systemd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build linux
1+
// +build linux,!static_build
22

33
package systemd
44

0 commit comments

Comments
 (0)