feature, ipn/ipnlocal: add, use feature.CanSystemdStatus for more DCE
When systemd notification support was omitted from the build, or on non-Linux systems, we were unnecessarily emitting code and generating garbage stringifying addresses upon transition to the Running state. Updates #12614 Change-Id: If713f47351c7922bb70e9da85bf92725b25954b9 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
e059382174
commit
e0e8731130
+8
-1
@@ -23,10 +23,17 @@ var HookSystemdStatus Hook[func(format string, args ...any)]
|
||||
// It does nothing on non-Linux systems or if the binary was built without
|
||||
// the sdnotify feature.
|
||||
func SystemdStatus(format string, args ...any) {
|
||||
if runtime.GOOS != "linux" || !buildfeatures.HasSDNotify {
|
||||
if !CanSystemdStatus { // mid-stack inlining DCE
|
||||
return
|
||||
}
|
||||
if f, ok := HookSystemdStatus.GetOk(); ok {
|
||||
f(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// CanSystemdStatus reports whether the current build has systemd notifications
|
||||
// linked in.
|
||||
//
|
||||
// It's effectively the same as HookSystemdStatus.IsSet(), but a constant for
|
||||
// dead code elimination reasons.
|
||||
const CanSystemdStatus = runtime.GOOS == "linux" && buildfeatures.HasSDNotify
|
||||
|
||||
Reference in New Issue
Block a user