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

[tor-commits] [Git][tpo/applications/tor-browser-build][main] 7 commits: Bug 41137: add the linux-aarch64 targets and improve linux-cross



Title: GitLab

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

Commits:

  • 08c95509
    by NoisyCoil at 2024-05-08T15:40:26+02:00
    Bug 41137: add the linux-aarch64 targets and improve linux-cross
    
  • 9c8ed4d1
    by NoisyCoil at 2024-05-08T15:43:49+02:00
    Bug 41137: '--add-architecture' in containers only when actually cross-compiling
    
    Mainly so that the container's id, which is also determined by 'pre',
    does not change if we call the project with 'linux-cross' but don't
    actually need to cross-compile.
    
  • e53ab0d3
    by NoisyCoil at 2024-05-08T15:44:51+02:00
    Bug 41137: Define distdir and filename for cross-binutils
    
  • af937966
    by NoisyCoil at 2024-05-08T15:46:09+02:00
    Bug 41137: Separate gcc and gcc-cross
    
    Use stretch's glibc and stretch-security's linux to maintain
    compatibility with Debian stretch, add linux-aarch64 glibc patches to
    avoid build failures
    
  • db06f569
    by NoisyCoil at 2024-05-08T15:49:12+02:00
    Bug 41137: Add the linux-aarch64 target to OpenSSL
    
  • da1663bd
    by NoisyCoil at 2024-05-09T11:17:19+02:00
    Bug 41137: Add the linux-{aarch64,arm} targets to Tor
    
  • 06de89a5
    by NoisyCoil at 2024-05-09T11:17:19+02:00
    Bug 41137: Add the linux-{aarch64,arm} targets to Go
    

16 changed files:

