Russ - go/make now builds packages with go, cgo, and assembly files. There's still some ...
13 years, 10 months ago
(2011-05-24 07:41:04 UTC)
#3
Russ - go/make now builds packages with go, cgo, and assembly files.
There's still some hard-coded stuff in there that should be derived from the
environment - your guidance on the general approach would be good at this point.
Particularly with the cgo stuff.
On Thu, May 26, 2011 at 00:22, <rsc@golang.org> wrote: > http://codereview.appspot.com/4433047/diff/20001/src/pkg/go/make/build.go#newcode25 > src/pkg/go/make/build.go:25: var arch ...
13 years, 10 months ago
(2011-05-26 11:29:48 UTC)
#7
On Thu, May 26, 2011 at 00:22, <rsc@golang.org> wrote:
>
http://codereview.appspot.com/4433047/diff/20001/src/pkg/go/make/build.go#new...
> src/pkg/go/make/build.go:25: var arch string
> Please make this a separate
>
> // ArchChar returns the architecture character for the given goarch.
> // For example, ArchChar("amd64") returns "6".
> func ArchChar(goarch string) (string, os.Error) {
> }
Why not make this a map lookup instead?
--Benny.
>> syslist.go: ../../../Make.inc Makefile > > Done, but why? Because the rule has no other ...
13 years, 10 months ago
(2011-05-26 13:42:38 UTC)
#8
>> syslist.go: ../../../Make.inc Makefile
>
> Done, but why?
Because the rule has no other dependencies.
syslist.go is out of date if the Makefile changes
(because the rule might have) or if Make.inc
changes (because the list of GOARCH or GOOS
might have).
FYI http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go File src/pkg/go/make/build.go (right): http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go#newcode54 src/pkg/go/make/build.go:54: cmds = append(cmds, c) Is this not clearer ...
13 years, 10 months ago
(2011-05-26 16:28:46 UTC)
#9
looking good http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go File src/pkg/go/make/build.go (right): http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go#newcode52 src/pkg/go/make/build.go:52: var cmds []Cmd should be []*Cmd i ...
13 years, 10 months ago
(2011-05-26 16:39:22 UTC)
#10
looking good
http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go
File src/pkg/go/make/build.go (right):
http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:52: var cmds []Cmd
should be []*Cmd
i bet callers will want to have maps keyed by command
http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:64:
I suggest having
type build struct {
cmds []*Cmd
obj string
goarch string
... whatever other context you need
}
func (b *build) mkdir(path string) {
b.cmds = append(b.cmds, &Cmd{Args: []string{"mkdir", "-p", obj}})
}
func (b *build) gc(files []string) {
b.cmds = append(b.cmds, &Cmd{
... whatever
})
}
and so on
then here init the builder and
b.mkdir(obj)
if len(d.CgoFiles) > 0 {
outGo, outObj := b.cgo(d.Cgofiles)
gofiles = append(gofiles, outGo...)
ofiles = append(ofiles, outObj...)
}
if len(gofiles) > 0 {
ofiles = append(ofiles, b.gc(gofiles))
}
if len(d.SFiles) > 0 {
ofiles = append(ofiles, b.as(d.SFiles)...)
}
...
right now the logic and the command details
are too intertwined.
http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:206: func (c Cmd) String() string {
c *Cmd please
http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go File src/pkg/go/make/build.go (right): http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go#newcode52 src/pkg/go/make/build.go:52: var cmds []Cmd On 2011/05/26 16:39:22, rsc wrote: > ...
13 years, 10 months ago
(2011-05-27 06:04:04 UTC)
#11
http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go
File src/pkg/go/make/build.go (right):
http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:52: var cmds []Cmd
On 2011/05/26 16:39:22, rsc wrote:
> should be []*Cmd
> i bet callers will want to have maps keyed by command
Done.
http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:54: cmds = append(cmds, c)
On 2011/05/26 16:28:46, kevlar wrote:
> Is this not clearer to inline? Even as is, the name might make more sense as
> "enq" or "qcmd" or "addCmd" or something that indicates it's not actually
> running the command. You might also just have this append onto a named return
> variable, since there are so few other return cases.
I renamed it to "add". Closures are useful. Let's use them.
http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:64:
On 2011/05/26 16:39:22, rsc wrote:
> I suggest having
>
> type build struct {
> cmds []*Cmd
> obj string
> goarch string
> ... whatever other context you need
> }
>
> func (b *build) mkdir(path string) {
> b.cmds = append(b.cmds, &Cmd{Args: []string{"mkdir", "-p", obj}})
> }
>
> func (b *build) gc(files []string) {
> b.cmds = append(b.cmds, &Cmd{
> ... whatever
> })
> }
>
> and so on
>
> then here init the builder and
>
> b.mkdir(obj)
>
> if len(d.CgoFiles) > 0 {
> outGo, outObj := b.cgo(d.Cgofiles)
> gofiles = append(gofiles, outGo...)
> ofiles = append(ofiles, outObj...)
> }
>
> if len(gofiles) > 0 {
> ofiles = append(ofiles, b.gc(gofiles))
> }
>
> if len(d.SFiles) > 0 {
> ofiles = append(ofiles, b.as(d.SFiles)...)
> }
>
> ...
>
> right now the logic and the command details
> are too intertwined.
>
Done. The cgo function is still a bit hairy, but not too bad.
http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:80: cgoCfiles[i+2] = obj + fn[:len(fn)-2] + "cgo2.c"
On 2011/05/26 16:28:46, kevlar wrote:
> I'm always a little hesitant to assign to indices in a slice over which I am
not
> ranging...
You shouldn't be. I've given the slice exactly the right length, and now I'm
filling it in. If there's an off-by-one error here it should be immediately
obvious. This is good style.
> append feels safer, and setting the capacity up front negates almost
> all of the performance hit.
It might feel safer, but it's not.
http://codereview.appspot.com/4433047/diff/27002/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:206: func (c Cmd) String() string {
On 2011/05/26 16:39:22, rsc wrote:
> c *Cmd please
Done.
http://codereview.appspot.com/4433047/diff/36001/src/pkg/go/make/build.go File src/pkg/go/make/build.go (right): http://codereview.appspot.com/4433047/diff/36001/src/pkg/go/make/build.go#newcode83 src/pkg/go/make/build.go:83: // builds will be relative to dir, so our ...
13 years, 10 months ago
(2011-05-27 15:09:31 UTC)
#12
http://codereview.appspot.com/4433047/diff/36001/src/pkg/go/make/build.go File src/pkg/go/make/build.go (right): http://codereview.appspot.com/4433047/diff/36001/src/pkg/go/make/build.go#newcode83 src/pkg/go/make/build.go:83: // builds will be relative to dir, so our ...
13 years, 10 months ago
(2011-05-30 00:30:09 UTC)
#13
http://codereview.appspot.com/4433047/diff/36001/src/pkg/go/make/build.go
File src/pkg/go/make/build.go (right):
http://codereview.appspot.com/4433047/diff/36001/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:83: // builds will be relative to dir, so our target
should be absolute
On 2011/05/27 15:09:31, rsc wrote:
> I don't really understand this. I know what you mean but
> not why the caller would pass in a current-directory-relative
> target that would be wrong.
It's that the build commands are expected to be run from the package directory.
Perhaps Build should assume the target is relative to the package directory.
http://codereview.appspot.com/4433047/diff/36001/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:97: } else {
On 2011/05/27 15:09:31, rsc wrote:
> no else after return
The 'a' variable is scoped to the if block.
http://codereview.appspot.com/4433047/diff/36001/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:135: b.link(targ, ofiles...)
On 2011/05/27 15:09:31, rsc wrote:
> b.ld
Done.
http://codereview.appspot.com/4433047/diff/36001/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:137: b.pack(targ, ofiles...)
On 2011/05/27 15:09:31, rsc wrote:
> b.gopack
Done.
http://codereview.appspot.com/4433047/diff/36001/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:196: args := []string{cc, "-FVw", "-I" + inc, "-o",
ofile}
On 2011/05/27 15:09:31, rsc wrote:
> in general should use "-I", arg not "-I" + arg,
> for any flag. the former works right when arg == "".
> the latter turns into a bug.
Done.
http://codereview.appspot.com/4433047/diff/36001/src/pkg/go/make/build.go#new...
src/pkg/go/make/build.go:233: gofiles := make([]string, len(cgofiles)+1)
On 2011/05/27 15:09:31, rsc wrote:
> This is weird; it's the only place in the whole program
> where you work so hard on the indices and sizes.
> It's premature optimization. Running cgo
> is a billion times more expensive than what this code
> saves by being so complex to size the arrays.
>
> You're writing C code. Let Go do the work.
>
> gofiles := []string{b.obj + "_cgo_gotypes.go"}
> cfiles := []string{b.obj + "_cgo_main.c", "_cgo_export.c"}
> for _, f := range cgofiles {
> f = f[:len(f)-2]
> gofiles = append(gofiles, b.obj + f + "cgo1.go")
> cfiles = append(cfiles, b.obj + f + "cgo2.c")
> }
>
> Same for output below.
Done.
PTAL I've added the GOPATH parsing stuff from goinstall to a new file path.go, and ...
13 years, 10 months ago
(2011-06-02 10:51:35 UTC)
#16
PTAL
I've added the GOPATH parsing stuff from goinstall to a new file path.go, and
tweaked the API a bit as I started adding this to goinstall in another CL:
http://codereview.appspot.com/4515180
*** Submitted as http://code.google.com/p/go/source/detail?r=0f1980acc591 *** go/build: new package for building go programs R=rsc CC=golang-dev http://codereview.appspot.com/4433047 ...
13 years, 9 months ago
(2011-06-04 02:45:17 UTC)
#19
Issue 4433047: code review 4433047: go/build: new package for building go programs
(Closed)
Created 13 years, 11 months ago by adg
Modified 13 years, 9 months ago
Reviewers:
Base URL:
Comments: 76