-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild-libstdc++
executable file
·70 lines (57 loc) · 2.1 KB
/
build-libstdc++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
set -e
GCC_VERSION=gcc-12.2.0
NEWLIB_VERSION=newlib-4.2.0.20211231
NEWLIB_INCLUDES=$PWD/build/$NEWLIB_VERSION/newlib/libc/include
JOBS=$(nproc --all)
OUT_DIR_NOPIC=$PWD/no-pic
OUT_DIR_PIC=$PWD/pic
mkdir -p $OUT_DIR_NOPIC
mkdir -p $OUT_DIR_PIC
LIBSTDCXX_FLAGS="--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-libssp \
--disable-libstdcxx-pch \
--disable-nls \
--disable-shared \
--disable-threads \
--disable-tls \
--disable-plugin \
--disable-libstdcxx-verbose \
--with-gnu-as \
--with-gnu-ld \
--with-newlib \
--with-headers \
--enable-languages=c,c++ \
--with-cpu=cortex-m7 \
--with-mode=thumb \
--with-float=hard"
mkdir -p build
cd build
wget -nc ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/$GCC_VERSION/$GCC_VERSION.tar.xz
tar --skip-old-files -xaf $GCC_VERSION.tar.xz
cd $GCC_VERSION
mkdir -p build
cd build
../configure --target=arm-none-eabi \
$LIBSTDCXX_FLAGS \
CFLAGS_FOR_TARGET="-g -Os -ffunction-sections -fdata-sections -fno-exceptions -isystem $NEWLIB_INCLUDES" \
CXXFLAGS_FOR_TARGET="-g -Os -ffunction-sections -fdata-sections -fno-exceptions -isystem $NEWLIB_INCLUDES"
make -j $JOBS
cp arm-none-eabi/libgcc/libgcc.a $OUT_DIR_NOPIC
cp arm-none-eabi/libstdc++-v3/src/.libs/libstdc++.a $OUT_DIR_NOPIC/libstdc++_nano.a
cp arm-none-eabi/libstdc++-v3/libsupc++/.libs/libsupc++.a $OUT_DIR_NOPIC/libsupc++_nano.a
cd ..
mkdir -p build-pic
cd build-pic
../configure --target=arm-none-eabi \
$LIBSTDCXX_FLAGS \
CFLAGS_FOR_TARGET="-g -Os -ffunction-sections -fdata-sections -fno-exceptions -fPIC -mno-pic-data-is-text-relative -mno-single-pic-base -isystem $NEWLIB_INCLUDES" \
CXXFLAGS_FOR_TARGET="-g -Os -ffunction-sections -fdata-sections -fno-exceptions -fPIC -mno-pic-data-is-text-relative -mno-single-pic-base -isystem $NEWLIB_INCLUDES"
make -j $JOBS
cp arm-none-eabi/libgcc/libgcc.a $OUT_DIR_PIC
cp arm-none-eabi/libstdc++-v3/src/.libs/libstdc++.a $OUT_DIR_PIC/libstdc++_nano.a
cp arm-none-eabi/libstdc++-v3/libsupc++/.libs/libsupc++.a $OUT_DIR_PIC/libsupc++_nano.a