Changes:

  • projects/binutils/build
    1 1
     #!/bin/bash
    
    2 2
     [% c("var/set_default_env") -%]
    
    3 3
     mkdir /var/tmp/dist
    
    4
    -distdir=/var/tmp/dist/binutils
    
    4
    +distdir=/var/tmp/dist/[% c("var/distdir") %]
    
    5 5
     [% IF c("var/linux"); GET c("var/set_hardened_build_flags"); END %]
    
    6 6
     
    
    7 7
     tar xf [% project %]-[% c("version") %].tar.xz
    
    ... ... @@ -15,6 +15,6 @@ make install MAKEINFO=true
    15 15
     
    
    16 16
     cd /var/tmp/dist
    
    17 17
     [% c('tar', {
    
    18
    -        tar_src => [ project ],
    
    18
    +        tar_src => [ c('var/distdir') ],
    
    19 19
             tar_args => '-caf ' _ dest_dir _ '/' _ c('filename'),
    
    20 20
             }) %]

  • projects/binutils/config
    1 1
     # vim: filetype=yaml sw=2
    
    2 2
     version: 2.39
    
    3
    -filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.[% c("compress_tar") %]'
    
    3
    +filename: '[% project %]-[% c("version") %]-[% IF c("var/linux-cross") %]cross-[% c("arch") %]-[% END %][% c("var/build_id") %].tar.[% c("compress_tar") %]'
    
    4 4
     container:
    
    5 5
       use_container: 1
    
    6 6
     var:
    
    7
    +  distdir: binutils
    
    7 8
       configure_opt: '--disable-multilib --enable-gold --enable-deterministic-archives --enable-plugins'
    
    8 9
     
    
    9 10
     targets:
    
    ... ... @@ -12,6 +13,7 @@ targets:
    12 13
           configure_opt: '--target=[% c("arch") %]-w64-mingw32 --disable-multilib --enable-deterministic-archives'
    
    13 14
       linux-cross:
    
    14 15
         var:
    
    16
    +      distdir: 'binutils-cross-[% c("arch") %]'
    
    15 17
           # gold is disabled on cross-compiles until we upgrade to glibc 2.26 and
    
    16 18
           # binutils 2.28
    
    17 19
           configure_opt: '--target=[% c("var/crosstarget") %] --disable-multilib --enable-deterministic-archives --enable-plugins'
    

  • projects/container-image/config
    ... ... @@ -34,7 +34,7 @@ pre: |
    34 34
       apt-get update -y -q
    
    35 35
       [% IF pc(c('origin_project'), 'var/pre_pkginst', { step => c('origin_step') }) -%]
    
    36 36
         [% pc(c('origin_project'), 'var/pre_pkginst', { step => c('origin_step') }) %]
    
    37
    -    [% IF c("var/linux-cross") -%]
    
    37
    +    [% IF c("var/linux-cross") && ! pc(c('origin_project'), 'var/no_crosscompile', { step => c('origin_step') }) -%]
    
    38 38
           dpkg --add-architecture [% c("var/arch_debian") %]
    
    39 39
         [% END -%]
    
    40 40
         # Update the package cache again because `pre_pkginst` may change the
    

  • projects/gcc-cross/build
    1
    +#!/bin/sh
    
    2
    +[% c("var/set_default_env") -%]
    
    3
    +mkdir -p /var/tmp/build
    
    4
    +distdir=/var/tmp/dist/[% c("var/distdir") %]
    
    5
    +
    
    6
    +# Install native gcc
    
    7
    +mkdir /var/tmp/dist
    
    8
    +cd /var/tmp/dist
    
    9
    +tar xf $rootdir/[% c('input_files_by_name/gcc-native') %]
    
    10
    +export PATH="$distdir/bin:$PATH"
    
    11
    +
    
    12
    +# Install cross binutils (needed for cross-compiling)
    
    13
    +cd /var/tmp/dist
    
    14
    +tar xf $rootdir/[% c('input_files_by_name/binutils') %]
    
    15
    +rsync -a binutils-cross-[% c("arch") %]/* $distdir
    
    16
    +rm -rf binutils-cross-[% c("arch") %]
    
    17
    +
    
    18
    +# Install Linux headers, see Step 2 of
    
    19
    +# https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
    
    20
    +# Doing this before gcc configure is intended to solve a limits.h issue
    
    21
    +cd /var/tmp/build
    
    22
    +mkdir linux
    
    23
    +cd linux
    
    24
    +tar -xJf $rootdir/linux-[% c("var/linux_version") %].tar.xz
    
    25
    +cd linux-[% c("var/linux_version") %]
    
    26
    +make ARCH=[% IF c("arch") == "aarch64" %]arm64[% ELSE %][% c("arch") %][% END %] INSTALL_HDR_PATH=$distdir/[% c("var/crosstarget") %] headers_install
    
    27
    +
    
    28
    +cd /var/tmp/build
    
    29
    +mkdir gcc-cross
    
    30
    +cd gcc-cross
    
    31
    +tar -xJf $rootdir/[% c('input_files_by_name/gcc') %]
    
    32
    +cd gcc-[% c("version") %]
    
    33
    +patch -p1 <$rootdir/gcc-cross.patch
    
    34
    +
    
    35
    +cd /var/tmp/build/gcc-cross
    
    36
    +gcc-[% c("version") %]/configure --prefix=$distdir --includedir=$distdir/[% c("var/crosstarget") %]/include [% c("var/configure_opt") %]
    
    37
    +
    
    38
    +# For cross-compiling to work, we need to partially build GCC, then build
    
    39
    +# glibc, then come back to finish GCC.
    
    40
    +
    
    41
    +# Build only the components of GCC that don't need glibc, see Step 3 of
    
    42
    +# https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
    
    43
    +cd /var/tmp/build/gcc-cross
    
    44
    +make -j[% c("num_procs") %] all-gcc
    
    45
    +make install-gcc
    
    46
    +
    
    47
    +# Build glibc headers and startup files, see Step 4 of
    
    48
    +# https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
    
    49
    +cd /var/tmp/build
    
    50
    +mkdir glibc
    
    51
    +cd glibc
    
    52
    +tar -xJf $rootdir/glibc-[% c("var/glibc_version") %].tar.xz
    
    53
    +[% IF c("var/linux-aarch64") -%]
    
    54
    +  # Avoid linking issues by backporting glibc patches
    
    55
    +  cd glibc-[% c("var/glibc_version") %]
    
    56
    +  patch -p1 <$rootdir/glibc-cross-linux-aarch64.patch
    
    57
    +  patch -p1 <$rootdir/glibc-cross-linux-aarch64-2.patch
    
    58
    +  cd /var/tmp/build/glibc
    
    59
    +[% END -%]
    
    60
    +
    
    61
    +# TODO: Remove --disable-werror once glibc is upgraded to a version that's
    
    62
    +# designed to work with the GCC version we're using.
    
    63
    +glibc-[% c("var/glibc_version") %]/configure --prefix=$distdir/[% c("var/crosstarget") %] --build=$MACHTYPE --host=[% c("var/crosstarget") %] --target=[% c("var/crosstarget") %] --with-headers=$distdir/[% c("var/crosstarget") %]/include --disable-multilib --disable-werror libc_cv_forced_unwind=yes
    
    64
    +make install-bootstrap-headers=yes install-headers
    
    65
    +make -j[% c("num_procs") %] csu/subdir_lib
    
    66
    +install csu/crt1.o csu/crti.o csu/crtn.o $distdir/[% c("var/crosstarget") %]/lib
    
    67
    +[% c("var/crosstarget") %]-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $distdir/[% c("var/crosstarget") %]/lib/libc.so
    
    68
    +# stdio_lim.h is intended to solve a limits.h issue
    
    69
    +touch $distdir/[% c("var/crosstarget") %]/include/gnu/stubs.h $distdir/[% c("var/crosstarget") %]/include/bits/stdio_lim.h
    
    70
    +
    
    71
    +# Build compiler support library, see Step 5 of
    
    72
    +# https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
    
    73
    +cd /var/tmp/build/gcc-cross
    
    74
    +make -j[% c("num_procs") %] all-target-libgcc
    
    75
    +make install-target-libgcc
    
    76
    +
    
    77
    +# finish building glibc, see Step 6 of
    
    78
    +# https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
    
    79
    +cd /var/tmp/build/glibc
    
    80
    +make -j[% c("num_procs") %]
    
    81
    +make install
    
    82
    +
    
    83
    +# We're done with glibc, we can now finish building gcc...
    
    84
    +cd /var/tmp/build/gcc-cross
    
    85
    +make -j[% c("num_procs") %]
    
    86
    +make install
    
    87
    +
    
    88
    +# Include a working version of limits.h
    
    89
    +cd gcc-[% c("version") %]
    
    90
    +cat gcc/limitx.h gcc/glimits.h gcc/limity.h >$distdir/lib/gcc/[% c("var/crosstarget") %]/[% c("version") %]/include/limits.h
    
    91
    +
    
    92
    +cd /var/tmp/dist
    
    93
    +[% c('tar', {
    
    94
    +        tar_src => [ c('var/distdir') ],
    
    95
    +        tar_args => '-caf ' _ dest_dir _ '/' _ c('filename'),
    
    96
    +        }) %]

  • projects/gcc-cross/config
    1
    +# vim: filetype=yaml sw=2
    
    2
    +filename: '[% project %]-[% c("version") %]-[% c("arch") %]-[% c("var/build_id") %].tar.[% c("compress_tar") %]'
    
    3
    +# Note: When updating the gcc version, if this includes a libstdc++
    
    4
    +# ABI change we should also update projects/firefox/abicheck.cc to
    
    5
    +# require the new version.
    
    6
    +version: '[% pc("gcc-source", "version") %]'
    
    7
    +container:
    
    8
    +  use_container: 1
    
    9
    +hardened_gcc: 1
    
    10
    +var:
    
    11
    +  distdir: gcc
    
    12
    +  deps:
    
    13
    +    - build-essential
    
    14
    +    - libmpc-dev
    
    15
    +  setup: |
    
    16
    +    mkdir -p /var/tmp/dist
    
    17
    +    tar -C /var/tmp/dist -xf $rootdir/[% c("compiler_tarfile") %]
    
    18
    +    export PATH="/var/tmp/dist/[% c("var/distdir") %]/bin:$PATH"
    
    19
    +    export LD_LIBRARY_PATH=/var/tmp/dist/[% c("var/distdir") %]/lib64:/var/tmp/dist/[% c("var/distdir") %]/lib32
    
    20
    +    [% IF c("hardened_gcc"); GET c("var/set_hardened_build_flags"); END %]
    
    21
    +  configure_opt: '--target=[% c("var/crosstarget") %] --disable-multilib --enable-languages=c,c++ --with-glibc-version=[% c("var/glibc_version") %]'
    
    22
    +  # Use stretch's glibc and stretch-security's linux
    
    23
    +  glibc_version: 2.24
    
    24
    +  linux_version: 4.19.232
    
    25
    +  arch_deps:
    
    26
    +    - libc6-dev-i386
    
    27
    +    - gawk
    
    28
    +    - rsync
    
    29
    +
    
    30
    +targets:
    
    31
    +  linux-arm:
    
    32
    +    var:
    
    33
    +      configure_opt: '--target=[% c("var/crosstarget") %] --disable-multilib --enable-languages=c,c++ --with-glibc-version=[% c("var/glibc_version") %] --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb'
    
    34
    +
    
    35
    +input_files:
    
    36
    +  - project: container-image
    
    37
    +  - project: gcc-source
    
    38
    +    name: gcc
    
    39
    +  - name: binutils
    
    40
    +    project: binutils
    
    41
    +    target_prepend:
    
    42
    +      - linux-cross
    
    43
    +  - name: gcc-native
    
    44
    +    project: gcc
    
    45
    +  - URL: 'https://ftp.gnu.org/gnu/glibc/glibc-[% c("var/glibc_version") %].tar.xz'
    
    46
    +    sha256sum: 99d4a3e8efd144d71488e478f62587578c0f4e1fa0b4eed47ee3d4975ebeb5d3
    
    47
    +  - URL: 'https://www.kernel.org/pub/linux/kernel/v4.x/linux-[% c("var/linux_version") %].tar.xz'
    
    48
    +    sha256sum: 4fcfe814780d63dc56e907bf41596ff162e9601978bdc1a60eab64cc3903a22c
    
    49
    +  - filename: 'gcc-cross.patch'
    
    50
    +  - filename: 'glibc-cross-linux-aarch64.patch'
    
    51
    +    enable: '[% c("var/linux-aarch64") -%]'
    
    52
    +  - filename: 'glibc-cross-linux-aarch64-2.patch'
    
    53
    +    enable: '[% c("var/linux-aarch64") -%]'

  • projects/gcc-cross/gcc-cross.patch
    1
    +Avoids "../../../gcc-10.3.0/libsanitizer/asan/asan_linux.cpp:217:21: error:
    
    2
    +'PATH_MAX' was not declared in this scope". PATH_MAX is in /include/linux/limits.h,
    
    3
    +which is usually included by /include/limits.h (indirectly, through posix headers,
    
    4
    +etc.). For some reason, when cross-compiling, this inclusion chain is broken and
    
    5
    +we must include <linux/limits.h> by hand.
    
    6
    +
    
    7
    +Index: gcc-10.3.0/libsanitizer/asan/asan_linux.cpp
    
    8
    +===================================================================
    
    9
    +--- gcc-10.3.0.orig/libsanitizer/asan/asan_linux.cpp
    
    10
    ++++ gcc-10.3.0/libsanitizer/asan/asan_linux.cpp
    
    11
    +@@ -32,6 +32,7 @@
    
    12
    + #include <dlfcn.h>
    
    13
    + #include <fcntl.h>
    
    14
    + #include <limits.h>
    
    15
    ++#include <linux/limits.h>
    
    16
    + #include <pthread.h>
    
    17
    + #include <stdio.h>
    
    18
    + #include <unistd.h>

  • projects/gcc-cross/glibc-cross-linux-aarch64-2.patch
    1
    +From e9177fba13549a8e2a6232f46080e5c6d3e467b1 Mon Sep 17 00:00:00 2001
    
    2
    +From: Szabolcs Nagy <szabolcs.nagy@xxxxxxx>
    
    3
    +Date: Wed, 21 Jun 2017 13:47:07 +0100
    
    4
    +Subject: [PATCH] [AArch64] Use hidden __GI__dl_argv in rtld startup code
    
    5
    +
    
    6
    +We rely on the symbol being locally defined so using extern symbol
    
    7
    +is not correct and the linker may complain about the relocations.
    
    8
    +---
    
    9
    + ChangeLog                    | 5 +++++
    
    10
    + sysdeps/aarch64/dl-machine.h | 4 ++--
    
    11
    + 2 files changed, 7 insertions(+), 2 deletions(-)
    
    12
    +
    
    13
    +Index: glibc/sysdeps/aarch64/dl-machine.h
    
    14
    +===================================================================
    
    15
    +--- glibc.orig/sysdeps/aarch64/dl-machine.h
    
    16
    ++++ glibc/sysdeps/aarch64/dl-machine.h
    
    17
    +@@ -172,8 +172,8 @@ _dl_start_user:							\n\
    
    18
    + 	cmp	x0, #0						\n\
    
    19
    + 	bne	1b						\n\
    
    20
    + 	// Update _dl_argv					\n\
    
    21
    +-	adrp	x3, _dl_argv					\n\
    
    22
    +-	str	x2, [x3, #:lo12:_dl_argv]			\n\
    
    23
    ++	adrp	x3, __GI__dl_argv				\n\
    
    24
    ++	str	x2, [x3, #:lo12:__GI__dl_argv]			\n\
    
    25
    + .L_done_stack_adjust:						\n\
    
    26
    + 	// compute envp						\n\
    
    27
    + 	add	x3, x2, x1, lsl #3				\n\
    
    28
    +-- 
    
    29
    +2.43.2
    
    30
    +

  • projects/gcc-cross/glibc-cross-linux-aarch64.patch
    1
    +From a68ba2f3cd3cbe32c1f31e13c20ed13487727b32 Mon Sep 17 00:00:00 2001
    
    2
    +From: Szabolcs Nagy <szabolcs.nagy@xxxxxxx>
    
    3
    +Date: Wed, 18 Oct 2017 17:26:23 +0100
    
    4
    +Subject: [PATCH] [AARCH64] Rewrite elf_machine_load_address using _DYNAMIC
    
    5
    + symbol
    
    6
    +
    
    7
    +This patch rewrites aarch64 elf_machine_load_address to use special _DYNAMIC
    
    8
    +symbol instead of _dl_start.
    
    9
    +
    
    10
    +The static address of _DYNAMIC symbol is stored in the first GOT entry.
    
    11
    +Here is the change which makes this solution work (part of binutils 2.24):
    
    12
    +https://sourceware.org/ml/binutils/2013-06/msg00248.html
    
    13
    +
    
    14
    +i386, x86_64 targets use the same method to do this as well.
    
    15
    +
    
    16
    +The original implementation relies on a trick that R_AARCH64_ABS32 relocation
    
    17
    +being resolved at link time and the static address fits in the 32bits.
    
    18
    +However, in LP64, normally, the address is defined to be 64 bit.
    
    19
    +
    
    20
    +Here is the C version one which should be portable in all cases.
    
    21
    +
    
    22
    +	* sysdeps/aarch64/dl-machine.h (elf_machine_load_address): Use
    
    23
    +	_DYNAMIC symbol to calculate load address.
    
    24
    +---
    
    25
    + ChangeLog                    |  5 +++++
    
    26
    + sysdeps/aarch64/dl-machine.h | 39 +++++-------------------------------
    
    27
    + 2 files changed, 10 insertions(+), 34 deletions(-)
    
    28
    +
    
    29
    +Index: glibc-2.26/sysdeps/aarch64/dl-machine.h
    
    30
    +===================================================================
    
    31
    +--- glibc-2.26.orig/sysdeps/aarch64/dl-machine.h
    
    32
    ++++ glibc-2.26/sysdeps/aarch64/dl-machine.h
    
    33
    +@@ -51,26 +51,11 @@ elf_machine_load_address (void)
    
    34
    +   /* To figure out the load address we use the definition that for any symbol:
    
    35
    +      dynamic_addr(symbol) = static_addr(symbol) + load_addr
    
    36
    + 
    
    37
    +-     The choice of symbol is arbitrary. The static address we obtain
    
    38
    +-     by constructing a non GOT reference to the symbol, the dynamic
    
    39
    +-     address of the symbol we compute using adrp/add to compute the
    
    40
    +-     symbol's address relative to the PC.
    
    41
    +-     This depends on 32bit relocations being resolved at link time
    
    42
    +-     and that the static address fits in the 32bits.  */
    
    43
    ++    _DYNAMIC sysmbol is used here as its link-time address stored in
    
    44
    ++    the special unrelocated first GOT entry.  */
    
    45
    + 
    
    46
    +-  ElfW(Addr) static_addr;
    
    47
    +-  ElfW(Addr) dynamic_addr;
    
    48
    +-
    
    49
    +-  asm ("					\n"
    
    50
    +-"	adrp	%1, _dl_start;			\n"
    
    51
    +-"	add	%1, %1, #:lo12:_dl_start	\n"
    
    52
    +-"	ldr	%w0, 1f				\n"
    
    53
    +-"	b	2f				\n"
    
    54
    +-"1:						\n"
    
    55
    +-"	.word	_dl_start			\n"
    
    56
    +-"2:						\n"
    
    57
    +-    : "=r" (static_addr),  "=r" (dynamic_addr));
    
    58
    +-  return dynamic_addr - static_addr;
    
    59
    ++    extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
    
    60
    ++    return (ElfW(Addr)) &_DYNAMIC - elf_machine_dynamic ();
    
    61
    + }
    
    62
    + 
    
    63
    + /* Set up the loaded object described by L so its unrelocated PLT

  • projects/gcc/build
    1 1
     #!/bin/sh
    
    2 2
     [% c("var/set_default_env") -%]
    
    3 3
     mkdir -p /var/tmp/build
    
    4
    -[% IF c("var/linux") && ! c("var/linux-cross") -%]
    
    4
    +
    
    5
    +[% IF c("var/linux") -%]
    
    5 6
       # Config options for hardening
    
    6 7
       export DEB_BUILD_HARDENING=1
    
    7 8
       # Since r223796 landed on GCC master enforcing PIE breaks GCC compilation.
    
    ... ... @@ -19,81 +20,9 @@ mkdir -p /var/tmp/build
    19 20
     [% END -%]
    
    20 21
     distdir=/var/tmp/dist/[% c("var/distdir") %]
    
    21 22
     
    
    22
    -[% IF c("var/linux-cross") -%]
    
    23
    -
    
    24
    -  # Install binutils (needed for cross-compiling)
    
    25
    -  mkdir /var/tmp/dist
    
    26
    -  cd /var/tmp/dist
    
    27
    -  tar xf $rootdir/[% c('input_files_by_name/binutils') %]
    
    28
    -  mv binutils $distdir
    
    29
    -  export PATH="$distdir/bin:$PATH"
    
    30
    -
    
    31
    -  # Install Linux headers, see Step 2 of
    
    32
    -  # https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
    
    33
    -  # Doing this before gcc configure is intended to solve a limits.h issue
    
    34
    -  cd /var/tmp/build
    
    35
    -  mkdir linux
    
    36
    -  cd linux
    
    37
    -  tar -xJf $rootdir/linux-[% c("var/linux_version") %].tar.xz
    
    38
    -  cd linux-[% c("var/linux_version") %]
    
    39
    -  make ARCH=[% c("arch") %] INSTALL_HDR_PATH=$distdir/[% c("var/crosstarget") %] headers_install
    
    40
    -
    
    41
    -  cd /var/tmp/build
    
    42
    -  mkdir gcc
    
    43
    -  cd gcc
    
    44
    -  tar -xJf $rootdir/[% c('input_files_by_name/gcc') %]
    
    45
    -  # --with-headers is intended to solve a limits.h issue
    
    46
    -  [% project %]-[% c("version") %]/configure --prefix=$distdir --with-headers=$distdir/[% c("var/crosstarget") %]/include/linux [% c("var/configure_opt") %]
    
    47
    -
    
    48
    -  # For cross-compiling to work, we need to partially build GCC, then build
    
    49
    -  # glibc, then come back to finish GCC.
    
    50
    -
    
    51
    -  # Build only the components of GCC that don't need glibc, see Step 3 of
    
    52
    -  # https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
    
    53
    -  cd /var/tmp/build/gcc
    
    54
    -  make -j[% c("num_procs") %] all-gcc
    
    55
    -  make install-gcc
    
    56
    -  # Removing sys-include is intended to solve a limits.h issue
    
    57
    -  rm --recursive --force $distdir/[% c("var/crosstarget") %]/sys-include
    
    58
    -
    
    59
    -  # Build glibc headers and startup files, see Step 4 of
    
    60
    -  # https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
    
    61
    -  cd /var/tmp/build
    
    62
    -  mkdir glibc
    
    63
    -  cd glibc
    
    64
    -  tar -xJf $rootdir/glibc-[% c("var/glibc_version") %].tar.xz
    
    65
    -  # TODO: Remove --disable-werror once glibc is upgraded to a version that's
    
    66
    -  # designed to work with the GCC version we're using.
    
    67
    -  glibc-[% c("var/glibc_version") %]/configure --prefix=$distdir/[% c("var/crosstarget") %] --build=$MACHTYPE --host=[% c("var/crosstarget") %] --target=[% c("var/crosstarget") %] --with-headers=$distdir/[% c("var/crosstarget") %]/include --disable-multilib --disable-werror libc_cv_forced_unwind=yes
    
    68
    -  make install-bootstrap-headers=yes install-headers
    
    69
    -  make -j[% c("num_procs") %] csu/subdir_lib
    
    70
    -  install csu/crt1.o csu/crti.o csu/crtn.o $distdir/[% c("var/crosstarget") %]/lib
    
    71
    -  [% c("var/crosstarget") %]-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $distdir/[% c("var/crosstarget") %]/lib/libc.so
    
    72
    -  # stdio_lim.h is intended to solve a limits.h issue
    
    73
    -  touch $distdir/[% c("var/crosstarget") %]/include/gnu/stubs.h $distdir/[% c("var/crosstarget") %]/include/bits/stdio_lim.h
    
    74
    -
    
    75
    -  # Build compiler support library, see Step 5 of
    
    76
    -  # https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
    
    77
    -  cd /var/tmp/build/gcc
    
    78
    -  make -j[% c("num_procs") %] all-target-libgcc
    
    79
    -  make install-target-libgcc
    
    80
    -
    
    81
    -  # finish building glibc, see Step 6 of
    
    82
    -  # https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
    
    83
    -  cd /var/tmp/build/glibc
    
    84
    -  make -j[% c("num_procs") %]
    
    85
    -  make install
    
    86
    -
    
    87
    -  # We're done with glibc, we can now finish building gcc...
    
    88
    -  cd /var/tmp/build/gcc
    
    89
    -
    
    90
    -[% ELSE -%]
    
    91
    -
    
    92
    -  tar -C /var/tmp/build -xf $rootdir/[% c('input_files_by_name/gcc') %]
    
    93
    -  cd /var/tmp/build/[% project %]-[% c("version") %]
    
    94
    -  ./configure --prefix=$distdir [% c("var/configure_opt") %]
    
    95
    -
    
    96
    -[% END -%]
    
    23
    +tar -C /var/tmp/build -xf $rootdir/[% c('input_files_by_name/gcc') %]
    
    24
    +cd /var/tmp/build/[% project %]-[% c("version") %]
    
    25
    +./configure --prefix=$distdir [% c("var/configure_opt") %]
    
    97 26
     
    
    98 27
     make -j[% c("num_procs") %]
    
    99 28
     make install
    

  • projects/gcc/config
    1 1
     # vim: filetype=yaml sw=2
    
    2
    -filename: '[% project %]-[% c("version") %]-[% IF c("var/linux-cross") %][% c("var/osname") %][% ELSE %]x86[% END %]-[% c("var/build_id") %].tar.[% c("compress_tar") %]'
    
    2
    +filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.[% c("compress_tar") %]'
    
    3 3
     # Note: When updating the gcc version, if this includes a libstdc++
    
    4 4
     # ABI change we should also update projects/firefox/abicheck.cc to
    
    5 5
     # require the new version.
    
    ... ... @@ -7,6 +7,7 @@ version: '[% pc("gcc-source", "version") %]'
    7 7
     container:
    
    8 8
       use_container: 1
    
    9 9
     var:
    
    10
    +  no_crosscompile: 1
    
    10 11
       distdir: gcc
    
    11 12
       deps:
    
    12 13
         - build-essential
    
    ... ... @@ -15,9 +16,7 @@ var:
    15 16
         mkdir -p /var/tmp/dist
    
    16 17
         tar -C /var/tmp/dist -xf $rootdir/[% c("compiler_tarfile") %]
    
    17 18
         export PATH="/var/tmp/dist/[% c("var/distdir") %]/bin:$PATH"
    
    18
    -    [% IF ! c("var/linux-cross") -%]
    
    19
    -      export LD_LIBRARY_PATH=/var/tmp/dist/[% c("var/distdir") %]/lib64:/var/tmp/dist/[% c("var/distdir") %]/lib32
    
    20
    -    [% END -%]
    
    19
    +    export LD_LIBRARY_PATH=/var/tmp/dist/[% c("var/distdir") %]/lib64:/var/tmp/dist/[% c("var/distdir") %]/lib32
    
    21 20
         [% IF c("hardened_gcc"); GET c("var/set_hardened_build_flags"); END %]
    
    22 21
     
    
    23 22
     targets:
    
    ... ... @@ -33,33 +32,8 @@ targets:
    33 32
           configure_opt: --enable-multilib --enable-languages=c,c++ --with-arch_32=i686
    
    34 33
           arch_deps:
    
    35 34
             - libc6-dev-i386
    
    36
    -  linux-cross:
    
    37
    -    var:
    
    38
    -      target_prefix: '[% c("var/crosstarget") %]-'
    
    39
    -      distdir: gcc-cross
    
    40
    -      # TODO: Consider upgrading to a glibc that works out of the box with the
    
    41
    -      # GCC version we use. However, removing our glibc version workarounds may
    
    42
    -      # not be desirable since we want to be able to easily bump the GCC
    
    43
    -      # version without worrying about linux-cross breakage.
    
    44
    -      glibc_version: 2.26
    
    45
    -      linux_version: 4.10.1
    
    46
    -      arch_deps:
    
    47
    -        - libc6-dev-i386
    
    48
    -        - gawk
    
    49
    -  linux-arm:
    
    50
    -    var:
    
    51
    -      configure_opt: --disable-multilib --enable-languages=c,c++ --target=arm-linux-gnueabihf --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb
    
    52 35
     
    
    53 36
     input_files:
    
    54 37
       - project: container-image
    
    55 38
       - project: gcc-source
    
    56 39
         name: gcc
    57
    -  - name: binutils
    
    58
    -    project: binutils
    
    59
    -    enable: '[% c("var/linux-cross") -%]'
    
    60
    -  - URL: 'https://ftp.gnu.org/gnu/glibc/glibc-[% c("var/glibc_version") %].tar.xz'
    
    61
    -    sha256sum: e54e0a934cd2bc94429be79da5e9385898d2306b9eaf3c92d5a77af96190f6bd
    
    62
    -    enable: '[% c("var/linux-cross") -%]'
    
    63
    -  - URL: 'https://www.kernel.org/pub/linux/kernel/v4.x/linux-[% c("var/linux_version") %].tar.xz'
    
    64
    -    sha256sum: 6ca06bb5faf5f83600d7388bb623dae41df2a257de85ad5d1792e03302bc3543
    
    65
    -    enable: '[% c("var/linux-cross") -%]'

  • projects/go-bootstrap/config
    ... ... @@ -4,6 +4,9 @@ filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.[% c("co
    4 4
     container:
    
    5 5
       use_container: 1
    
    6 6
     
    
    7
    +var:
    
    8
    +  no_crosscompile: 1
    
    9
    +
    
    7 10
     input_files:
    
    8 11
       - project: container-image
    
    9 12
       - URL: 'https://golang.org/dl/go[% c("version") %].src.tar.gz'
    

  • projects/go/config
    ... ... @@ -9,6 +9,7 @@ var:
    9 9
       use_go_1_20: 0
    
    10 10
       go_1_21: 1.21.9
    
    11 11
       go_1_20: 1.20.14
    
    12
    +  no_crosscompile: 1
    
    12 13
       setup: |
    
    13 14
         mkdir -p /var/tmp/dist
    
    14 15
         tar -C /var/tmp/dist -xf $rootdir/[% c("go_tarfile") %]
    
    ... ... @@ -101,6 +102,12 @@ targets:
    101 102
       linux-i686:
    
    102 103
         var:
    
    103 104
           GOARCH: 386
    
    105
    +  linux-aarch64:
    
    106
    +    var:
    
    107
    +      GOARCH: arm64
    
    108
    +  linux-arm:
    
    109
    +    var:
    
    110
    +      GOARCH: arm
    
    104 111
       android:
    
    105 112
         var:
    
    106 113
           GOOS: android
    

  • projects/openssl/config
    ... ... @@ -14,6 +14,9 @@ targets:
    14 14
       linux-i686:
    
    15 15
         var:
    
    16 16
           configure_opts: -shared linux-x86
    
    17
    +  linux-aarch64:
    
    18
    +    var:
    
    19
    +      configure_opts: -shared --cross-compile-prefix=[% c("var/crosstarget") %]- enable-ec_nistp_64_gcc_128 linux-aarch64
    
    17 20
       linux-arm:
    
    18 21
         var:
    
    19 22
           configure_opts: -shared --cross-compile-prefix=[% c("var/crosstarget") %]- linux-armv4
    

  • projects/tor/build
    ... ... @@ -21,6 +21,20 @@ mkdir $TORBINDIR
    21 21
     [% IF c("var/windows") || c("var/android") %]
    
    22 22
       tar -C /var/tmp/dist -xf [% c('input_files_by_name/zlib') %]
    
    23 23
       zlibdir=/var/tmp/dist/zlib
    
    24
    +[% ELSIF c("var/linux-cross") %]
    
    25
    +  # Since 1. we are using Debian's zlib1g-dev:$arch_debian, 2. our
    
    26
    +  # cross-toolchain's default paths (i.e. -I and -L) are not the same
    
    27
    +  # as those of Debian's cross-toolchain, and 3. tor's configure does
    
    28
    +  # not support separate header and library directories for zlib, we
    
    29
    +  # need to make the headers and $arch_debian library available to
    
    30
    +  # configure manually.
    
    31
    +  # DO NOT use CPPFLAGS="-I/usr/include" to include the headers, the
    
    32
    +  # build will fail (probably because some of our cross-$arch_debian
    
    33
    +  # headers get masked by the native ones).
    
    34
    +  CROSS_INCLUDEDIR=/var/tmp/dist/gcc/[% c("var/crosstarget") %]/include
    
    35
    +  ln -s /usr/include/zconf.h $CROSS_INCLUDEDIR
    
    36
    +  ln -s /usr/include/zlib.h $CROSS_INCLUDEDIR
    
    37
    +  export LDFLAGS="-L/usr/lib/[% c("var/crosstarget") %] $LDFLAGS"
    
    24 38
     [% END %]
    
    25 39
     [% IF c("var/android") %]
    
    26 40
       tar -C /var/tmp/dist -xf [% c('input_files_by_name/zstd') %]
    
    ... ... @@ -44,10 +58,14 @@ openssldir=/var/tmp/dist/openssl
    44 58
       # LD_LIBRARY_PATH value to the Tor Browser with the newer one. Thus, we copy
    
    45 59
       # the libstdc++ into the directory with the libs tor depends on, too. See bug
    
    46 60
       # 13359 for further details.
    
    47
    -  cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libstdc++.so.6 "$TORBINDIR"
    
    61
    +  libdir=[% c("var/libdir") %]
    
    62
    +  [% IF c("var/linux-cross") -%]
    
    63
    +    libdir="[% c("var/crosstarget") %]/$libdir"
    
    64
    +  [% END -%]
    
    65
    +  cp "/var/tmp/dist/gcc/$libdir/libstdc++.so.6" "$TORBINDIR"
    
    48 66
       [% IF c("var/asan") -%]
    
    49
    -    cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libasan.so.6 "$TORBINDIR"
    
    50
    -    cp /var/tmp/dist/gcc/[% c("var/libdir") %]/libubsan.so.1 "$TORBINDIR"
    
    67
    +    cp "/var/tmp/dist/gcc/$libdir/libasan.so.6" "$TORBINDIR"
    
    68
    +    cp "/var/tmp/dist/gcc/$libdir/libubsan.so.1" "$TORBINDIR"
    
    51 69
       [% END -%]
    
    52 70
       chmod 700 "$TORBINDIR"/*.so*
    
    53 71
       # This is needed to make RPATH unavailable. See bug 9150.
    
    ... ... @@ -73,6 +91,7 @@ find -type f -print0 | xargs -0 [% c("touch") %]
    73 91
         [% IF c("var/windows") || c("var/android") %]--with-zlib-dir="$zlibdir"[% END %] \
    
    74 92
         [% IF c("var/macos") %]--enable-static-openssl[% END %] \
    
    75 93
         [% IF c("var/windows") %]--enable-static-libevent --enable-static-openssl --enable-static-zlib[% END %] \
    
    94
    +    [% IF c("var/linux-cross") %]--build=x86_64-linux-gnu[% END %] \
    
    76 95
         --enable-gpl --prefix="$distdir" [% c("var/configure_opt") %]
    
    77 96
     [% IF c("var/macos") -%]
    
    78 97
       export LD_PRELOAD=[% c("var/faketime_path") %]
    
    ... ... @@ -103,10 +122,17 @@ cd $distdir
    103 122
     [% END %]
    
    104 123
     
    
    105 124
     [% IF c("var/linux") %]
    
    125
    +  [% IF c("var/linux-cross") -%]
    
    126
    +    CROSS_PREFIX=[% c("var/crosstarget") %]-
    
    127
    +  [% END -%]
    
    128
    +
    
    129
    +  OBJCOPY="${CROSS_PREFIX}objcopy"
    
    130
    +  STRIP="${CROSS_PREFIX}strip"
    
    131
    +
    
    106 132
       # Strip and generate debuginfo for libs
    
    107
    -  objcopy --only-keep-debug $distdir/bin/tor "$TORDEBUGDIR/tor"
    
    108
    -  install -s $distdir/bin/tor "$TORBINDIR"
    
    109
    -  objcopy --add-gnu-debuglink="$TORDEBUGDIR/tor" "$TORBINDIR/tor"
    
    133
    +  "$OBJCOPY" --only-keep-debug $distdir/bin/tor "$TORDEBUGDIR/tor"
    
    134
    +  install -s --strip-program="$STRIP" $distdir/bin/tor "$TORBINDIR"
    
    135
    +  "$OBJCOPY" --add-gnu-debuglink="$TORDEBUGDIR/tor" "$TORBINDIR/tor"
    
    110 136
       for i in "$TORBINDIR"/*so*
    
    111 137
       do
    
    112 138
           LIB=`basename $i`
    
    ... ... @@ -116,11 +142,11 @@ cd $distdir
    116 142
             # treat this the same as the rest (though it seems libstdc++ doesn't come with
    
    117 143
             # any useful debug symbols since we don't build it, so maybe we should figure
    
    118 144
             # out how to package them
    
    119
    -        strip "$TORBINDIR/$LIB"
    
    145
    +        "$STRIP" "$TORBINDIR/$LIB"
    
    120 146
           else
    
    121
    -        objcopy --only-keep-debug "$TORBINDIR/$LIB" "$TORDEBUGDIR/$LIB"
    
    122
    -        strip "$TORBINDIR/$LIB"
    
    123
    -        objcopy --add-gnu-debuglink="$TORDEBUGDIR/$LIB" "$TORBINDIR/$LIB"
    
    147
    +        "$OBJCOPY" --only-keep-debug "$TORBINDIR/$LIB" "$TORDEBUGDIR/$LIB"
    
    148
    +        "$STRIP" "$TORBINDIR/$LIB"
    
    149
    +        "$OBJCOPY" --add-gnu-debuglink="$TORDEBUGDIR/$LIB" "$TORBINDIR/$LIB"
    
    124 150
           fi
    
    125 151
       done
    
    126 152
     [% END %]
    

  • projects/tor/config
    ... ... @@ -30,6 +30,17 @@ targets:
    30 30
           libdir: lib64
    
    31 31
           arch_deps:
    
    32 32
             - zlib1g-dev
    
    33
    +  linux-aarch64:
    
    34
    +    var:
    
    35
    +      libdir: lib64
    
    36
    +      arch_deps:
    
    37
    +        - zlib1g-dev:arm64
    
    38
    +  linux-arm:
    
    39
    +    var:
    
    40
    +      libdir: lib
    
    41
    +      arch_deps:
    
    42
    +        - zlib1g-dev:armhf
    
    43
    +
    
    33 44
       android:
    
    34 45
         var:
    
    35 46
           configure_opt_project: '--enable-android --enable-static-openssl --enable-static-libevent --enable-zstd --disable-tool-name-check --disable-system-torrc'
    

  • rbm.conf
    ... ... @@ -468,14 +468,29 @@ targets:
    468 468
         - linux-i686
    
    469 469
         - linux
    
    470 470
         - basebrowser
    
    471
    +  torbrowser-linux-aarch64:
    
    472
    +    - linux-cross
    
    473
    +    - linux-aarch64
    
    474
    +    - linux
    
    475
    +    - torbrowser
    
    476
    +  basebrowser-linux-aarch64:
    
    477
    +    - linux-cross
    
    478
    +    - linux-aarch64
    
    479
    +    - linux
    
    480
    +    - basebrowser
    
    481
    +  mullvadbrowser-linux-aarch64:
    
    482
    +    - linux-cross
    
    483
    +    - linux-aarch64
    
    484
    +    - linux
    
    485
    +    - mullvadbrowser
    
    471 486
       torbrowser-linux-arm:
    
    472
    -    - linux-arm
    
    473 487
         - linux-cross
    
    488
    +    - linux-arm
    
    474 489
         - linux
    
    475 490
         - torbrowser
    
    476 491
       basebrowser-linux-arm:
    
    477
    -    - linux-arm
    
    478 492
         - linux-cross
    
    493
    +    - linux-arm
    
    479 494
         - linux
    
    480 495
         - basebrowser
    
    481 496
       linux-x86_64:
    
    ... ... @@ -493,18 +508,26 @@ targets:
    493 508
           linux-cross: 0
    
    494 509
           configure_opt: '--host=i686-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 [% c("var/configure_opt_project") %]'
    
    495 510
           arch_debian: i386
    
    511
    +  linux-aarch64:
    
    512
    +    arch: aarch64
    
    513
    +    var:
    
    514
    +      linux-aarch64: 1
    
    515
    +      osname: linux-aarch64
    
    516
    +      linux-cross: 1
    
    517
    +      arch_debian: arm64
    
    518
    +      crosstarget: aarch64-linux-gnu
    
    496 519
       linux-arm:
    
    497 520
         arch: arm
    
    498 521
         var:
    
    499 522
           linux-arm: 1
    
    500 523
           osname: linux-arm
    
    501
    -      crosstarget: arm-linux-gnueabihf
    
    524
    +      linux-cross: 1
    
    502 525
           arch_debian: armhf
    
    526
    +      crosstarget: arm-linux-gnueabihf
    
    503 527
       linux-cross:
    
    504 528
         var:
    
    505 529
           linux-cross: 1
    
    506
    -      container:
    
    507
    -        arch: amd64
    
    530
    +      compiler: 'gcc[% IF ! c("var/no_crosscompile") %]-cross[% END %]'
    
    508 531
           configure_opt: '--host=[% c("var/crosstarget") %] [% c("var/configure_opt_project") %]'
    
    509 532
       linux:
    
    510 533
         # tar in strech does not know how to extract tar.zst files
    

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