Unverified Commit 9b591074 authored by boklm's avatar boklm
Browse files

Build go-webrtc and snowflake for mac.

tor-browser-bundle.git author: David Fifield <david@bamsoftware.com>
tor-browser-bundle.git commit: 26e0cd44f2886bfad1c3d30844ff7a21eb9d0478

Commit message from the tor-browser-bundle.git commit:

Build go-webrtc and snowflake in the mac pluggable-transports descriptor.

I had to apply two tricks to get a reproducible snowflake-client.

The first is to use faketime to eliminate some timestamps. There were 11
variable timestamps in the file. Through experimentation, I found that
10 of them were dependent on the Go runtime (recompiling Go caused them
to change) and 1 was dependent on snowflake-client itself (recompiling
snowflake-client with the same runtime changed only that 1 timestamp).
The underlying issue has to do with clang 3.8.0 on Darwin embedding
timestamps, unsolved in the Go issue tracker as of 13 days ago.
https://github.com/golang/go/issues/9206#issuecomment-310476743

The second is a sed command to clobber embedded paths of the form
/tmp/go-buildXXXXXXXXX and /tmp/go-link-XXXXXXXXX. Their presence is
caused by some combination of Clang and Darwin, and there is as yet no
known workaround upstream.
parent de79b7e0
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ var:
    # Replace the prebuilt webrtc library with our own one.
    rm -rf include/ lib/
    cp -a /var/tmp/dist/webrtc/{include,lib} .
    [% IF c("var/linux") -%]
      # The go-webrtc package sets _GLIBCXX_USE_CXX11_ABI=0 for compatibility with
      # the prebuilt libwebrtc-magic.a libraries. Since we build our own
      # libwebrtc-magic.a with the C++11 ABI, we have to undo that setting here,
@@ -27,6 +28,15 @@ var:
      # __STDC_FORMAT_MACROS is needed for a definition of PRIxPTR from inttypes.h.
      export CGO_CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=1 -D__STDC_FORMAT_MACROS=1"
      export CGO_LDFLAGS=-latomic
    [% END -%]
    [% IF c("var/osx") -%]
      export CGO_ENABLED=1
      export CGO_CFLAGS="[% c("var/FLAGS") %] -mmacosx-version-min=10.7"
      export CGO_CXXFLAGS="[% c("var/FLAGS") %] -stdlib=libc++ -mmacosx-version-min=10.7"
      export CGO_LDFLAGS="[% c("var/FLAGS") %] -stdlib=libc++ -mmacosx-version-min=10.7"
      export CC="$clangdir/bin/clang"
      export CXX="$clangdir/bin/clang++"
    [% END -%]

targets:
  master:
@@ -36,6 +46,10 @@ targets:
      arch_deps:
        - pkg-config
        - libx11-dev
  osx-x86_64:
    var:
      arch_deps:
        - pkg-config

input_files:
  - project: container-image
+6 −1
Original line number Diff line number Diff line
@@ -52,7 +52,12 @@ cd /var/tmp/dist/go/src
  # http://golang.org/doc/install/source#environment
  export GOOS=darwin
  export GOARCH=amd64
  CGO_ENABLED=1 CC_FOR_TARGET="$CC_FOR_TARGET" CC= CFLAGS= LDFLAGS= ./make.bash
  # faketime is needed because clang 3.8.0 on Darwin embeds the timestamps of
  # certain intermediate object files (including those that arise here while
  # compiling the Go runtime itself). Without this, variable timestamps would
  # end up in snowflake-client.
  # https://github.com/golang/go/issues/9206#issuecomment-310476743
  CGO_ENABLED=1 CC_FOR_TARGET="$CC_FOR_TARGET" CC= CFLAGS= LDFLAGS= [% c("var/faketime") %] ./make.bash
[% ELSIF c("var/windows") -%]
  # Create a cc-for-target script that closes over CC, CFLAGS, and LDFLAGS.
  # Go's CC_FOR_TARGET only allows a command name, not a command with arguments.
+2 −0
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ targets:
    var:
      GOOS: darwin
      GOARCH: amd64
      arch_deps:
        - faketime
  linux:
    var:
      GOOS: linux
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ tar -C $distdir -xf [% c('input_files_by_name/cctools') %]
cd $distdir/cctools/bin
ln -s ../../clang/bin/clang x86_64-apple-darwin10-clang
ln -s ../../clang/bin/clang++ x86_64-apple-darwin10-clang++
# "go link" expects to find a program called "dsymutil" exactly.
ln -sf x86_64-apple-darwin10-dsymutil dsymutil

cd "/var/tmp/dist"
[% c('tar', {
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ var:
    use_container: 1
  setup: |
    mkdir -p /var/tmp/dist
    tar -C /var/tmp/dist -xf [% c("compiler_tarfile") %]
    tar -C /var/tmp/dist -xf $rootdir/[% c("compiler_tarfile") %]
    export sysrootdir=/var/tmp/dist/[% project %]/SDK/
    export clangdir=/var/tmp/dist/[% project %]/clang
    export cctoolsdir=/var/tmp/dist/[% project %]/cctools/bin
Loading