You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`--embed` can be used to embed the contents of a directory into the Caddy executable. `--embed` can be passed multiple times with separate source directories. The source directory can be prefixed with a custom alias and a colon `:` to write the embedded files into an aliased subdirectory, which is useful when combined with the `root` directive and sub-directive.
82
83
84
+
-`--pgo` can be used to specify a file containing a profile to use for profile guided optimization. If a file named `default.pgo` is present in the current directory, it will automatically be used. This feature is new to xcaddy and is considered experimental.
Copy file name to clipboardExpand all lines: cmd/commands.go
+20-1Lines changed: 20 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,7 @@ func init() {
19
19
buildCommand.Flags().String("output", "", "change the output file name")
20
20
buildCommand.Flags().StringArray("replace", []string{}, "like --with but for Go modules")
21
21
buildCommand.Flags().StringArray("embed", []string{}, "embeds directories into the built Caddy executable to use with the `embedded` file-system")
22
+
buildCommand.Flags().String("pgo", "", "file containing profile for PGO (experimental)")
22
23
}
23
24
24
25
varversionCommand=&cobra.Command{
@@ -35,7 +36,8 @@ var buildCommand = &cobra.Command{
35
36
[--output <file>]
36
37
[--with <module[@version][=replacement]>...]
37
38
[--replace <module[@version]=replacement>...]
38
-
[--embed <[alias]:path/to/dir>...]`,
39
+
[--embed <[alias]:path/to/dir>...]
40
+
[--pgo <file>] # EXPERIMENTAL`,
39
41
Long: `
40
42
<caddy_version> is the core Caddy version to build; defaults to CADDY_VERSION env variable or latest.
41
43
This can be the keyword latest, which will use the latest stable tag, or any git ref such as:
@@ -52,6 +54,8 @@ Flags:
52
54
--replace is like --with, but does not add a blank import to the code; it only writes a replace directive to go.mod, which is useful when developing on Caddy's dependencies (ones that are not Caddy modules). Try this if you got an error when using --with, like cannot find module providing package.
53
55
54
56
--embed can be used to embed the contents of a directory into the Caddy executable. --embed can be passed multiple times with separate source directories. The source directory can be prefixed with a custom alias and a colon : to write the embedded files into an aliased subdirectory, which is useful when combined with the root directive and sub-directive.
57
+
58
+
--pgo is used to specify a specify a file containing a profile for profile-guided optimization (experimental)
55
59
`,
56
60
Short: "Compile custom caddy binaries",
57
61
Args: cobra.MaximumNArgs(1),
@@ -60,6 +64,7 @@ Flags:
60
64
varplugins []xcaddy.Dependency
61
65
varreplacements []xcaddy.Replace
62
66
varembedDir []string
67
+
varpgostring
63
68
varargCaddyVersionstring
64
69
iflen(args) >0 {
65
70
argCaddyVersion=args[0]
@@ -103,6 +108,19 @@ Flags:
103
108
iferr!=nil {
104
109
returnfmt.Errorf("unable to parse --embed arguments: %s", err.Error())
105
110
}
111
+
112
+
// Experimental: If no --pgo flag is specified and a default.pgo file is found, use that for PGO
113
+
pgo, err=cmd.Flags().GetString("pgo")
114
+
iferr!=nil {
115
+
returnfmt.Errorf("unable to parse --pgo arguments: %s", err.Error())
116
+
}
117
+
ifpgo=="" {
118
+
_, err=os.Stat("default.pgo")
119
+
iferr==nil {
120
+
pgo="default.pgo"
121
+
}
122
+
}
123
+
106
124
// prefer caddy version from command line argument over env var
107
125
ifargCaddyVersion!="" {
108
126
caddyVersion=argCaddyVersion
@@ -127,6 +145,7 @@ Flags:
127
145
Debug: buildDebugOutput,
128
146
BuildFlags: buildFlags,
129
147
ModFlags: modFlags,
148
+
PgoProfile: pgo,
130
149
}
131
150
for_, md:=rangeembedDir {
132
151
ifbefore, after, found:=strings.Cut(md, ":"); found {
0 commit comments