1. 04 Jun, 2015 7 commits
    • Russ Cox's avatar
      cmd/go: clean up after 'go build' during 'go install' · 227fb116
      Russ Cox authored
      If 'go install' (with no arguments, meaning the current directory)
      succeeds, remove the executable written by 'go build', if present.
      This avoids leaving a stale binary behind during a sequence like:
      
      	go build
      	<test, mostly works, make small change>
      	go install
      
      Before this CL, the current directory still has the stale binary
      from 'go build'. If $PATH contains dot, running the name of
      the program will find this stale binary instead of the new,
      installed one.
      
      Remove the 'go build' target during 'go install', both to clean
      up the directory and to avoid accidentally running the stale binary.
      
      Another way to view this CL is that it makes the go command
      behave as if 'go install' is implemented by 'go build' followed by
      moving the resulting binary to the install location.
      
      See #9645 for discussion and objections.
      
      Fixes #9645.
      
      Change-Id: Ide109572f96bbb5a35be45dda17738317462a7d4
      Reviewed-on: https://go-review.googlesource.com/10682Reviewed-by: default avatarRob Pike <r@golang.org>
      227fb116
    • Russ Cox's avatar
      cmd/go: always rebuild GOPATH code that looks out of date · 119daba9
      Russ Cox authored
      We used to put a rebuilding barrier between GOPATHs, so that if
      you had GOPATH=dir1:dir2 and you had "p" in dir1/src/p
      and "q" in dir2/src/q, with "p" importing "q", then when you
      ran 'go install p', it would see that it was working in dir1
      and (since nothing from dir2 was explicitly mentioned)
      would assume that everything in dir2 is up-to-date, provided
      it is built at all.
      
      This has the confusing behavior that if "q" hasn't been built ever,
      then if you update sources in q and run 'go install p', the right
      thing happens (q is rebuilt and then p), but after that, if you update
      sources in q and run 'go install p', nothing happens: the installed
      q is assumed up-to-date.
      
      People using code conventions with multiple GOPATH entries
      (for example, with commands in one place and libraries in another,
      or vendoring conventions that try to avoid rewriting import paths)
      run into this without realizing it and end up with incorrect build
      results.
      
      The original motivation here was to avoid rebuild standard packages
      since a system-installed GOROOT might be unwritable.
      The change introduced to separate GOROOT also separated
      individual GOPATH entries. Later changes added a different, more
      aggressive earlier shortcut for GOROOT in release settings,
      so the code here is now only applying to (and confusing)
      multiple GOPATH entries. Remove it.
      
      Fixes #10509.
      
      Change-Id: I687a3baa81eff4073b0d67f9acbc5a3ab192eda5
      Reviewed-on: https://go-review.googlesource.com/9155Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      119daba9
    • Russ Cox's avatar
      cmd/go: detect when package or binary is stale due to removed source file · 7b87631e
      Russ Cox authored
      The go command uses file modification times to decide when a
      package is out of date: if the .a file is older than a source file,
      the .a file needs to be rebuilt. This scheme breaks down when
      multiple source files compile into a single .a file: if one source file
      is removed but no other changes are made, there is no indication
      that the .a file is out of date.
      
      The fix is to store a value called a build ID in the package archive itself.
      The build ID is a hash of the names of all source files compiled into the package.
      A later go command can read the build ID out of the package archive
      and compare to the build ID derived from the list of source files it now
      sees in the directory. If the build IDs differ, the file list has changed,
      and the package must be rebuilt.
      
      There is a cost here: when scanning a package directory, in addition
      to reading the beginning of every source file for build tags and imports,
      the go command now also reads the beginning of the associated
      package archive, for the build ID. This is at most a doubling in the
      number of files read. On my 2012 MacBook Pro, the time for
      'go list std' increases from about 0.215 seconds to about 0.23 seconds.
      
      For executable binaries, the approach is the same except that the
      build ID information is stored in a trailer at the end of the executable file.
      It remains to be seen if anything objects to the trailer.
      I don't expect problems except maybe on Plan 9.
      
      Fixes #3895.
      
      Change-Id: I21b4ebf5890c1a39e4a013eabe1ddbb5f3510c04
      Reviewed-on: https://go-review.googlesource.com/9154Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      7b87631e
    • Russ Cox's avatar
      cmd/compile: merge Node.Opt and Node.Val behind access methods · 81d5810b
      Russ Cox authored
      $ sizeof -p cmd/compile/internal/gc Node
      Node 144
      $
      
      Change-Id: I688e3790964fe42f48c19f697ec38094a92fe1c1
      Reviewed-on: https://go-review.googlesource.com/10531Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      81d5810b
    • Russ Cox's avatar
      cmd/compile: cleanups for Node trimming sequence · a53710ff
      Russ Cox authored
      Suggested during code reviews of last 15 CLs (or so).
      
      Change-Id: If780f6eb47a7a31df133c64d5dcf0eaf04d8447b
      Reviewed-on: https://go-review.googlesource.com/10675Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
      a53710ff
    • Josh Bleecher Snyder's avatar
      cmd/link: make stkcheck more flexible · ca19e55f
      Josh Bleecher Snyder authored
      stkcheck is flow-insensitive: It processes calls in PC order.
      Since morestack was always the first call in a function,
      it was a safe, conservative approximation to simply adjust stack
      space as we went, recognizing morestack when it showed up.
      
      Subsequent CLS will rearrange the function prologue;
      morestack may no longer be the first call in a function.
      
      Introducing flow-sensitivity to stkcheck would allow this,
      and possibly allow a smaller stackguard.
      It is also a high risk change and possibly expensive.
      
      Instead, assume that all calls to morestack occur as
      part of the function prologue, no matter where they
      are located in the program text.
      
      Updates #10587.
      
      Change-Id: I4dcdd4256a980fc4bc433a68a10989ff57f7034f
      Reviewed-on: https://go-review.googlesource.com/10496
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      ca19e55f
    • Russ Cox's avatar
      cmd/internal/gc: accept map literals with omitted key type · 73d109c5
      Russ Cox authored
      Fixes #10209.
      
      Change-Id: I248434f9195c868befd1ed8a6000a9cac72d1df8
      Reviewed-on: https://go-review.googlesource.com/10263Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      73d109c5
  2. 03 Jun, 2015 33 commits