Skip to content

Commit

Permalink
unbootstrap gcc/binutils
Browse files Browse the repository at this point in the history
  • Loading branch information
jhheider committed Jan 28, 2023
1 parent 04bc017 commit cede0e3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 57 deletions.
18 changes: 6 additions & 12 deletions projects/gnu.org/binutils/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ distributable:

versions:
#TODO HTML listing: https://ftp.gnu.org/gnu/binutils/
- v2.39
- '2.40'
- 2.39

build:
dependencies:
Expand All @@ -15,23 +16,16 @@ build:
tea.xyz/gx/cc: c99
linux:
gnu.org/gcc: '*'
gnu.org/binutils: '*'
script: |
# FIXME: bootstrap - we need `as` from binutils to build with gcc
if test "{{hw.platform}}" = "linux"; then
if command -v sudo; then
sudo apt-get --yes install binutils
else # assume no sudo = we can just run apt-get
apt-get --yes install binutils
fi
fi
./configure --prefix={{ prefix }}
make --jobs {{ hw.concurrency }}
make install
test:
script: objdump -x $(which objdump) | grep -s $TEST_STRING
script: |
objdump -x $(which objdump) | grep "$TEST_STRING"
objdump -x $(which objdump) | grep -s "$TEST_STRING"
env:
# Representitive output to look for
darwin:
Expand Down
69 changes: 24 additions & 45 deletions projects/gnu.org/gcc/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,25 @@ versions:
strip: /^releases\/gcc-/

dependencies:
darwin:
apple.com/xcode/clt: '*' # needed for MacOS.sdk
gnu.org/gmp: '>=4.2'
gnu.org/mpfr: '>=2.4.0'
gnu.org/mpc: '>=0.8.0'
# Post bootstrap
# gnu.org/binutils: '*'
gnu.org/binutils: '*' # linker needs `as`

build:
dependencies:
darwin:
tea.xyz/gx/cc: c99 # need cc to strip `-nodefaultrpaths`
# linux:
# gnu.org/gcc: '*'
tea.xyz/gx/cc: c99
linux:
gnu.org/gcc: '*'
gnu.org/make: '*'
perl.org: '^5.6.1'
gnu.org/patch: '*'
curl.se: '*'
working-directory: build
script: |
# Branch from the Darwin maintainer of GCC, with a few generic fixes and
# Apple Silicon support, located at https://github.com/iains/gcc-12-branch
curl https://raw.githubusercontent.com/Homebrew/formula-patches/1d184289/gcc/gcc-12.2.0-arm.diff | patch -p1
# skip multilib prefixes for best interop
sed -i.bak -e 's_m64=../lib64_m64=_' gcc/config/i386/t-linux64
rm gcc/config/i386/t-linux64.bak
### /*** BOOTSTRAP BLOCK - REMOVE AFTER BOOTSTRAP ***/
if test "{{hw.platform}}" = "linux"; then
command -v sudo && SUDO=sudo
$SUDO apt-get --yes install gcc g++
fi
### /*** END BOOTSTRAP BLOCK ***/
mkdir build
cd build
curl https://raw.githubusercontent.com/Homebrew/formula-patches/1d184289/gcc/gcc-12.2.0-arm.diff | patch -p1 -d..
# Note that env vars with spaces don't behave well, due to shells and life
# in general. So we handle those in script. Unless and until we decide to
Expand All @@ -62,12 +38,21 @@ build:
export ARGS=("${ARGS[@]}" --with-boot-ldflags="-static-libstdc++ -static-libgcc $LDFLAGS")
fi
# On darwin, we build with the default llvm, so getting gnu's as in the path causes issues
if test {{hw.platform}} = "darwin"; then
export PATH=$(echo $PATH | tr ':' '\n' | grep -v '{{deps.gnu.org/binutils.prefix}}/bin' | tr '\n' ':')
fi
../configure "${ARGS[@]}"
make --jobs {{ hw.concurrency }}
make install
cd {{prefix}}/bin
ln -s c++ gc++
# On Linux, we need to move the libraries to the lib directory.
if test {{hw.platform}} = "linux"; then
cd {{prefix}}
mv lib64/* lib/
rmdir lib64
fi
env:
ARGS:
- --prefix={{ prefix }}
Expand All @@ -92,21 +77,15 @@ build:
ARGS:
- --build=x86_64-apple-darwin20.0.0

test:
# FIXME: remove after bootstrap of gcc/binutils
dependencies:
gnu.org/binutils: '*' # for `as`
script: |
gcc --version | grep -q "tea GCC {{version}}"
gcc -o test1 test.c -lgmp
./test1
g++ -o test2 test.cc
test "$(./test2)" = "Hello, world!"
test: |
gcc --version | grep -q "tea GCC {{version}}"
gcc -o test1 test.c -lgmp
./test1
g++ -o test2 test.cc
test "$(./test2)" = "Hello, world!"
provides:
# we keep `c++` in tea.xyz/gx/cc, but we expose it
# as `gc++` here in case someone wants it explicitly
- bin/gc++
- bin/c++
- bin/cpp
- bin/g++
- bin/gcc
Expand Down

0 comments on commit cede0e3

Please sign in to comment.