Skip to content

Commit

Permalink
support darwin_x86_64 cpu value (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-parsons authored and pmbethe09 committed May 3, 2017
1 parent 342c688 commit 04a6871
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions go/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def go_environment_vars(ctx):
"GOARCH": "386"},
"darwin": {"GOOS": "darwin",
"GOARCH": "amd64"},
"darwin_x86_64": {"GOOS": "darwin",
"GOARCH": "amd64"},
"freebsd": {"GOOS": "freebsd",
"GOARCH": "amd64"},
"armeabi-v7a": {"GOOS": "linux",
Expand All @@ -183,6 +185,10 @@ def go_environment_vars(ctx):
{"GOOS": "linux",
"GOARCH": "amd64"})

def _is_darwin_cpu(ctx):
cpu = ctx.fragments.cpp.cpu
return cpu == "darwin" or cpu == "darwin_x86_64"

def _emit_generate_params_action(cmds, ctx, fn):
cmds_all = [
# Use bash explicitly. /bin/sh is default, and it may be linked to a
Expand Down Expand Up @@ -542,7 +548,7 @@ def _emit_go_link_action(ctx, importmap, transitive_libs, cgo_deps, lib,
# http://lists.apple.com/archives/Darwin-dev/2006/Sep/msg00084.html
# TODO(yugui) Remove this workaround once rules_go stops supporting XCode 7.2
# or earlier.
if ctx.fragments.cpp.cpu != 'darwin':
if not _is_darwin_cpu(ctx):
link_cmd += ["-s"]

link_cmd += [
Expand Down Expand Up @@ -1151,7 +1157,7 @@ def _cgo_object_impl(ctx):
"-nostdlib",
"-Wl,-r",
]
if ctx.fragments.cpp.cpu == "darwin":
if _is_darwin_cpu(ctx):
arguments += ["-shared", "-Wl,-all_load"]
else:
arguments += ["-Wl,-whole-archive"]
Expand Down

0 comments on commit 04a6871

Please sign in to comment.