about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-12-13T15·15+0000
committerVincent Ambo <tazjin@google.com>2019-12-13T15·15+0000
commitcfae527cc14c55f2cfa3d356674971c627ad1a88 (patch)
treec12164acf353575ae6fed8611078e325db4a462f
parent5649c75d01dc9058d9a6092ad2a504669cc780a9 (diff)
feat(buildGo): Support linking of symabi files for ASM sources
-rw-r--r--buildGo.nix9
1 files changed, 7 insertions, 2 deletions
diff --git a/buildGo.nix b/buildGo.nix
index 759a671fad9b..b61c3904fb18 100644
--- a/buildGo.nix
+++ b/buildGo.nix
@@ -64,12 +64,17 @@ let
   #
   # This outputs both the sources and compiled binary, as both are
   # needed when downstream packages depend on it.
-  package = { name, srcs, deps ? [], path ? name }:
+  package = { name, srcs, deps ? [], path ? name, sfiles ? [] }:
   let uniqueDeps = allDeps deps;
+      asmBuild = if sfiles == [] then "" else ''
+        ${go}/bin/go tool asm -trimpath $PWD -I $PWD -I ${go}/share/go/pkg/include -D GOOS_linux -D GOARCH_amd64 -gensymabis -o ./symabis ${spaceOut sfiles}
+      '';
+      asmLink = if sfiles == [] then "-complete" else "-symabis ./symabis";
   in (runCommand "golib-${name}" {} ''
     mkdir -p $out/${path}
     ${srcList path (map (s: "${s}") srcs)}
-    ${go}/bin/go tool compile -o $out/${path}.a -trimpath=$PWD -trimpath=${go} -p ${path} ${includeSources uniqueDeps} ${spaceOut srcs}
+    ${asmBuild}
+    ${go}/bin/go tool compile -pack ${asmLink} -o $out/${path}.a -trimpath=$PWD -trimpath=${go} -p ${path} ${includeSources uniqueDeps} ${spaceOut srcs}
   '') // { goDeps = uniqueDeps; goImportPath = path; };
 
   # Build a tree of Go libraries out of an external Go source