Skip to content

Commit 3c5fe89

Browse files
committed
Updated first batch of instructions for x86_64.
1 parent 516eb9c commit 3c5fe89

13 files changed

Lines changed: 353 additions & 0 deletions
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# perform as root:
2+
export MLFS=/mnt/mlfs
3+
mkdir -pv $MLFS
4+
mkdir -v $MLFS/sources
5+
chmod -v a+wt $MLFS/sources
6+
7+
#download sources + patches
8+
9+
mkdir -v $MLFS/cross-tools
10+
mkdir -v $MLFS/tools
11+
ln -sv $MLFS/cross-tools /
12+
ln -sv $MLFS/tools /
13+
14+
groupadd mlfs
15+
useradd -s /bin/bash -g mlfs -m -k /dev/null mlfs
16+
passwd mlfs
17+
18+
chown -v mlfs $MLFS/cross-tools
19+
chown -v mlfs $MLFS/sources
20+
chown -v mlfs $MLFS/tools
21+
22+
# Now run as mlfs user
23+
su - mlfs
24+
25+
cat > ~/.bash_profile << "EOF"
26+
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\n\$ ' /bin/bash
27+
EOF
28+
29+
cat > ~/.bashrc << "EOF"
30+
set +h
31+
umask 022
32+
MLFS=/mnt/mlfs
33+
LC_ALL=POSIX
34+
PATH=/cross-tools/bin:/tools/bin:/bin:/usr/bin
35+
export MLFS LC_ALL MLFS_TGT PATH
36+
EOF
37+
38+
source ~/.bash_profile
39+
40+
#CFLAGS and CXXFLAGS must not be set during the building of cross-tools.
41+
unset CFLAGS
42+
unset CXXFLAGS
43+
cat >> ~/.bashrc << EOF
44+
unset CFLAGS
45+
unset CXXFLAGS
46+
EOF
47+
48+
#Build Variables:
49+
export MLFS_HOST="$(echo $MACHTYPE | \
50+
sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
51+
export MLFS_TARGET="x86_64-linux-musl"
52+
cat >> ~/.bashrc << EOF
53+
export MLFS_HOST="${MLFS_HOST}"
54+
export MLFS_TARGET="${MLFS_TARGET}"
55+
export MLFS_ARCH=x86
56+
export MLFS_CPU=x86-64
57+
EOF
58+
source ~/.bashrc
59+
60+
# the next are done as mlfs user
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Cross-Tools: Kernel Headers
2+
# build & install as user mlfs
3+
4+
make mrproper
5+
make ARCH=${MLFS_ARCH} headers_check
6+
make ARCH=${MLFS_ARCH} INSTALL_HDR_PATH=/cross-tools/${MLFS_TARGET} headers_install
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Cross-Tools: Binutils
2+
# Build and install as mlfs
3+
4+
mkdir -v build && cd build
5+
../configure \
6+
--prefix=/cross-tools --target=${MLFS_TARGET} \
7+
--with-sysroot=/cross-tools/${MLFS_TARGET} \
8+
--disable-nls --disable-multilib \
9+
--disable-werror \
10+
--disable-ppl-version-check \
11+
--disable-cloog-version-check \
12+
--enable-deterministic-archives \
13+
--disable-compressed-debug-sections
14+
make configure-host
15+
make && make install
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Cross-Tools: GCC STATIC
2+
# Build and install as mlfs
3+
4+
tar -xf ../mpfr-4.0.1.tar.xz
5+
mv -v mpfr-4.0.1 mpfr
6+
tar -xf ../gmp-6.1.2.tar.xz
7+
mv -v gmp-6.1.2 gmp
8+
tar -xf ../mpc-1.1.0.tar.gz
9+
mv -v mpc-1.1.0 mpc
10+
mkdir -v build && cd build
11+
../configure \
12+
--prefix=/cross-tools --build=${MLFS_HOST} \
13+
--host=${MLFS_HOST} --target=${MLFS_TARGET} \
14+
--with-sysroot=/cross-tools/${MLFS_TARGET} \
15+
--disable-nls --with-newlib --without-ppl \
16+
--without-cloog --disable-libmpx \
17+
--disable-libitm --disable-libvtv \
18+
--disable-libssp --disable-shared \
19+
--disable-libgomp --without-headers \
20+
--disable-threads --disable-multilib \
21+
--disable-libatomic --disable-libstdcxx \
22+
--disable-libmudflap --disable-libcilkrts \
23+
--enable-languages=c --disable-libquadmath \
24+
--disable-libsanitizer --with-arch=${MLFS_CPU} \
25+
--disable-decimal-float --enable-clocale=generic \
26+
--disable-gnu-indirect-function
27+
make all-gcc all-target-libgcc
28+
make install-gcc install-target-libgcc
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Cross-Tools: Musl
2+
# Build and install as mlfs
3+
4+
./configure \
5+
CROSS_COMPILE=${MLFS_TARGET}- \
6+
--prefix=/ \
7+
--target=${MLFS_TARGET}
8+
make && DESTDIR=/cross-tools make install
9+
mkdir -v /cross-tools/usr
10+
ln -sv ../include /cross-tools/usr/include
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Cross-Tools: GCC-8.2.0 Final
2+
# Build and install as mlfs
3+
4+
tar -xf ../mpfr-4.0.1.tar.xz
5+
mv -v mpfr-4.0.1 mpfr
6+
tar -xf ../gmp-6.1.2.tar.xz
7+
mv -v gmp-6.1.2 gmp
8+
tar -xf ../mpc-1.1.0.tar.gz
9+
mv -v mpc-1.1.0 mpc
10+
11+
# Apply patches [from void-linux]
12+
patch -Np0 -i ../gcc-8.2.0-void-0016-invalid_tls_model.diff
13+
patch -Np0 -i ../gcc-8.2.0-void-fix-cxxflags-passing.patch
14+
patch -Np0 -i ../gcc-8.2.0-void-fix-musl-execinfo.patch
15+
patch -Np0 -i ../gcc-8.2.0-void-no-stack_chk_fail_local.patch
16+
17+
mkdir build && cd build
18+
AR=ar LDFLAGS="-Wl,-rpath,/cross-tools/lib" \
19+
../configure \
20+
--prefix=/cross-tools \
21+
--build=${MLFS_HOST} \
22+
--host=${MLFS_HOST} \
23+
--target=${MLFS_TARGET} \
24+
--disable-multilib \
25+
--with-sysroot=/cross-tools \
26+
--disable-nls \
27+
--enable-shared \
28+
--enable-languages=c,c++ \
29+
--enable-__cxa_atexit \
30+
--enable-c99 \
31+
--enable-long-long \
32+
--enable-threads=posix \
33+
--enable-clocale=generic \
34+
--enable-libstdcxx-time \
35+
--enable-checking=release \
36+
--enable-fully-dynamic-string \
37+
--disable-symvers \
38+
--disable-gnu-indirect-function \
39+
--disable-libmudflap \
40+
--disable-libsanitizer \
41+
--disable-libmpx \
42+
--disable-lto-plugin \
43+
--disable-libssp
44+
45+
make AS_FOR_TARGET="${MLFS_TARGET}-as" \
46+
LD_FOR_TARGET="${MLFS_TARGET}-ld"
47+
48+
make install
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Cross-Tools: File
2+
# Build and install as mlfs
3+
4+
./configure --prefix=/cross-tools
5+
make && make install
6+
7+
# Optional: Backup cross-tools
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Tool Chain: Binutils PASS 1 of 2
2+
# Build and install as mlfs
3+
4+
export CC="${MLFS_TARGET}-gcc"
5+
export CXX="${MLFS_TARGET}-g++"
6+
export AR="${MLFS_TARGET}-ar"
7+
export AS="${MLFS_TARGET}-as"
8+
export RANLIB="${MLFS_TARGET}-ranlib"
9+
export LD="${MLFS_TARGET}-ld"
10+
export STRIP="${MLFS_TARGET}-strip"
11+
12+
mkdir -v build && cd build
13+
../configure --prefix=/tools \
14+
--with-sysroot=$MLFS \
15+
--with-lib-path=/tools/lib \
16+
--build=${MLFS_HOST} \
17+
--host=${MLFS_TARGET} \
18+
--target=${MLFS_TARGET} \
19+
--disable-nls \
20+
--disable-werror
21+
22+
make && make install
23+
24+
make -C ld clean
25+
make -C ld LIB_PATH=/tools/lib
26+
cp -v ld/ld-new /tools/bin
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Tool Chain: GCC-8.2.0 PASS 1 of 2
2+
# Build and install as mlfs
3+
4+
export CC="${MLFS_TARGET}-gcc"
5+
export CXX="${MLFS_TARGET}-g++"
6+
export AR="${MLFS_TARGET}-ar"
7+
export AS="${MLFS_TARGET}-as"
8+
export RANLIB="${MLFS_TARGET}-ranlib"
9+
export LD="${MLFS_TARGET}-ld"
10+
export STRIP="${MLFS_TARGET}-strip"
11+
12+
tar -xf ../mpfr-4.0.1.tar.xz
13+
mv -v mpfr-4.0.1 mpfr
14+
tar -xf ../gmp-6.1.2.tar.xz
15+
mv -v gmp-6.1.2 gmp
16+
tar -xf ../mpc-1.1.0.tar.gz
17+
mv -v mpc-1.1.0 mpc
18+
19+
patch -Np0 -i ../gcc-8.2.0-void-0016-invalid_tls_model.diff
20+
patch -Np0 -i ../gcc-8.2.0-void-fix-cxxflags-passing.patch
21+
patch -Np0 -i ../gcc-8.2.0-void-fix-musl-execinfo.patch
22+
patch -Np0 -i ../gcc-8.2.0-void-no-stack_chk_fail_local.patch
23+
24+
25+
#change the location of GCC's default dynamic linker to use the one installed in /tools
26+
for file in gcc/config/{linux,i386/linux{,64}}.h
27+
do
28+
cp -uv $file{,.orig}
29+
sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
30+
-e 's@/usr@/tools@g' $file.orig > $file
31+
echo '
32+
#undef STANDARD_STARTFILE_PREFIX_1
33+
#undef STANDARD_STARTFILE_PREFIX_2
34+
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
35+
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
36+
touch $file.orig
37+
done
38+
39+
case $(uname -m) in
40+
x86_64)
41+
sed -e '/m64=/s/lib64/lib/' \
42+
-i.orig gcc/config/i386/t-linux64
43+
;;
44+
esac
45+
46+
mkdir -v build && cd build
47+
../configure \
48+
--target=${MLFS_TARGET} \
49+
--build=${MLFS_HOST} \
50+
--host=${MLFS_TARGET} \
51+
--prefix=/tools \
52+
--with-sysroot=$MLFS \
53+
--with-newlib \
54+
--without-headers \
55+
--with-local-prefix=/tools \
56+
--with-native-system-header-dir=/tools/include \
57+
--disable-nls \
58+
--disable-shared \
59+
--disable-multilib \
60+
--disable-threads \
61+
--disable-libatomic \
62+
--disable-libgomp \
63+
--disable-libmpx \
64+
--disable-libquadmath \
65+
--disable-libssp \
66+
--disable-libvtv \
67+
--disable-libstdcxx \
68+
--enable-languages=c,c++ \
69+
--disable-libstdcxx-pch \
70+
--disable-symvers \
71+
--disable-libitm \
72+
--disable-gnu-indirect-function \
73+
--disable-libmudflap \
74+
--disable-libsanitizer \
75+
--disable-libcilkrts
76+
## Will not build unless $PATH is switched from /cross-tools/bin:/tools/bin:/bin:/usr/bin to
77+
## /bin:/usr/bin:/cross-tools/bin:/tools/bin
78+
export PATH=/bin:/usr/bin:/cross-tools/bin:/tools/bin
79+
make && make install
80+
81+
export PATH=/cross-tools/bin:/tools/bin:/bin:/usr/bin
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Tool Chain: Kernel Headers
2+
# Build and install as mlfs
3+
4+
make mrproper
5+
6+
PATH=/bin:/usr/bin:/cross-tools/bin:/tools/bin \
7+
MLFS_ARCH=x86 make INSTALL_HDR_PATH=dest headers_install
8+
find dest/include \( -name .install -o -name ..install.cmd \) -delete
9+
10+
#If not present
11+
#mkdir -v /tools/include
12+
cp -rv dest/include/* /tools/include

0 commit comments

Comments
 (0)