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

[tor-commits] [Git][tpo/applications/tor-browser-build][main] Bug 40777: Update Go to 1.20.4 and create a Go bootstrap project



Title: GitLab

Pier Angelo Vendrame pushed to branch main at The Tor Project / Applications / tor-browser-build

Commits:

  • b37e2ebd
    by Pier Angelo Vendrame at 2023-05-25T18:28:35+02:00
    Bug 40777: Update Go to 1.20.4 and create a Go bootstrap project
    
    The Go compiler is written in Go, but it is possible to bootstrap it
    from C wiht Go 1.4.
    Before this commit, we used to build Go 1.4 for all our platforms,
    so we built a compiler to throw it away several times.
    
    Starting from Go 1.20, the team decided to require Go V-3 to bootstrap
    (i.e., Go 1.17 to bootrastrap Go 1.20).
    Bootstrapping is still feasible, but throwing away two compilers is
    not a good idea. So, we decided to create a Go bootstrap project, and
    build it only once (for Linux amd64) until it will be able to build
    more recent Go compilers.
    

5 changed files:

Changes:

  • projects/go-bootstrap/build
    1
    +#!/bin/bash
    
    2
    +[% c("var/set_default_env") -%]
    
    3
    +
    
    4
    +# This project is expected to be built only on Linux.
    
    5
    +# Then the actual Go compiler will be built for each platform.
    
    6
    +
    
    7
    +distdir=/var/tmp/dist/[% project %]
    
    8
    +mkdir -p /var/tmp/build /var/tmp/dist
    
    9
    +
    
    10
    +# Building go 1.4.x
    
    11
    +# This is needed to bootstrap the go that we actually use
    
    12
    +# https://golang.org/doc/install/source#go14
    
    13
    +tar -C /var/tmp/build --transform='s,^go\>,go1.4,' -xf $rootdir/[% c('input_files_by_name/go14') %]
    
    14
    +cd /var/tmp/build/go1.4/src
    
    15
    +# Disable cgo to avoid conflicts with newer GCC. cgo is not needed for the bootstrap go.
    
    16
    +# https://github.com/golang/go/issues/13114#issuecomment-186922245
    
    17
    +# Disable CC etc. that are set up for cross builds.
    
    18
    +CGO_ENABLED=0 CC= CFLAGS= LDFLAGS= ./make.bash
    
    19
    +export GOROOT_BOOTSTRAP="/var/tmp/build/go1.4"
    
    20
    +
    
    21
    +cd $rootdir
    
    22
    +
    
    23
    +tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/go') %]
    
    24
    +export GOROOT="$distdir"
    
    25
    +mv /var/tmp/dist/go $distdir
    
    26
    +cd $distdir/src
    
    27
    +
    
    28
    +./make.bash
    
    29
    +
    
    30
    +# This directory is non-reproducible and doesn't exist in official Go releases,
    
    31
    +# so remove it to preserve reproducibility of the output.
    
    32
    +rm -rf $distdir/pkg/obj/go-build/
    
    33
    +
    
    34
    +cd /var/tmp/dist
    
    35
    +[% c('tar', {
    
    36
    +        tar_src => [ project ],
    
    37
    +        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    
    38
    +    }) %]

  • projects/go-bootstrap/config
    1
    +# vim: filetype=yaml sw=2
    
    2
    +version: 1.19.9
    
    3
    +filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
    
    4
    +container:
    
    5
    +  use_container: 1
    
    6
    +
    
    7
    +input_files:
    
    8
    +  - project: container-image
    
    9
    +  - URL: 'https://golang.org/dl/go[% c("version") %].src.tar.gz'
    
    10
    +    name: go
    
    11
    +    sha256sum: 131190a4697a70c5b1d232df5d3f55a3f9ec0e78e40516196ffb3f09ae6a5744
    
    12
    +  - URL: https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz
    
    13
    +    name: go14
    
    14
    +    sha256sum: f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52

  • projects/go/0001-Use-fixed-go-build-tmp-directory.patch
    1
    -From 958f724b1b434702c3d44ceaca646791674d07b1 Mon Sep 17 00:00:00 2001
    
    1
    +From 2c1c98d6404284df744a194dd23bd3660f365387 Mon Sep 17 00:00:00 2001
    
    2 2
     From: Georg Koppen <gk@xxxxxxxxxxxxxx>
    
    3 3
     Date: Fri, 17 Apr 2020 10:24:23 +0000
    
    4 4
     Subject: [PATCH] Use fixed go-build tmp directory
    
    ... ... @@ -6,15 +6,18 @@ Subject: [PATCH] Use fixed go-build tmp directory
    6 6
     Use fixed go-build tmp directory, when the directory does not exist, in
    
    7 7
     order to avoid some reproducibility issues where build directory gets
    
    8 8
     embedded in generated binaries.
    
    9
    +---
    
    10
    + src/cmd/go/internal/work/action.go | 10 +++++++---
    
    11
    + 1 file changed, 7 insertions(+), 3 deletions(-)
    
    9 12
     
    
    10 13
     diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go
    
    11
    -index 33b7818fb2..5e369d0f53 100644
    
    14
    +index 8beb1345d0..dccf39c1c1 100644
    
    12 15
     --- a/src/cmd/go/internal/work/action.go
    
    13 16
     +++ b/src/cmd/go/internal/work/action.go
    
    14
    -@@ -252,9 +252,13 @@ func (b *Builder) Init() {
    
    15
    - 	if cfg.BuildN {
    
    16
    - 		b.WorkDir = "$WORK"
    
    17
    - 	} else {
    
    17
    +@@ -279,9 +279,13 @@ func NewBuilder(workDir string) *Builder {
    
    18
    + 		if !buildInitStarted {
    
    19
    + 			panic("internal error: NewBuilder called before BuildInit")
    
    20
    + 		}
    
    18 21
     -		tmp, err := os.MkdirTemp(cfg.Getenv("GOTMPDIR"), "go-build")
    
    19 22
     -		if err != nil {
    
    20 23
     -			base.Fatalf("go: creating work dir: %v", err)
    
    ... ... @@ -29,5 +32,5 @@ index 33b7818fb2..5e369d0f53 100644
    29 32
      		if !filepath.IsAbs(tmp) {
    
    30 33
      			abs, err := filepath.Abs(tmp)
    
    31 34
     -- 
    
    32
    -2.26.1
    
    35
    +2.39.2
    
    33 36
     

  • projects/go/build
    ... ... @@ -3,27 +3,8 @@
    3 3
     distdir=/var/tmp/dist/[% project %]
    
    4 4
     mkdir -p /var/tmp/dist
    
    5 5
     
    
    6
    -[% IF c("var/linux") %]
    
    7
    -  # Config options for hardening-wrapper
    
    8
    -  export DEB_BUILD_HARDENING=1
    
    9
    -  export DEB_BUILD_HARDENING_STACKPROTECTOR=1
    
    10
    -  export DEB_BUILD_HARDENING_FORTIFY=1
    
    11
    -  export DEB_BUILD_HARDENING_FORMAT=1
    
    12
    -  export DEB_BUILD_HARDENING_PIE=1
    
    13
    -[% END %]
    
    14
    -
    
    15
    -mkdir -p /var/tmp/build
    
    16
    -
    
    17
    -# Building go 1.4.x
    
    18
    -# This is needed to bootstrap the go that we actually use
    
    19
    -# https://golang.org/doc/install/source#go14
    
    20
    -tar -C /var/tmp/build --transform='s,^go\>,go1.4,' -xf $rootdir/[% c('input_files_by_name/go14') %]
    
    21
    -cd /var/tmp/build/go1.4/src
    
    22
    -# Disable cgo to avoid conflicts with newer GCC. cgo is not needed for the bootstrap go.
    
    23
    -# https://github.com/golang/go/issues/13114#issuecomment-186922245
    
    24
    -# Disable CC etc. that are set up for cross builds.
    
    25
    -CGO_ENABLED=0 CC= CFLAGS= LDFLAGS= ./make.bash
    
    26
    -export GOROOT_BOOTSTRAP="/var/tmp/build/go1.4"
    
    6
    +tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/go-bootstrap') %]
    
    7
    +export GOROOT_BOOTSTRAP="/var/tmp/dist/go-bootstrap"
    
    27 8
     
    
    28 9
     cd $rootdir
    
    29 10
     [% IF ! c("var/linux") %]
    

  • projects/go/config
    1 1
     # vim: filetype=yaml sw=2
    
    2
    -version: 1.19.9
    
    3
    -filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
    
    2
    +version: 1.20.4
    
    3
    +filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
    
    4 4
     container:
    
    5 5
       use_container: 1
    
    6 6
     
    
    7 7
     var:
    
    8
    -  go14_version: 1.4.3
    
    9
    -
    
    10 8
       setup: |
    
    11 9
         mkdir -p /var/tmp/dist
    
    12 10
         tar -C /var/tmp/dist -xf $rootdir/[% c("go_tarfile") %]
    
    ... ... @@ -121,9 +119,10 @@ input_files:
    121 119
         enable: '[% ! c("var/linux") %]'
    
    122 120
       - URL: 'https://golang.org/dl/go[% c("version") %].src.tar.gz'
    
    123 121
         name: go
    
    124
    -    sha256sum: 131190a4697a70c5b1d232df5d3f55a3f9ec0e78e40516196ffb3f09ae6a5744
    
    125
    -  - URL: 'https://golang.org/dl/go[% c("var/go14_version") %].src.tar.gz'
    
    126
    -    name: go14
    
    127
    -    sha256sum: 9947fc705b0b841b5938c48b22dc33e9647ec0752bae66e50278df4f23f64959
    
    122
    +    sha256sum: 9f34ace128764b7a3a4b238b805856cc1b2184304df9e5690825b0710f4202d6
    
    123
    +  - project: go-bootstrap
    
    124
    +    name: go-bootstrap
    
    125
    +    target_replace:
    
    126
    +      '^.*browser-.*': 'basebrowser-linux-x86_64'
    
    128 127
       - filename: 0001-Use-fixed-go-build-tmp-directory.patch
    
    129 128
         enable: '[% c("var/android") %]'

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