boklm pushed to branch main at The Tor Project / Applications / tor-browser-build
Commits: 1f881995 by JeremyRand at 2023-05-15T11:34:26+00:00 Bug 32355: binutils: Add linux-cross target
- - - - - eb83bb70 by Jeremy Rand at 2023-05-15T11:34:26+00:00 Bug 32355: gcc: Add linux-arm target
- - - - - 25d02d5d by JeremyRand at 2023-05-15T11:34:26+00:00 Bug 32355: openssl: Add linux-arm target
- - - - - 225f00eb by Jeremy Rand at 2023-05-15T11:34:26+00:00 Bug 32355: gcc: Add osname to output filename
Makes it easier to tell which outputs are for linux-cross.
- - - - -
5 changed files:
- projects/binutils/build - projects/binutils/config - projects/gcc/build - projects/gcc/config - projects/openssl/config
Changes:
===================================== projects/binutils/build ===================================== @@ -23,7 +23,11 @@ cd [% project %]-[% c("version") %] make -j[% c("num_procs") %] MAKEINFO=true make install MAKEINFO=true
-[% IF c("var/linux") %] +# gold is disabled for linux-cross, because of +# https://sourceware.org/bugzilla/show_bug.cgi?id=14995 +# Once we upgrade to glibc 2.26, we might be able to enable gold for +# linux-cross. +[% IF c("var/linux") && ! c("var/linux-cross") %] # Make sure gold is used with the hardening wrapper for full RELRO, see #13031. cd $distdir/bin rm ld
===================================== projects/binutils/config ===================================== @@ -10,6 +10,11 @@ targets: windows: var: configure_opt: '--target=[% c("arch") %]-w64-mingw32 --disable-multilib --enable-deterministic-archives' + linux-cross: + var: + # gold is disabled on cross-compiles until we upgrade to glibc 2.26 and + # binutils 2.28 + configure_opt: '--target=[% c("var/crosstarget") %] --disable-multilib --enable-deterministic-archives --enable-plugins'
input_files: - URL: https://ftp.gnu.org/gnu/binutils/binutils-%5B% c("version") %].tar.xz
===================================== projects/gcc/build ===================================== @@ -16,11 +16,85 @@ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48817. export DEB_BUILD_HARDENING_FORMAT=0 [% END -%] -distdir=/var/tmp/dist/[% project %] +distdir=/var/tmp/dist/[% c("var/distdir") %] mkdir /var/tmp/build -tar -C /var/tmp/build -xf $rootdir/[% c('input_files_by_name/gcc') %] -cd /var/tmp/build/[% project %]-[% c("version") %] -./configure --prefix=$distdir [% c("var/configure_opt") %] + +[% IF c("var/linux-cross") -%] + + # Install binutils (needed for cross-compiling) + mkdir /var/tmp/dist + cd /var/tmp/dist + tar xf $rootdir/[% c('input_files_by_name/binutils') %] + mv binutils $distdir + export PATH="$distdir/bin:$PATH" + + # Install Linux headers, see Step 2 of + # https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/ + # Doing this before gcc configure is intended to solve a limits.h issue + cd /var/tmp/build + mkdir linux + cd linux + tar -xJf $rootdir/linux-[% c("var/linux_version") %].tar.xz + cd linux-[% c("var/linux_version") %] + make ARCH=[% c("arch") %] INSTALL_HDR_PATH=$distdir/[% c("var/crosstarget") %] headers_install + + cd /var/tmp/build + mkdir gcc + cd gcc + tar -xJf $rootdir/[% c('input_files_by_name/gcc') %] + # --with-headers is intended to solve a limits.h issue + [% project %]-[% c("version") %]/configure --prefix=$distdir --with-headers=$distdir/[% c("var/crosstarget") %]/include/linux [% c("var/configure_opt") %] + + # For cross-compiling to work, we need to partially build GCC, then build + # glibc, then come back to finish GCC. + + # Build only the components of GCC that don't need glibc, see Step 3 of + # https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/ + cd /var/tmp/build/gcc + make -j[% c("num_procs") %] all-gcc + make install-gcc + # Removing sys-include is intended to solve a limits.h issue + rm --recursive --force $distdir/[% c("var/crosstarget") %]/sys-include + + # Build glibc headers and startup files, see Step 4 of + # https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/ + cd /var/tmp/build + mkdir glibc + cd glibc + tar -xJf $rootdir/glibc-[% c("var/glibc_version") %].tar.xz + # TODO: Remove --disable-werror once glibc is upgraded to a version that's + # designed to work with the GCC version we're using. + 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 + make install-bootstrap-headers=yes install-headers + make -j[% c("num_procs") %] csu/subdir_lib + install csu/crt1.o csu/crti.o csu/crtn.o $distdir/[% c("var/crosstarget") %]/lib + [% c("var/crosstarget") %]-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $distdir/[% c("var/crosstarget") %]/lib/libc.so + # stdio_lim.h is intended to solve a limits.h issue + touch $distdir/[% c("var/crosstarget") %]/include/gnu/stubs.h $distdir/[% c("var/crosstarget") %]/include/bits/stdio_lim.h + + # Build compiler support library, see Step 5 of + # https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/ + cd /var/tmp/build/gcc + make -j[% c("num_procs") %] all-target-libgcc + make install-target-libgcc + + # finish building glibc, see Step 6 of + # https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/ + cd /var/tmp/build/glibc + make -j[% c("num_procs") %] + make install + + # We're done with glibc, we can now finish building gcc... + cd /var/tmp/build/gcc + +[% ELSE -%] + + tar -C /var/tmp/build -xf $rootdir/[% c('input_files_by_name/gcc') %] + cd /var/tmp/build/[% project %]-[% c("version") %] + ./configure --prefix=$distdir [% c("var/configure_opt") %] + +[% END -%] + make -j[% c("num_procs") %] make install # tor-browser-build#31321: we need a link to our GCC, to prevent some projects @@ -28,6 +102,6 @@ make install ln -s gcc $distdir/bin/cc cd /var/tmp/dist [% c('tar', { - tar_src => [ project ], + tar_src => [ c('var/distdir') ], tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'), }) %]
===================================== projects/gcc/config ===================================== @@ -1,5 +1,5 @@ # vim: filetype=yaml sw=2 -filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz' +filename: '[% project %]-[% c("version") %]-[% IF c("var/linux-cross") %][% c("var/osname") %][% ELSE %]x86[% END %]-[% c("var/build_id") %].tar.gz' # Note: When updating the gcc version, if this includes a libstdc++ # ABI change we should also update projects/firefox/abicheck.cc to # require the new version. @@ -7,14 +7,17 @@ version: '[% pc("gcc-source", "version") %]' container: use_container: 1 var: + distdir: gcc deps: - build-essential - libmpc-dev setup: | mkdir -p /var/tmp/dist tar -C /var/tmp/dist -xf $rootdir/[% c("compiler_tarfile") %] - export PATH="/var/tmp/dist/gcc/bin:$PATH" - export LD_LIBRARY_PATH=/var/tmp/dist/gcc/lib64:/var/tmp/dist/gcc/lib32 + export PATH="/var/tmp/dist/[% c("var/distdir") %]/bin:$PATH" + [% IF ! c("var/linux-cross") -%] + export LD_LIBRARY_PATH=/var/tmp/dist/[% c("var/distdir") %]/lib64:/var/tmp/dist/[% c("var/distdir") %]/lib32 + [% END -%]
[% IF c("hardened_gcc") -%] # Config options for hardening-wrapper @@ -25,14 +28,14 @@ var: export DEB_BUILD_HARDENING_PIE=1
# Make sure we use the hardening wrapper - pushd /var/tmp/dist/gcc/bin + pushd /var/tmp/dist/[% c("var/distdir") %]/bin cp /usr/bin/hardened-cc ./ - mv gcc gcc.real - mv c++ c++.real - mv g++ g++.real - ln -sf hardened-cc gcc - ln -sf hardened-cc c++ - ln -sf hardened-cc g++ + mv [% c("var/target_prefix") %]gcc [% c("var/target_prefix") %]gcc.real + mv [% c("var/target_prefix") %]c++ [% c("var/target_prefix") %]c++.real + mv [% c("var/target_prefix") %]g++ [% c("var/target_prefix") %]g++.real + ln -sf hardened-cc [% c("var/target_prefix") %]gcc + ln -sf hardened-cc [% c("var/target_prefix") %]c++ + ln -sf hardened-cc [% c("var/target_prefix") %]g++ popd [% END -%]
@@ -50,8 +53,34 @@ targets: arch_deps: - hardening-wrapper - libc6-dev-i386 + linux-cross: + var: + target_prefix: '[% c("var/crosstarget") %]-' + distdir: gcc-cross + # TODO: Consider upgrading to a glibc that works out of the box with the + # GCC version we use. However, removing our glibc version workarounds may + # not be desirable since we want to be able to easily bump the GCC + # version without worrying about linux-cross breakage. + glibc_version: 2.26 + linux_version: 4.10.1 + arch_deps: + - hardening-wrapper + - libc6-dev-i386 + - gawk + linux-arm: + var: + 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
input_files: - project: container-image - project: gcc-source name: gcc + - name: binutils + project: binutils + enable: '[% c("var/linux-cross") -%]' + - URL: 'https://ftp.gnu.org/gnu/glibc/glibc-%5B% c("var/glibc_version") %].tar.xz' + sha256sum: e54e0a934cd2bc94429be79da5e9385898d2306b9eaf3c92d5a77af96190f6bd + enable: '[% c("var/linux-cross") -%]' + - URL: 'https://www.kernel.org/pub/linux/kernel/v4.x/linux-%5B% c("var/linux_version") %].tar.xz' + sha256sum: 6ca06bb5faf5f83600d7388bb623dae41df2a257de85ad5d1792e03302bc3543 + enable: '[% c("var/linux-cross") -%]'
===================================== projects/openssl/config ===================================== @@ -14,6 +14,9 @@ targets: linux-i686: var: configure_opts: -shared linux-x86 + linux-arm: + var: + configure_opts: -shared --cross-compile-prefix=[% c("var/crosstarget") %]- linux-armv4 windows: var: flag_mwindows: ''
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/compare/0...
tbb-commits@lists.torproject.org