New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go build executes unnecessary mkdir #6583

Closed
davecheney opened this Issue Oct 14, 2013 · 6 comments

Comments

Projects
None yet
4 participants
@davecheney
Copy link
Contributor

davecheney commented Oct 14, 2013

What steps will reproduce the problem?

% go build -x
WORK=/tmp/go-build249279931
mkdir -p $WORK/crypto/hmac/_obj/
mkdir -p $WORK/crypto/
cd /home/dfc/go/src/pkg/crypto/hmac
/home/dfc/go/pkg/tool/linux_arm/5g -o $WORK/crypto/hmac/_obj/_go_.5 -p crypto/hmac
-complete -D _/home/dfc/go/src/pkg/crypto/hmac -I $WORK ./hmac.go
/home/dfc/go/pkg/tool/linux_arm/pack grcP $WORK $WORK/crypto/hmac.a
$WORK/crypto/hmac/_obj/_go_.5

What is the expected output? What do you see instead?

mkdir -p $WORK/crypto/hmac/_obj/

will create $WORK/crypto/

so

mkdir -p $WORK/crypto/

is unnecessary.

Please use labels and text to provide additional information.
@robpike

This comment has been minimized.

Copy link
Contributor

robpike commented Oct 14, 2013

Comment 1:

Seems to happen for any nested package such as crypto/hmac or encoding/binary. Curious:
if you go one level deeper, say encoding/binary/foo, it mkdirs only two, not three
mkdir -p $WORK/encoding/binary/foo/_obj/
mkdir -p $WORK/encoding/binary/
A quick scan of the source doesn't make the reason obvious. It's also very unimportant.

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@gopherbot

This comment has been minimized.

Copy link

gopherbot commented Oct 15, 2013

Comment 2 by frederic.husson@baleinoid.fr:

In build.go you have a makedir for  the objdir and one for the target and you have in
modeBuild if not a.link : a.target = a.objpkg
    // Make build directory.
    obj := a.objdir
    if err := b.mkdir(obj); err != nil {
        return err
    }
    // make target directory
    dir, _ := filepath.Split(a.target)
    if dir != "" {
        if err := b.mkdir(dir); err != nil {
            return err
        }
    }
@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Nov 27, 2013

Comment 3:

Labels changed: added go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Dec 4, 2013

Comment 4:

Labels changed: added release-none, removed go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Dec 4, 2013

Comment 5:

Labels changed: added repo-main.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015

@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Oct 25, 2017

This doesn't matter; fixing it would make the code more fragile.

@rsc rsc closed this Oct 25, 2017

@golang golang locked and limited conversation to collaborators Oct 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.