[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser-build/master] Bug 27827: pass -tmpdir to the linker in snowflake build



commit 28abf57bd5bd307262741ac679a80e98aa389d20
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Tue Oct 16 18:40:59 2018 -0600

    Bug 27827: pass -tmpdir to the linker in snowflake build
    
    The update to go 1.11.1 fixed part of #27827, namely the
    /tmp/go-buildRANDOMNUM paths embedded in the binary. However there is
    still a single /tmp/go-link-RANDOMNUM/go.o path remaining -- it comes
    from here:
    https://github.com/golang/go/blob/go1.11.1/src/cmd/link/internal/ld/lib.go#L935-L946
    The random path affects the Go build ID even if we overwrite the random
    digits in the binary.
    
    Luckily there's a -tmpdir flag that lets us override the random path.
---
 projects/snowflake/build | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/projects/snowflake/build b/projects/snowflake/build
index 693d853..777d360 100644
--- a/projects/snowflake/build
+++ b/projects/snowflake/build
@@ -35,32 +35,13 @@ cd client
 [% IF c("var/osx") -%]
   # Without faketime, snowflake-client would contain the timestamp of the
   # temporary client.a file created during "go build".
-  [% c("var/faketime") %] go build -ldflags '-s'
+  # The -tmpdir flag overrides what would otherwise be a randomly generated
+  # path, /tmp/go-link-RANDOMNUM/go.o.
+  mkdir -p /var/tmp/go-link.tmpdir
+  [% c("var/faketime") %] go build -ldflags '-s -tmpdir /var/tmp/go-link.tmpdir'
 [% ELSE -%]
   go build -ldflags '-s'
 [% END -%]
-[% IF c("var/osx") -%]
-  # Hack: Overwrite variable absolute paths embedded in the binary. clang 3.8.0
-  # on Darwin embeds such paths and the issue is unsolved in upstream Go as of
-  # 2016-06-28:
-  # https://github.com/golang/go/issues/9206#issuecomment-310476743
-  # The two kinds of paths are ("000000000" stands for 9 random digits):
-  #   /tmp/go-build000000000
-  #   /tmp/go-link-000000000
-  # Such paths are the output of ioutil.TempDir("", "go-build") and
-  # ioutil.TempDir("", "go-link-").
-  cp -a client client.stomped
-  sed -i -E -e 's#(/tmp/go-build|/tmp/go-link-)[0-9]{9}/#\1XXXXXXXXX/#g' client.stomped
-  # Sanity check: make sure the file actually changed. If it did not, it could
-  # mean that a change in go or clang has made this step unnecessary.
-  if cmp client client.stomped
-  then
-    echo "No paths replaced in snowflake-client. Maybe the replacement failed or is no longer needed."
-    echo "Check projects/snowflake/build"
-    exit 1
-  fi
-  mv -f client.stomped client
-[% END -%]
 cp -a client[% IF c("var/windows") %].exe[% END %] $PTDIR/snowflake-client[% IF c("var/windows") %].exe[% END %]
 
 cd ..



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits