-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated first batch of instructions for x86_64.
- Loading branch information
Showing
13 changed files
with
353 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# perform as root: | ||
export MLFS=/mnt/mlfs | ||
mkdir -pv $MLFS | ||
mkdir -v $MLFS/sources | ||
chmod -v a+wt $MLFS/sources | ||
|
||
#download sources + patches | ||
|
||
mkdir -v $MLFS/cross-tools | ||
mkdir -v $MLFS/tools | ||
ln -sv $MLFS/cross-tools / | ||
ln -sv $MLFS/tools / | ||
|
||
groupadd mlfs | ||
useradd -s /bin/bash -g mlfs -m -k /dev/null mlfs | ||
passwd mlfs | ||
|
||
chown -v mlfs $MLFS/cross-tools | ||
chown -v mlfs $MLFS/sources | ||
chown -v mlfs $MLFS/tools | ||
|
||
# Now run as mlfs user | ||
su - mlfs | ||
|
||
cat > ~/.bash_profile << "EOF" | ||
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\n\$ ' /bin/bash | ||
EOF | ||
|
||
cat > ~/.bashrc << "EOF" | ||
set +h | ||
umask 022 | ||
MLFS=/mnt/mlfs | ||
LC_ALL=POSIX | ||
PATH=/cross-tools/bin:/tools/bin:/bin:/usr/bin | ||
export MLFS LC_ALL MLFS_TGT PATH | ||
EOF | ||
|
||
source ~/.bash_profile | ||
|
||
#CFLAGS and CXXFLAGS must not be set during the building of cross-tools. | ||
unset CFLAGS | ||
unset CXXFLAGS | ||
cat >> ~/.bashrc << EOF | ||
unset CFLAGS | ||
unset CXXFLAGS | ||
EOF | ||
|
||
#Build Variables: | ||
export MLFS_HOST="$(echo $MACHTYPE | \ | ||
sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")" | ||
export MLFS_TARGET="x86_64-linux-musl" | ||
cat >> ~/.bashrc << EOF | ||
export MLFS_HOST="${MLFS_HOST}" | ||
export MLFS_TARGET="${MLFS_TARGET}" | ||
export MLFS_ARCH=x86 | ||
export MLFS_CPU=x86-64 | ||
EOF | ||
source ~/.bashrc | ||
|
||
# the next are done as mlfs user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Cross-Tools: Kernel Headers | ||
# build & install as user mlfs | ||
|
||
make mrproper | ||
make ARCH=${MLFS_ARCH} headers_check | ||
make ARCH=${MLFS_ARCH} INSTALL_HDR_PATH=/cross-tools/${MLFS_TARGET} headers_install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Cross-Tools: Binutils | ||
# Build and install as mlfs | ||
|
||
mkdir -v build && cd build | ||
../configure \ | ||
--prefix=/cross-tools --target=${MLFS_TARGET} \ | ||
--with-sysroot=/cross-tools/${MLFS_TARGET} \ | ||
--disable-nls --disable-multilib \ | ||
--disable-werror \ | ||
--disable-ppl-version-check \ | ||
--disable-cloog-version-check \ | ||
--enable-deterministic-archives \ | ||
--disable-compressed-debug-sections | ||
make configure-host | ||
make && make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Cross-Tools: GCC STATIC | ||
# Build and install as mlfs | ||
|
||
tar -xf ../mpfr-4.0.1.tar.xz | ||
mv -v mpfr-4.0.1 mpfr | ||
tar -xf ../gmp-6.1.2.tar.xz | ||
mv -v gmp-6.1.2 gmp | ||
tar -xf ../mpc-1.1.0.tar.gz | ||
mv -v mpc-1.1.0 mpc | ||
mkdir -v build && cd build | ||
../configure \ | ||
--prefix=/cross-tools --build=${MLFS_HOST} \ | ||
--host=${MLFS_HOST} --target=${MLFS_TARGET} \ | ||
--with-sysroot=/cross-tools/${MLFS_TARGET} \ | ||
--disable-nls --with-newlib --without-ppl \ | ||
--without-cloog --disable-libmpx \ | ||
--disable-libitm --disable-libvtv \ | ||
--disable-libssp --disable-shared \ | ||
--disable-libgomp --without-headers \ | ||
--disable-threads --disable-multilib \ | ||
--disable-libatomic --disable-libstdcxx \ | ||
--disable-libmudflap --disable-libcilkrts \ | ||
--enable-languages=c --disable-libquadmath \ | ||
--disable-libsanitizer --with-arch=${MLFS_CPU} \ | ||
--disable-decimal-float --enable-clocale=generic \ | ||
--disable-gnu-indirect-function | ||
make all-gcc all-target-libgcc | ||
make install-gcc install-target-libgcc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Cross-Tools: Musl | ||
# Build and install as mlfs | ||
|
||
./configure \ | ||
CROSS_COMPILE=${MLFS_TARGET}- \ | ||
--prefix=/ \ | ||
--target=${MLFS_TARGET} | ||
make && DESTDIR=/cross-tools make install | ||
mkdir -v /cross-tools/usr | ||
ln -sv ../include /cross-tools/usr/include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Cross-Tools: GCC-8.2.0 Final | ||
# Build and install as mlfs | ||
|
||
tar -xf ../mpfr-4.0.1.tar.xz | ||
mv -v mpfr-4.0.1 mpfr | ||
tar -xf ../gmp-6.1.2.tar.xz | ||
mv -v gmp-6.1.2 gmp | ||
tar -xf ../mpc-1.1.0.tar.gz | ||
mv -v mpc-1.1.0 mpc | ||
|
||
# Apply patches [from void-linux] | ||
patch -Np0 -i ../gcc-8.2.0-void-0016-invalid_tls_model.diff | ||
patch -Np0 -i ../gcc-8.2.0-void-fix-cxxflags-passing.patch | ||
patch -Np0 -i ../gcc-8.2.0-void-fix-musl-execinfo.patch | ||
patch -Np0 -i ../gcc-8.2.0-void-no-stack_chk_fail_local.patch | ||
|
||
mkdir build && cd build | ||
AR=ar LDFLAGS="-Wl,-rpath,/cross-tools/lib" \ | ||
../configure \ | ||
--prefix=/cross-tools \ | ||
--build=${MLFS_HOST} \ | ||
--host=${MLFS_HOST} \ | ||
--target=${MLFS_TARGET} \ | ||
--disable-multilib \ | ||
--with-sysroot=/cross-tools \ | ||
--disable-nls \ | ||
--enable-shared \ | ||
--enable-languages=c,c++ \ | ||
--enable-__cxa_atexit \ | ||
--enable-c99 \ | ||
--enable-long-long \ | ||
--enable-threads=posix \ | ||
--enable-clocale=generic \ | ||
--enable-libstdcxx-time \ | ||
--enable-checking=release \ | ||
--enable-fully-dynamic-string \ | ||
--disable-symvers \ | ||
--disable-gnu-indirect-function \ | ||
--disable-libmudflap \ | ||
--disable-libsanitizer \ | ||
--disable-libmpx \ | ||
--disable-lto-plugin \ | ||
--disable-libssp | ||
|
||
make AS_FOR_TARGET="${MLFS_TARGET}-as" \ | ||
LD_FOR_TARGET="${MLFS_TARGET}-ld" | ||
|
||
make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Cross-Tools: File | ||
# Build and install as mlfs | ||
|
||
./configure --prefix=/cross-tools | ||
make && make install | ||
|
||
# Optional: Backup cross-tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Tool Chain: Binutils PASS 1 of 2 | ||
# Build and install as mlfs | ||
|
||
export CC="${MLFS_TARGET}-gcc" | ||
export CXX="${MLFS_TARGET}-g++" | ||
export AR="${MLFS_TARGET}-ar" | ||
export AS="${MLFS_TARGET}-as" | ||
export RANLIB="${MLFS_TARGET}-ranlib" | ||
export LD="${MLFS_TARGET}-ld" | ||
export STRIP="${MLFS_TARGET}-strip" | ||
|
||
mkdir -v build && cd build | ||
../configure --prefix=/tools \ | ||
--with-sysroot=$MLFS \ | ||
--with-lib-path=/tools/lib \ | ||
--build=${MLFS_HOST} \ | ||
--host=${MLFS_TARGET} \ | ||
--target=${MLFS_TARGET} \ | ||
--disable-nls \ | ||
--disable-werror | ||
|
||
make && make install | ||
|
||
make -C ld clean | ||
make -C ld LIB_PATH=/tools/lib | ||
cp -v ld/ld-new /tools/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Tool Chain: GCC-8.2.0 PASS 1 of 2 | ||
# Build and install as mlfs | ||
|
||
export CC="${MLFS_TARGET}-gcc" | ||
export CXX="${MLFS_TARGET}-g++" | ||
export AR="${MLFS_TARGET}-ar" | ||
export AS="${MLFS_TARGET}-as" | ||
export RANLIB="${MLFS_TARGET}-ranlib" | ||
export LD="${MLFS_TARGET}-ld" | ||
export STRIP="${MLFS_TARGET}-strip" | ||
|
||
tar -xf ../mpfr-4.0.1.tar.xz | ||
mv -v mpfr-4.0.1 mpfr | ||
tar -xf ../gmp-6.1.2.tar.xz | ||
mv -v gmp-6.1.2 gmp | ||
tar -xf ../mpc-1.1.0.tar.gz | ||
mv -v mpc-1.1.0 mpc | ||
|
||
patch -Np0 -i ../gcc-8.2.0-void-0016-invalid_tls_model.diff | ||
patch -Np0 -i ../gcc-8.2.0-void-fix-cxxflags-passing.patch | ||
patch -Np0 -i ../gcc-8.2.0-void-fix-musl-execinfo.patch | ||
patch -Np0 -i ../gcc-8.2.0-void-no-stack_chk_fail_local.patch | ||
|
||
|
||
#change the location of GCC's default dynamic linker to use the one installed in /tools | ||
for file in gcc/config/{linux,i386/linux{,64}}.h | ||
do | ||
cp -uv $file{,.orig} | ||
sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ | ||
-e 's@/usr@/tools@g' $file.orig > $file | ||
echo ' | ||
#undef STANDARD_STARTFILE_PREFIX_1 | ||
#undef STANDARD_STARTFILE_PREFIX_2 | ||
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" | ||
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file | ||
touch $file.orig | ||
done | ||
|
||
case $(uname -m) in | ||
x86_64) | ||
sed -e '/m64=/s/lib64/lib/' \ | ||
-i.orig gcc/config/i386/t-linux64 | ||
;; | ||
esac | ||
|
||
mkdir -v build && cd build | ||
../configure \ | ||
--target=${MLFS_TARGET} \ | ||
--build=${MLFS_HOST} \ | ||
--host=${MLFS_TARGET} \ | ||
--prefix=/tools \ | ||
--with-sysroot=$MLFS \ | ||
--with-newlib \ | ||
--without-headers \ | ||
--with-local-prefix=/tools \ | ||
--with-native-system-header-dir=/tools/include \ | ||
--disable-nls \ | ||
--disable-shared \ | ||
--disable-multilib \ | ||
--disable-threads \ | ||
--disable-libatomic \ | ||
--disable-libgomp \ | ||
--disable-libmpx \ | ||
--disable-libquadmath \ | ||
--disable-libssp \ | ||
--disable-libvtv \ | ||
--disable-libstdcxx \ | ||
--enable-languages=c,c++ \ | ||
--disable-libstdcxx-pch \ | ||
--disable-symvers \ | ||
--disable-libitm \ | ||
--disable-gnu-indirect-function \ | ||
--disable-libmudflap \ | ||
--disable-libsanitizer \ | ||
--disable-libcilkrts | ||
## Will not build unless $PATH is switched from /cross-tools/bin:/tools/bin:/bin:/usr/bin to | ||
## /bin:/usr/bin:/cross-tools/bin:/tools/bin | ||
export PATH=/bin:/usr/bin:/cross-tools/bin:/tools/bin | ||
make && make install | ||
|
||
export PATH=/cross-tools/bin:/tools/bin:/bin:/usr/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Tool Chain: Kernel Headers | ||
# Build and install as mlfs | ||
|
||
make mrproper | ||
|
||
PATH=/bin:/usr/bin:/cross-tools/bin:/tools/bin \ | ||
MLFS_ARCH=x86 make INSTALL_HDR_PATH=dest headers_install | ||
find dest/include \( -name .install -o -name ..install.cmd \) -delete | ||
|
||
#If not present | ||
#mkdir -v /tools/include | ||
cp -rv dest/include/* /tools/include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Tool Chain: Adjust Tool Chain | ||
# Edit as mlfs | ||
|
||
mv -v /tools/bin/{ld,ld-old} | ||
mv -v /tools/$(${MLFS_TARGET}-gcc -dumpmachine)/bin/{ld,ld-old} | ||
mv -v /tools/bin/{ld-new,ld} | ||
ln -sv /tools/bin/ld /tools/$(${MLFS_TARGET}-gcc -dumpmachine)/bin/ld | ||
|
||
SPECFILE=`dirname $(${MLFS_TARGET}-gcc -print-libgcc-file-name)`/specs && | ||
${MLFS_TARGET}-gcc -dumpspecs > tempspecfile | ||
#modify file for every /lib/ld-musl-x86_64.so.1 to /tools/lib/ld-musl-x86_64.so.1 | ||
mv -vf tempspecfile $SPECFILE && | ||
unset SPECFILE | ||
|
||
GCC_INCLUDEDIR=`dirname $(${MLFS_TARGET}-gcc -print-libgcc-file-name)`/include && | ||
find ${GCC_INCLUDEDIR}/* -maxdepth 0 -xtype d -exec rm -rvf '{}' \; && | ||
rm -vf `grep -l "DO NOT EDIT THIS FILE" ${GCC_INCLUDEDIR}/*` && | ||
unset GCC_INCLUDEDIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Tool Chain: Musl | ||
# Build and install as mlfs | ||
|
||
./configure \ | ||
CROSS_COMPILE=${MLFS_TARGET}- \ | ||
--prefix=/ \ | ||
--target=${MLFS_TARGET} | ||
make && make DESTDIR=/tools install | ||
|
||
#make sure symlink is valid: /tools/lib/ld-musl-x86_64.so.1 to /tools/lib/libc.so | ||
rm -v /tools/lib/ld-musl-x86_64.so.1 | ||
ln -sv libc.so /tools/lib/ld-musl-x86_64.so.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Tool Chain: Libstdc++ 8.2.0 | ||
# Build and install as mlfs | ||
|
||
export CC="${MLFS_TARGET}-gcc" | ||
export CXX="${MLFS_TARGET}-g++" | ||
export AR="${MLFS_TARGET}-ar" | ||
export AS="${MLFS_TARGET}-as" | ||
export RANLIB="${MLFS_TARGET}-ranlib" | ||
export LD="${MLFS_TARGET}-ld" | ||
export STRIP="${MLFS_TARGET}-strip" | ||
|
||
# Apply patches [from void-linux] | ||
patch -Np0 -i ../gcc-8.2.0-void-0016-invalid_tls_model.diff | ||
patch -Np0 -i ../gcc-8.2.0-void-fix-cxxflags-passing.patch | ||
patch -Np0 -i ../gcc-8.2.0-void-fix-musl-execinfo.patch | ||
patch -Np0 -i ../gcc-8.2.0-void-no-stack_chk_fail_local.patch | ||
|
||
mkdir -v build && cd build | ||
../libstdc++-v3/configure \ | ||
--target=${MLFS_TARGET} \ | ||
--build=${MLFS_HOST} \ | ||
--host=${MLFS_TARGET} \ | ||
--prefix=/tools \ | ||
--disable-multilib \ | ||
--disable-nls \ | ||
--disable-libstdcxx-threads \ | ||
--disable-libstdcxx-pch \ | ||
--with-gxx-include-dir=/tools/${MLFS_TARGET}/include/c++/8.2.0 | ||
|
||
make && make install |