@@ -309,28 +309,27 @@ func getDelve(ctx context.Context, platform v1.Platform) (string, error) {
309309 cloneDir := filepath .Join (tmpInstallDir , "delve" )
310310 err = os .MkdirAll (cloneDir , 0755 )
311311 if err != nil {
312- return "" , fmt .Errorf ("making dir for delve clone: %v " , err )
312+ return "" , fmt .Errorf ("making dir for delve clone: %w " , err )
313313 }
314314 err = git .Clone (ctx , cloneDir , delveCloneURL )
315315 if err != nil {
316- return "" , fmt .Errorf ("cloning delve repo: %v " , err )
316+ return "" , fmt .Errorf ("cloning delve repo: %w " , err )
317317 }
318318 osArchDir := fmt .Sprintf ("%s_%s" , platform .OS , platform .Architecture )
319319 delveBinaryPath := filepath .Join (tmpInstallDir , "bin" , osArchDir , "dlv" )
320320
321321 // install delve to tmp directory
322322 args := []string {
323323 "build" ,
324- "-C" ,
325- cloneDir ,
326- "./cmd/dlv" ,
327324 "-o" ,
328325 delveBinaryPath ,
326+ "./cmd/dlv" ,
329327 }
330328
331329 gobin := getGoBinary ()
332330 cmd := exec .CommandContext (ctx , gobin , args ... )
333331 cmd .Env = env
332+ cmd .Dir = cloneDir
334333
335334 var output bytes.Buffer
336335 cmd .Stderr = & output
@@ -924,6 +923,10 @@ func (g *gobuild) configForImportPath(ip string) Config {
924923 return config
925924}
926925
926+ func (g gobuild ) useDebugging (platform v1.Platform ) bool {
927+ return g .debug && doesPlatformSupportDebugging (platform )
928+ }
929+
927930func (g * gobuild ) buildOne (ctx context.Context , refStr string , base v1.Image , platform * v1.Platform ) (oci.SignedImage , error ) {
928931 if err := g .semaphore .Acquire (ctx , 1 ); err != nil {
929932 return nil , err
@@ -965,7 +968,7 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl
965968 }
966969 }
967970 if g .debug && ! doesPlatformSupportDebugging (* platform ) {
968- return nil , fmt . Errorf ( " debugging is not supported for %s " , platform )
971+ log . Printf ( "image for platform %q will be built without debugging enabled because debugging is not supported for that platform " , * platform )
969972 }
970973
971974 if ! g .platformMatcher .matches (platform ) {
@@ -1078,7 +1081,7 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl
10781081 })
10791082
10801083 delvePath := "" // path for delve in image
1081- if g .debug {
1084+ if g .useDebugging ( * platform ) {
10821085 // get delve locally
10831086 delveBinary , err := getDelve (ctx , * platform )
10841087 if err != nil {
@@ -1144,7 +1147,7 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl
11441147 updatePath (cfg , `C:\ko-app` )
11451148 cfg .Config .Env = append (cfg .Config .Env , `KO_DATA_PATH=C:\var\run\ko` )
11461149 } else {
1147- if g .debug {
1150+ if g .useDebugging ( * platform ) {
11481151 cfg .Config .Entrypoint = append ([]string {delvePath }, delveArgs ... )
11491152 cfg .Config .Entrypoint = append (cfg .Config .Entrypoint , appPath )
11501153 }
0 commit comments