]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: create -objdir if not exist
authorMichael Podtserkovskii <michaelpo@meta.com>
Fri, 5 Apr 2024 12:58:35 +0000 (13:58 +0100)
committerGopher Robot <gobot@golang.org>
Mon, 15 Apr 2024 22:43:52 +0000 (22:43 +0000)
Currently the directory is created only if -objdir is omited.
Creating the directory here is useful to avoid doing this in each build system.
And also this is consistent with similar flags of other tools like `-o`.

Change-Id: Ic39d6eb3e003bc4884089f80f790e30df4a54b01
Reviewed-on: https://go-review.googlesource.com/c/go/+/576815
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/cmd/cgo/main.go

index fce2671c2c123b3b87887c4cd6552addd4b36509..a9095dee3d7ae761b793cef6319f7e345ad4c972 100644 (file)
@@ -385,11 +385,11 @@ func main() {
        cPrefix = fmt.Sprintf("_%x", h.Sum(nil)[0:6])
 
        if *objDir == "" {
-               // make sure that _obj directory exists, so that we can write
-               // all the output files there.
-               os.Mkdir("_obj", 0777)
                *objDir = "_obj"
        }
+       // make sure that `objDir` directory exists, so that we can write
+       // all the output files there.
+       os.MkdirAll(*objDir, 0o700)
        *objDir += string(filepath.Separator)
 
        for i, input := range goFiles {