From edba66aa90f8bac5dd7c31b6352ba47524571ac0 Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Tue, 15 Sep 2015 12:04:22 +1000 Subject: [PATCH] context: add linkmode and buildmode Fixes #340 No accessors to change linkmode and buildmode because we don't support anything except buildmode=exe, and linkmode defaults to automatic. --- context.go | 9 ++++++--- gc.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/context.go b/context.go index ba21a64..5285828 100644 --- a/context.go +++ b/context.go @@ -37,6 +37,8 @@ type Context struct { gcflags []string // flags passed to the compiler ldflags []string // flags passed to the linker + + linkmode, buildmode string // link and build modes } // GOOS configures the Context to use goos as the target os. @@ -88,9 +90,10 @@ func (p *Project) NewContext(opts ...func(*Context) error) (*Context, error) { GcToolchain(), } ctx := Context{ - Project: p, - workdir: mktmpdir(), - pkgs: make(map[string]*Package), + Project: p, + workdir: mktmpdir(), + pkgs: make(map[string]*Package), + buildmode: "exe", } for _, opt := range append(defaults, opts...) { diff --git a/gc.go b/gc.go index bed57e4..c93fd1e 100644 --- a/gc.go +++ b/gc.go @@ -85,7 +85,7 @@ func (t *gcToolchain) Ld(pkg *Package, searchpaths []string, outfile, afile stri } args = append(args, "-extld="+gcc()) if gc15 { - args = append(args, "-buildmode=exe") + args = append(args, "-buildmode", pkg.buildmode) } args = append(args, afile) if err := mkdir(filepath.Dir(outfile)); err != nil {