Skip to content

Commit

Permalink
Fix Ubuntu 22.04 issues and add parallelization support (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgshep authored Mar 9, 2023
1 parent b1f79f6 commit 88c5c8c
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 18 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ RUN apt-get update && apt-get install -y \
git \
wget \
sudo \
make \
lsb-release \
&& chmod +x /i686-elf-tools/i686-elf-tools.sh \
&& /i686-elf-tools/i686-elf-tools.sh env \
&& /i686-elf-tools/i686-elf-tools.sh env -parallel \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /opt/mxe/.ccache \
&& rm -rf /opt/mxe/pkg

ENTRYPOINT ["/i686-elf-tools/i686-elf-tools.sh"]
ENTRYPOINT ["/i686-elf-tools/i686-elf-tools.sh"]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ If you experience any issues, you can specify one or more command line arguments
* `-bv`/`--binutils-version` - specify the Binutils version to build
* `-dv`/`--gdb-version` - specify the GDB version to build
* `-64` - compile for x86_64-elf instead of i686-elf
* `-parallel` - build `make` recipes in [parallel](https://www.gnu.org/software/make/manual/html_node/Parallel.html) (`-j4`). To modify the number of jobs executed in parallel, modify `i686-elf-tools.sh`

```sh
# Compile binutils and gcc only
Expand All @@ -96,6 +97,8 @@ e.g. **~/build-i686-elf/build-gcc-7.1.0/gcc_make.log**

If you attempt to run `make` and `configure` commands manually that depend on components of the linux i686-elf toolchain, ensure `~/build-i686-elf/linux/output/bin` is on your path, else you may get errors about binaries being missing.

By default, i686-elf-tools will build `make` recipes in parallel. If any arguments are specified to `i686-elf-tools.sh` however, parallel compilation must be opted into by explicitly specifying `-parallel`.

## Mac OS X

Installing an i386-elf toolchain on Mac OS X is - theoretically - outstandingly simple process. Note that the following relies on a third party script and is not supported by me. It may be possible to run *i686-elf-tools.sh* on Mac OS X with a bit of tweaking (like not using `apt-get` to install packages) however this is not supported.
Expand Down
91 changes: 75 additions & 16 deletions i686-elf-tools.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# i686-elf-tools.sh
# v1.3.1
# v1.3.2

# Define Global Variables

Expand All @@ -22,7 +22,7 @@ if [ $# -eq 0 ]; then
BUILD_GCC=true
BUILD_GDB=true
ZIP=true

PARALLEL=true
args="binutils gcc gdb zip"
else
args=$@
Expand All @@ -41,6 +41,7 @@ case $key in
zip) ZIP=true; ALL_PRODUCTS=false; shift ;;
env) ENV_ONLY=true; shift ;;
-64) x64=true; shift ;;
-parallel) PARALLEL=true; shift ;;
-bv|--binutils-version) BINUTILS_VERSION="$2"; shift; shift ;;
-gv|--gcc-version) GCC_VERSION="$2"; shift; shift ;;
-dv|--gdb-version) GDB_VERSION="$2"; shift; shift ;;
Expand Down Expand Up @@ -69,6 +70,7 @@ echo "BINUTILS_VERSION = ${BINUTILS_VERSION}"
echo "GCC_VERSION = ${GCC_VERSION}"
echo "GDB_VERSION = ${GDB_VERSION}"
echo "PATH = ${PATH}"
echo "PARALLEL = ${PARALLEL}"

function main {

Expand Down Expand Up @@ -96,21 +98,58 @@ function main {

finalize
}

function installPackages {

pkgList=(
git
autoconf
automake
autopoint
bash
bison
bzip2
flex
gettext
g++
gperf
intltool
libffi-dev
libgdk-pixbuf2.0-dev
libtool
libltdl-dev
libssl-dev
libxml-parser-perl
make
python3-mako
openssl
p7zip-full
patch
perl
pkg-config
ruby
scons
sed
unzip
wget
xz-utils
libtool-bin
texinfo
g++-multilib
lzip)
echoColor "Installing packages"

sudo -E DEBIAN_FRONTEND=noninteractive apt-get -qq install git \
autoconf automake autopoint bash bison bzip2 flex gettext\
g++ gperf intltool libffi-dev libgdk-pixbuf2.0-dev \
libtool libltdl-dev libssl-dev libxml-parser-perl make python3-mako \
openssl p7zip-full patch perl pkg-config python ruby scons \
sed unzip wget xz-utils libtool-bin texinfo g++-multilib lzip -y
# Fix correct python packages on modern Ubuntu versions
if [[ $(lsb_release -a) =~ .*"Ubuntu".*$ ]]; then
pkgList+=(python3 python-is-python3)
else
pkgList+=(python)
fi

for pkg in ${pkgList[@]}; do
sudo -E DEBIAN_FRONTEND=noninteractive apt-get -qq install $pkg -y
done
}

# MXE

function installMXE {

echoColor "Installing MXE"
Expand All @@ -121,7 +160,11 @@ function installMXE {
cd /opt
sudo -E git clone https://github.com/mxe/mxe.git
cd mxe
sudo make gcc
if [[ $PARALLEL == true ]]; then
sudo make -j4 gcc
else
sudo make gcc
fi
else
echoColor " MXE is already installed. You'd better make sure that you've previously made MXE's gcc! (/opt/mxe/usr/bin/i686-w64-mingw32.static-gcc)"
fi
Expand Down Expand Up @@ -266,7 +309,11 @@ function compileBinutils {

# Make
echoColor " Making (binutils_make.log)"
make >> binutils_make.log
if [[ $PARALLEL == true ]]; then
make -j4 >> binutils_make.log
else
make >> binutils_make.log
fi

# Install
echoColor " Installing (binutils_install.log)"
Expand Down Expand Up @@ -309,15 +356,23 @@ function compileGCC {

# Make GCC
echoColor " Making gcc (gcc_make.log)"
make all-gcc >> gcc_make.log
if [[ $PARALLEL == true ]]; then
make -j4 all-gcc >> gcc_make.log
else
make all-gcc >> gcc_make.log
fi

# Install GCC
echoColor " Installing gcc (gcc_install.log)"
sudo make install-gcc >> gcc_install.log

# Make libgcc
echoColor " Making libgcc (libgcc_make.log)"
make all-target-libgcc >> libgcc_make.log
if [[ $PARALLEL == true ]]; then
make -j4 all-target-libgcc >> libgcc_make.log
else
make all-target-libgcc >> libgcc_make.log
fi

# Install libgcc
echoColor " Installing libgcc (libgcc_install.log)"
Expand Down Expand Up @@ -370,7 +425,11 @@ function compileGDB {

# Make
echoColor " Making (gdb_make.log)"
make >> gdb_make.log
if [[ $PARALLEL == true ]]; then
make -j4 >> gdb_make.log
else
make >> gdb_make.log
fi

# Install
echoColor " Installing (gdb_install.log)"
Expand Down

0 comments on commit 88c5c8c

Please sign in to comment.