summaryrefslogtreecommitdiff
path: root/src/cmd/go/build.go
Commit message (Collapse)AuthorAgeFilesLines
* [dev.cc] cmd/go: adjust go, cgo builds & disable ccRuss Cox2014-11-111-32/+22
| | | | | | | | | | | | | | | | | | | [This CL is part of the removal of C code from package runtime. See golang.org/s/dev.cc for an overview.] Make gcToolchain.cc return an error (no C compiler!). Adjust expectations of cgo, now that cgo does not write any C files (no C compiler!). For packages with .s files, invoke Go compiler with -asmhdr go_asm.h so that assembly files can use it. This applies to all packages but is only needed today by package runtime. LGTM=r R=r CC=austin, golang-codereviews, iant, khr https://codereview.appspot.com/171470043
* cmd/go: disable warnings from cmd/cc when building for SWIGIan Lance Taylor2014-11-071-1/+9
| | | | | | | | | Fixes issue 9065. LGTM=rsc R=rsc, misch CC=golang-codereviews https://codereview.appspot.com/171270043
* cmd/go: pass $CGO_LDFLAGS to linker with the "gccgo" toolchain.Peter Collingbourne2014-10-251-0/+1
| | | | | | | | | LGTM=iant R=iant, minux CC=golang-codereviews, golang-dev https://codereview.appspot.com/157460043 Committer: Ian Lance Taylor <iant@golang.org>
* cmd/go: add '_go_' suffix to go files compiled by gccgo to avoid naming ↵Chris Manghane2014-10-151-1/+1
| | | | | | | | | | | conflicts Fixes issue 8828. LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/154410043
* cmd/go: make build -a skip standard packages in Go releasesRuss Cox2014-09-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Today, 'go build -a my/pkg' and 'go install -a my/pkg' recompile not just my/pkg and all its dependencies that you wrote but also the standard library packages. Recompiling the standard library is problematic on some systems because the installed copy is not writable. The -a behavior means that you can't use 'go install -a all' or 'go install -a my/...' to rebuild everything after a Go release - the rebuild stops early when it cannot overwrite the installed standard library. During development work, however, you do want install -a to rebuild everything, because anything might have changed. Resolve the conflict by making the behavior of -a depend on whether we are using a released copy of Go or a devel copy. In the release copies, -a no longer applies to the standard library. In the devel copies, it still does. This is the latest in a long line of refinements to the "do I build this or not" logic. It is surely not the last. Fixes issue 8290. LGTM=r R=golang-codereviews, r, tracey.brendan CC=adg, golang-codereviews, iant https://codereview.appspot.com/151730045
* cmd/go: handle paths like \x.go on windowsAlex Brainman2014-09-261-2/+7
| | | | | | | | | | | Fixes issue 8130. LGTM=rsc R=golang-codereviews, rsc CC=golang-codereviews https://codereview.appspot.com/143200043 Committer: Russ Cox <rsc@golang.org>
* cmd/go: display program name when reporting crashRuss Cox2014-09-261-0/+8
| | | | | | | | | | | Fix by atom (from CL 89190044), comment and test by me. Fixes issue 6823. LGTM=crawshaw R=golang-codereviews, crawshaw CC=0xe2.0x9a.0x9b, adg, golang-codereviews, iant, r https://codereview.appspot.com/148180043
* cmd/go: install dependencies for 'go build -i' on a commandRuss Cox2014-09-251-5/+6
| | | | | | | | | Fixes issue 8242. LGTM=r R=golang-codereviews, r CC=golang-codereviews, iant https://codereview.appspot.com/147150043
* cmd/go: fix bytes and net the right wayRuss Cox2014-09-241-1/+1
| | | | | | | | | | | | | | | | | | | Not sure why they used empty.s and all these other packages were special cased in cmd/go instead. Add them to the list. This avoids problems with net .s files being compiled with gcc in cgo mode and gcc not supporting // comments on ARM. Not a problem with bytes, but be consistent. The last change fixed the ARM build but broke the Windows build. Maybe *this* will make everyone happy. Sigh. TBR=iant CC=golang-codereviews https://codereview.appspot.com/144530046
* cmd/go: strip -fsanitize= flags when building cgo objectDmitriy Vyukov2014-09-251-0/+8
| | | | | | | | | Fixes issue 8788. LGTM=iant R=iant CC=golang-codereviews https://codereview.appspot.com/142470043
* cmd/go: use pkg-config include pathes in swig and don't double compile c++ ↵Ahmed Waheed Moanes2014-09-161-32/+61
| | | | | | | | | | | | | files. Fixes issue 8566. LGTM=iant R=iant CC=golang-codereviews https://codereview.appspot.com/126210045 Committer: Ian Lance Taylor <iant@golang.org>
* build: adjustments for move from src/pkg to srcRuss Cox2014-09-081-8/+7
| | | | | | | | | | | | | | | | | | | This CL adjusts code referring to src/pkg to refer to src. Immediately after submitting this CL, I will submit a change doing 'hg mv src/pkg/* src'. That change will be too large to review with Rietveld but will contain only the 'hg mv'. This CL will break the build. The followup 'hg mv' will fix it. For more about the move, see golang.org/s/go14nopkg. LGTM=r R=r CC=golang-codereviews https://codereview.appspot.com/134570043
* cmd/go: fix a couple of errors found by "go vet"Rob Pike2014-08-151-1/+1
| | | | | | | LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://codereview.appspot.com/127410043
* all: copy cmd/ld/textflag.h into pkg/GOOS_GOARCHRob Pike2014-08-121-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | The file is used by assembly code to define symbols like NOSPLIT. Having it hidden inside the cmd directory makes it hard to access outside the standard repository. Solution: As with a couple of other files used by cgo, copy the file into the pkg directory and add a -I argument to the assembler to access it. Thus one can write just #include "textflag.h" in .s files. The names in runtime are not updated because in the boot sequence the file has not been copied yet when runtime is built. All other .s files in the repository are updated. Changes to doc/asm.html, src/cmd/dist/build.c, and src/cmd/go/build.go are hand-made. The rest are just the renaming done by a global substitution. (Yay sam). LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/128050043
* cmd/go: don't pass --buildid=none on OpenBSDIan Lance Taylor2014-08-071-1/+1
| | | | | | | | According to the OpenBSD builder, it doesn't work. TBR=bradfitz CC=golang-codereviews https://codereview.appspot.com/126830043
* cmd/go: don't pass --buildid=none on FreeBSDIan Lance Taylor2014-08-071-1/+1
| | | | | | | | According to the FreeBSD builder, it doesn't work. TBR=bradfitz CC=golang-codereviews https://codereview.appspot.com/121400043
* cmd/go: pass --build-id=none when generating a cgo .oIan Lance Taylor2014-08-071-1/+17
| | | | | | | | | | | | | | | | | Some systems, like Ubuntu, pass --build-id when linking. The effect is to put a note in the output file. This is not useful when generating an object file with the -r option, as it eventually causes multiple build ID notes in the final executable, all but one of which are for tiny portions of the file and are therefore useless. Disable that by passing an explicit --build-id=none when linking with -r on systems that might do this. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://codereview.appspot.com/119460043
* cmd/go: use correct link flags if main package contains C++/ObjC filesPeter Collingbourne2014-08-011-3/+3
| | | | | | | | | LGTM=iant R=iant CC=golang-codereviews https://codereview.appspot.com/117470043 Committer: Ian Lance Taylor <iant@golang.org>
* cmd/go: introduce support for $GCCGO env varPeter Collingbourne2014-07-141-4/+12
| | | | | | | | | | | | This variable allows users to select the compiler when using the gccgo toolchain. LGTM=rsc R=rsc, iant, minux, aram CC=axwalk, golang-codereviews https://codereview.appspot.com/106700044 Committer: Russ Cox <rsc@golang.org>
* cmd/go: do not fail if libgcc does not existBenny Siegert2014-07-101-2/+2
| | | | | | | | | | | (This is a patch from the pkgsrc Go package.) LGTM=iant R=golang-codereviews, iant, joerg.sonnenberger, dave CC=golang-codereviews, joerg https://codereview.appspot.com/108340043 Committer: Ian Lance Taylor <iant@golang.org>
* cmd/go: use $CC to build _cgo_defun.cPeter Collingbourne2014-07-091-2/+1
| | | | | | | | | LGTM=dave, iant R=iant, dave CC=golang-codereviews https://codereview.appspot.com/112000043 Committer: Ian Lance Taylor <iant@golang.org>
* cmd/go: fix build -o panic when import path pattern matches 0 pkgsDmitri Shuralyov2014-07-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes issue 8165. After this change, the panic is replaced by a message: $ go build -o out ...doesntexist warning: "...doesntexist" matched no packages no packages to build The motivation to return 1 exit error code is to allow -o flag to be used to guarantee that the output binary is written to when exit status is 0. If someone uses an import path pattern to specify a single package and suddenly that matches no packages, it's better to return exit code 1 instead of silently doing nothing. This is consistent with the case when -o flag is given and multiple packages are matched. It's also somewhat consistent with the current behavior with the panic, except that gave return code 2. But it's similar in that it's also non-zero (indicating failure). I've changed the language to be similar to output of go test when an import path pattern matches no packages (it also has a return status of 1): $ go test ...doesntexist warning: "...doesntexist" matched no packages no packages to test LGTM=adg R=golang-codereviews, josharian, gobot, adg CC=golang-codereviews https://codereview.appspot.com/107140043 Committer: Andrew Gerrand <adg@golang.org>
* cmd/go, cmd/ld, runtime, os/user: TLS emulation for androidDavid Crawshaw2014-07-031-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on cl/69170045 by Elias Naur. There are currently several schemes for acquiring a TLS slot to save the g register. None of them appear to work for android. The closest are linux and darwin. Linux uses a linker TLS relocation. This is not supported by the android linker. Darwin uses a fixed offset, and calls pthread_key_create until it gets the slot it wants. As the runtime loads late in the android process lifecycle, after an arbitrary number of other libraries, we cannot rely on any particular slot being available. So we call pthread_key_create, take the first slot we are given, and put it in runtime.tlsg, which we turn into a regular variable in cmd/ld. Makes android/arm cgo binaries work. LGTM=minux R=elias.naur, minux, dave, josharian CC=golang-codereviews https://codereview.appspot.com/106380043
* runtime/race: support freebsdDmitriy Vyukov2014-06-201-3/+3
| | | | | | | | | All tests pass except one test in regexp package. LGTM=iant R=golang-codereviews, iant, dave CC=golang-codereviews https://codereview.appspot.com/107270043
* cmd/go: check for SWIG version that is too old to useIan Lance Taylor2014-05-211-1/+40
| | | | | | | | | Fixes issue 7983. LGTM=crawshaw R=golang-codereviews, crawshaw CC=golang-codereviews, rsc https://codereview.appspot.com/96540044
* cmd/go: link SWIG objects directly rather than using a shared libraryIan Lance Taylor2014-05-121-79/+26
| | | | | | | | | | | | | | This change requires using SWIG version 3.0 or later. Earlier versions of SWIG do not generate the pragmas required to use the external linker. Fixes issue 7155. Fixes issue 7156. LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/97120046
* cmd/go: better error for install of 'test-only' packageRuss Cox2014-05-121-12/+14
| | | | | | | | | Fixes issue 7915. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://codereview.appspot.com/96210044
* cmd/go: accept build flags in clean and listRuss Cox2014-05-091-2/+4
| | | | | | | | | | | | | | | | | | | | | list has been adding them one at a time haphazardly (race and tags were there and documented; compiler was there and undocumented). clean -i needs -compiler in order to clean the installed targets for alternate compilers. Fixes issue 7302. While we're here, tweak the language in the 'go get' docs about build flags. Fixes issue 7807. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://codereview.appspot.com/99130043
* cmd/go: add go build -iDavid Crawshaw2014-05-061-2/+11
| | | | | | | | | Fixes issue 7071. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://codereview.appspot.com/93770044
* cmd/go: test: clean up all temporary directoriesMichael Fraenkel2014-04-301-1/+2
| | | | | | | | | | | | go test may call builder.init() multiple times which will create a new work directory. The cleanup needs to hoist the current work directory. Fixes issue 7904. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://codereview.appspot.com/95900044 Committer: Ian Lance Taylor <iant@golang.org>
* build: remove tmp dir names from objects, support GOROOT_FINAL againRuss Cox2014-04-151-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we compile a generated file stored in a temporary directory - let's say /tmp/12345/work/x.c - then by default 6c stores the full path and then the pcln table in the final binary includes the full path. This makes repeated builds (using different temporary directories) produce different binaries, even if the inputs are the same. In the old 'go tool pack', the P flag specified a prefix to remove from all stored paths (if present), and cmd/go invoked 'go tool pack grcP $WORK' to remove references to the temporary work directory. We've changed the build to avoid pack as much as possible, under the theory that instead of making pack convert from .6 to .a, the tools should just write the .a directly and save a round of I/O. Instead of going back to invoking pack always, define a common flag -trimpath in the assemblers, C compilers, and Go compilers, implemented in liblink, and arrange for cmd/go to use the flag. Then the object files being written out have the shortened paths from the start. While we are here, reimplement pcln support for GOROOT_FINAL. A build in /tmp/go uses GOROOT=/tmp/go, but if GOROOT_FINAL=/usr/local/go is set, then a source file named /tmp/go/x.go is recorded instead as /usr/local/go/x.go. We use this so that we can prepare distributions to be installed in /usr/local/go without actually working in that directory. The conversion to liblink deleted all the old file name handling code, including the GOROOT_FINAL translation. Bring the GOROOT_FINAL translation back. Before this CL, using GOROOT_FINAL=/goroot make.bash: g% strings $(which go) | grep -c $TMPDIR 6 g% strings $(which go) | grep -c $GOROOT 793 g% After this CL: g% strings $(which go) | grep -c $TMPDIR 0 g% strings $(which go) | grep -c $GOROOT 0 g% (The references to $TMPDIR tend to be cgo-generated source files.) Adding the -trimpath flag to the assemblers required converting them to the new Go-semantics flag parser. The text in go1.3.html is copied and adjusted from go1.1.html, which is when we applied that conversion to the compilers and linkers. Fixes issue 6989. LGTM=iant R=r, iant CC=golang-codereviews https://codereview.appspot.com/88300045
* cmd/go: Check error from SWIG link step.Albert Strasheim2014-04-071-1/+3
| | | | | | | | | LGTM=iant R=iant CC=golang-codereviews https://codereview.appspot.com/85070043 Committer: Ian Lance Taylor <iant@golang.org>
* cmd/go: Use exported CgoLDFlags when compiler=gccgoErik Westrup2014-03-261-0/+1
| | | | | | | | | | | | | If you compile a program that has cgo LDFLAGS directives, those are exported to an environment variable to be used by subsequent compiler tool invocations. The linking phase when using the gccgo toolchain did not consider the envvar CGO_LDFLAGS's linking directives resulting in undefined references when using cgo+gccgo. Fixes issue 7573 LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://codereview.appspot.com/80780043 Committer: Ian Lance Taylor <iant@golang.org>
* cmd/go: ensure external test files are presented to the linker firstDave Cheney2014-03-261-1/+6
| | | | | | | | | | | | | | | Fixes issue 7627. CL 61970044 changed the order in which .a files are passed to gccgo's link phase. However by reversing the order it caused gccgo to complain if both internal (liba.a) and external (liba_test.a) versions of a package were presented as the former would not contain all the necessary symbols, and the latter would duplicate symbols already defined. This change ensures that all 'fake' targets remain at the top of the final link order which should be fine as a package compiled as an external test is a superset of its internal sibling. Looking at how gcToolchain links tests I think this change now accurately mirrors those actions which present $WORK/_test before $WORK in the link order. LGTM=iant R=rsc, iant CC=golang-codereviews, michael.hudson https://codereview.appspot.com/80300043
* cmd/go: let build -x output describe CGO_LDFLAGS env variableJan Ziak2014-03-181-1/+7
| | | | | | | | | Fixes issue 7249 LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://codereview.appspot.com/75820046
* cmd/go: fix invalid go pack command line in the output of go build -xJan Ziak2014-03-141-2/+2
| | | | | | | | | Fixes issue 7262 LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://codereview.appspot.com/76110043
* cmd/go: use correct libraries during gccgo linkMichael Hudson-Doyle2014-03-121-7/+16
| | | | | | | | | | | | | | Under some circumstances, gccgoToolchain's ld can pass the path of build outputs that have been deleted to the link command. Fixes issue 7303. LGTM=rsc R=golang-codereviews, dave, michael.hudson, rsc CC=golang-codereviews https://codereview.appspot.com/61970044 Committer: Russ Cox <rsc@golang.org>
* cmd/go: respect system CGO_CFLAGS and CGO_CXXFLAGSJan Ziak2014-03-121-24/+49
| | | | | | | | | Fixes issue 6882 LGTM=iant R=rsc, iant CC=golang-codereviews https://codereview.appspot.com/72080043
* cmd/go: add support for coverage in CgoFilesAlberto Garc?a Hierro2014-03-051-19/+30
| | | | | | | | | | | | Add CgoFiles to the covered files when building with cover support. LGTM=rsc R=golang-codereviews, gobot, r, rsc CC=golang-codereviews https://codereview.appspot.com/34680044 Committer: Russ Cox <rsc@golang.org>
* cmd/go: fix data race on buildLdflagsDmitriy Vyukov2014-03-041-0/+2
| | | | | | | | | Fixes issue 7438. LGTM=rsc R=golang-codereviews CC=bradfitz, golang-codereviews, iant, rsc https://codereview.appspot.com/70420044
* all: merge NaCl branch (part 1)Dave Cheney2014-02-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See golang.org/s/go13nacl for design overview. This CL is the mostly mechanical changes from rsc's Go 1.2 based NaCl branch, specifically 39cb35750369 to 500771b477cf from https://code.google.com/r/rsc-go13nacl. This CL does not include working NaCl support, there are probably two or three more large merges to come. CL 15750044 is not included as it involves more invasive changes to the linker which will need to be merged separately. The exact change lists included are 15050047: syscall: support for Native Client 15360044: syscall: unzip implementation for Native Client 15370044: syscall: Native Client SRPC implementation 15400047: cmd/dist, cmd/go, go/build, test: support for Native Client 15410048: runtime: support for Native Client 15410049: syscall: file descriptor table for Native Client 15410050: syscall: in-memory file system for Native Client 15440048: all: update +build lines for Native Client port 15540045: cmd/6g, cmd/8g, cmd/gc: support for Native Client 15570045: os: support for Native Client 15680044: crypto/..., hash/crc32, reflect, sync/atomic: support for amd64p32 15690044: net: support for Native Client 15690048: runtime: support for fake time like on Go Playground 15690051: build: disable various tests on Native Client LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/68150047 Committer: Russ Cox <rsc@golang.org>
* cmd/go: skip writing dwarf debug info for ephemeral binariesRuss Cox2014-02-191-0/+4
| | | | | | | | | | | | | | | | | | Update issue 6853 For an ephemeral binary - one created, run, and then deleted - there is no need to write dwarf debug information, since the binary will not be used with gdb. In this case, instruct the linker not to spend time and disk space generating the debug information by passing the -w flag to the linker. Omitting dwarf information reduces the size of most binaries by 25%. We may be more aggressive about this in the future. LGTM=bradfitz, r R=r, bradfitz CC=golang-codereviews https://codereview.appspot.com/65890043
* cmd/go: remove cross compiling restriction on cgoElias Naur2014-02-141-4/+0
| | | | | | | | | | | | | | A previous CL added support for cross compiling with cgo, but missed the GOOS check in cmd/go. Remove it. Update issue 4714 LGTM=iant R=iant CC=golang-codereviews https://codereview.appspot.com/57210046 Committer: Ian Lance Taylor <iant@golang.org>
* cmd/go: fix cgo error output rewriteShenghou Ma2014-02-131-2/+3
| | | | | | | | | | for example, we now rewrite *_Ctype_int to *C.int. Fixes issue 6781. LGTM=iant R=golang-codereviews, rsc, iant CC=golang-codereviews https://codereview.appspot.com/36860043
* cmd/go, go/build: support .m filesCarlos Castillo2014-02-131-5/+41
| | | | | | | | | | | | | | | | | | | go/build is changed to list the .m files in a package, and match them for build constraints, adding them to a new field: Package.MFiles. The go tool is changed to support building .m files and linking in the results during CGO and SWIG builds. This means packages that create a C interface to calls Objective-C code from go are now go-gettable without producing and distributing .syso files. This change is analogous to the one in Go 1.2 made to support C++ built code. This change doesn't support .mm files (Objective C++). Also added support for these MFiles to go list's -json mode. Fixes issue 6536. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://codereview.appspot.com/60590044 Committer: Ian Lance Taylor <iant@golang.org>
* cmd/go: do not create world-writable files.Shenghou Ma2014-02-061-6/+6
| | | | | | | | | Fixes issue 7240. LGTM=tommi.virtanen, bradfitz R=golang-codereviews, tommi.virtanen, bradfitz CC=golang-codereviews https://codereview.appspot.com/60480045
* cmd/go, cmd/cgo, make.bash: cross compiling with cgo enabledElias Naur2014-02-061-38/+45
| | | | | | | | | | | | | | | | | | | | Introduce two new environment variables, CC_FOR_TARGET and CXX_FOR_TARGET. CC_FOR_TARGET defaults to CC and is used when compiling for GOARCH, while CC remains for compiling for GOHOSTARCH. CXX_FOR_TARGET defaults to CXX and is used when compiling C++ code for GOARCH. CGO_ENABLED defaults to disabled when cross compiling and has to be explicitly enabled. Update issue 4714 LGTM=minux.ma, iant R=golang-codereviews, minux.ma, iant, rsc, dominik.honnef CC=golang-codereviews https://codereview.appspot.com/57100043 Committer: Ian Lance Taylor <iant@golang.org>
* cmd/go: When linking with gccgo pass .a files in the order they are discoveredMichael Hudson-Doyle2014-01-281-11/+9
| | | | | | | | | | | | | | | | | | | | Under some circumstances linking a test binary with gccgo can fail, because the installed version of the library ends up before the version built for the test on the linker command line. This admittedly slightly hackish fix fixes this by putting the library archives on the linker command line in the order that a pre-order depth first traversal of the dependencies gives them, which has the side effect of always putting the version of the library built for the test first. Fixes issue 6768 LGTM=rsc R=golang-codereviews, minux.ma, gobot, rsc, dave CC=golang-codereviews https://codereview.appspot.com/28050043 Committer: Dave Cheney <dave@cheney.net>
* cmd/go: do not require a valid archChar when using -compiler gccgoDave Cheney2014-01-221-1/+6
| | | | | | | | Fixes issue 7152. R=iant, rsc, gobot CC=golang-codereviews https://codereview.appspot.com/54790044
* go/build: mention 'tag' as an alias for 'build constraint'Rob Pike2013-12-191-2/+2
| | | | | | | | | | | The code is all about tags, and the cmd/go documentation said to look in the go/build documentation for information about tags, but the documentation said nothing about tags, only build constraints. Make things clearer. R=golang-dev, adg, rsc CC=golang-dev https://codereview.appspot.com/44100043