Skip to content

Commit

Permalink
Build GCC 11.2.0 for steam-runtime scout
Browse files Browse the repository at this point in the history
  • Loading branch information
danielga committed Oct 17, 2021
1 parent 9eb84d6 commit 0df5453
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 0 deletions.
60 changes: 60 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
trigger:
batch: true
branches:
include:
- 'gcc-build'
tags:
include:
- 'gcc-build/*'
jobs:
- job: gcc_build
displayName: Build GCC 11.2.0 compiler for steam-runtime scout
pool:
name: Azure Pipelines
vmImage: ubuntu-latest
container:
image: registry.gitlab.steamos.cloud/steamrt/scout/sdk:latest
options: -v /home
timeoutInMinutes: 180
steps:
- checkout: self
clean: true
fetchDepth: 1
submodules: recursive
- bash: 'build/gcc_build.sh 11.2.0'
displayName: Build
- task: CopyFiles@2
displayName: 'Copy files to $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)'
Contents: 'gcc-*.tar.xz'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
CleanTargetFolder: true
flattenFolders: true
preserveTimestamp: true
- task: PublishBuildArtifacts@1
displayName: 'Publish build artifacts'
inputs:
ArtifactName: gcc_build
- job: publish
displayName: Publish to GitHub Releases
pool:
name: Azure Pipelines
vmImage: ubuntu-latest
timeoutInMinutes: 10
dependsOn:
- gcc_build
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download build artifacts'
inputs:
downloadType: specific
parallelizationLimit: 12
- task: GitHubRelease@1
displayName: 'Publish GitHub release $(build.sourceBranchName)'
inputs:
gitHubConnection: 'GitHub danielga'
releaseNotesSource: inline
assets: '$(System.ArtifactsDirectory)/**'
addChangeLog: false
85 changes: 85 additions & 0 deletions build/gcc_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

set -euxo pipefail

# Don't use with versions prior to GCC 9!
version="${1:-11.2.0}"
major_version=`echo "$version" | cut -d. -f1`

sudo apt-get -y install wget flex texinfo build-essential m4 bison

if [ ! -f "gcc-${version}.tar.xz" ]; then
wget "http://ftp.gnu.org/gnu/gcc/gcc-${version}/gcc-${version}.tar.xz"
fi

if [ ! -d "gcc-${version}" ]; then
tar -xf "gcc-${version}.tar.xz"
fi

pushd "gcc-${version}"

contrib/download_prerequisites

if [ "$major_version" -ge "11" ]; then
# Patch dwarf_version to default to 4 instead of 5, since steam-runtime's ld doesn't support DWARF 5.
# This build of GCC will still support -gdwarf-5, but that's up to the user.
patch -u -p0 -N << EOF
--- gcc/common.opt 2021-09-29 17:10:59.793270902 +0100
+++ gcc/common.opt 2021-09-29 16:46:44.733263653 +0100
@@ -3175,7 +3175,7 @@
Generate debug information in default version of DWARF format.
gdwarf-
-Common Driver Joined UInteger Var(dwarf_version) Init(5) Negative(gstabs)
+Common Driver Joined UInteger Var(dwarf_version) Init(4) Negative(gstabs)
Generate debug information in DWARF v2 (or later) format.
gdwarf32
EOF
fi

rm -rf build/
mkdir build
pushd build

export CC=gcc-5
export CXX=g++-5
export AR=gcc-ar-5
export NM=gcc-nm-5
export RANLIB=gcc-ranlib-5

core_count=`getconf _NPROCESSORS_ONLN`
double_core_count="$(( core_count * 2 ))"

../configure -v --with-pkgversion="SteamRT ${version}-1+steamrt1.3+srt1" \
--enable-languages=brig,c,c++,d,fortran,lto,objc,obj-c++ \
--prefix="/usr/lib/gcc-${major_version}" --with-gcc-major-version-only \
--program-prefix= --program-suffix="-${major_version}" --enable-shared \
--enable-linker-build-id --with-pic --enable-nls --enable-clocale=gnu \
--enable-libstdcxx-debug --enable-libstdcxx-time=yes \
--with-default-libstdcxx-abi=gcc4-compatible --disable-libstdcxx-dual-abi \
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie \
--with-system-zlib --enable-multiarch --disable-werror --with-arch-32=i686 \
--with-abi=m64 --with-multilib-list=m32,m64 --enable-multilib --with-tune=generic \
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu \
--target=x86_64-linux-gnu
make -j "$double_core_count"
sudo make install-strip

popd

popd

sudo mkdir -p /usr/lib/gcc-11/lib32/backup
sudo mv /usr/lib/gcc-11/lib32/*.so* /usr/lib/gcc-11/lib32/backup

sudo mkdir -p /usr/lib/gcc-11/lib32/debug/backup
sudo mv /usr/lib/gcc-11/lib32/debug/*.so* /usr/lib/gcc-11/lib32/debug/backup

sudo mkdir -p /usr/lib/gcc-11/lib64/backup
sudo mv /usr/lib/gcc-11/lib64/*.so* /usr/lib/gcc-11/lib64/backup

sudo mkdir -p /usr/lib/gcc-11/lib64/debug/backup
sudo mv /usr/lib/gcc-11/lib64/debug/*.so* /usr/lib/gcc-11/lib64/debug/backup

tar -cvJf "gcc-${version}.tar.xz" "/usr/lib/gcc-${major_version}"

0 comments on commit 0df5453

Please sign in to comment.