├── .travis.yml ├── LICENSE ├── README.md ├── build.sh └── main.mk.patch /.travis.yml: -------------------------------------------------------------------------------- 1 | before_install: 2 | - sudo apt-get install g++-multilib python2.7 3 | script: "skiputil=no ./build.sh" 4 | deploy: 5 | skip_cleanup: true 6 | provider: releases 7 | api_key: 8 | secure: uoOHapLDTkp13PAbCfSHc6kE34JZniJEi3xMAN1IHZh7Ttr2QybLNBZme1UBu1YnLqMwHPT4YuBhcBkFpFaVK5YGU8ixEG4dGtsSKNe6ZyRis8rGePPywiRf8RlXaMHsVxceTiHNG7ln8dB4E0t3hAYLMQJmK8rkjCfFVTzZv0SNtdzMAyPqVDvmQq0QPVWFJ4dxi1+xsre/63dSmYbNh8xGw+fP1dTocDW/GQyEkPujdmQdZG4sFx+UZC4Y44XQyK38Y5BO2FCY7iPm46+kwHu3q8JZXXgwD0mnMgfZW2ZE/yJSmvqPUc4Er1xboMu/XSuXK9KKLZJ76vnx3RlcUSNOVTO5/lKg4i0l+/Zb9/PwYKDfDbfaBta4HYBgJGxHPJJDZvKczYlBEQaT3qLiydHy+sYSy2CsKRCcNhZ82ulI/5ABPtH/nji+0rVkN7Z6M+w51m9BY14JyLup83GwrBUmvfSi5hikfeMWhwVDvRY5kfdSKpAFy2UjDb0M+6aC4hSEc7nzH7VnL6ZEQu9DF0WsQ6/VVXFnUuNR5BpXJsH77fJBj87x3yeottIKgDzYUsIVx6PjY6YPrgpLo3EqB1KO0Pxckey+6WzRcJ9iWVzHVJ/24wwKap0Mqfdn+w8XBO2CwBdT5bKwZeN0haf5a08M8sy19woUtYRb+4alcV0= 9 | file: bionic_x86_64_nougat-release_zlib.tar.xz 10 | on: 11 | repo: vishalbiswas/libc-bionic 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Vishal Biswas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libc-bionic 2 | This repository contains scripts to build bionic libc (used in Android) only. 3 | 4 | I was unable to find any documentation to build just bionic, which gave rise to this. 5 | 6 | Please install `python2`, `libc-dev-i386` and `g++-multilib` first. 7 | 8 | Building under Linux subsystem for Windows is not supported, yet. The subsystem cannot 9 | run 32-bit executables generated while building. 10 | 11 | Only the latest nougat-release branch is supported as of now. I'm open to pull requests 12 | adding support for older ones. As a consequence, the build system will use ninja, which 13 | is mandatory post Marshmallow releases. -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | scriptdir="$(cd "$(dirname "$0")"; pwd)" 5 | topdir="`pwd`/android_build" 6 | 7 | googlebaseurl='https://android.googlesource.com/platform' 8 | tgzbaseurl="$googlebaseurl/@SOURCE@/+archive/@BUILDREF@.tar.gz" 9 | 10 | sources=('bionic' 'libnativehelper' 'build' 'build/kati' 'system/core' 'external/jemalloc' 'external/libcxx' 'external/libcxxabi' 'external/zlib' 11 | 'external/iputils' 'external/elfutils' 'external/llvm' 'external/libunwind_llvm' 'external/compiler-rt' 'external/safe-iop' 'external/gtest') 12 | : ${buildref='nougat-release'} 13 | : ${arch:=`uname -m`} 14 | : ${usetgz:='yes'} 15 | : ${skipsrc:='no'} 16 | : ${skipindeps:='no'} 17 | : ${skipcross:='no'} 18 | # benchmarks are broken right now 19 | : ${skipbenches:='yes'} 20 | : ${skiptests:='yes'} 21 | # extra utilities like zlib, ping 22 | : ${skiputil:='yes'} 23 | ndkarch=$arch 24 | gccarch=$arch 25 | luncharch=$arch 26 | gccver=4.9 27 | 28 | abi="$arch-linux-android" 29 | 30 | case $arch in 31 | x86) abi='x86_64-linux-android'; ndkarch='x86_64';; 32 | arm) abi+='eabi';; 33 | x86_64) gccarch='x86';; 34 | aarch64) ndkarch='arm64'; luncharch='arm64';; 35 | esac 36 | 37 | clangver=3.6 38 | prebuilts=( "prebuilts/gcc/linux-x86/host/`uname -m`-linux-glibc2.15-4.8" 'prebuilts/clang/host/linux-x86' 39 | 'prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8' 'prebuilts/ninja/linux-x86') 40 | 41 | download () { 42 | echo "downloading $1" 43 | 44 | if [ -d "$topdir/$1" ] 45 | then 46 | rm -rf "$topdir/$1" 47 | fi 48 | mkdir -p "$topdir/$1" 49 | cd "$topdir/$1" 50 | 51 | if [ "$usetgz" == 'no' ] 52 | then 53 | download_from_git $@ 54 | else 55 | download_tarball $@ 56 | fi 57 | 58 | cd "$topdir" 59 | } 60 | 61 | download_from_git () { 62 | git init -q 63 | git remote add origin "$googlebaseurl/$1" 64 | git fetch --depth 1 origin "$2" -q 65 | git reset --hard FETCH_HEAD -q 66 | } 67 | 68 | download_tarball () { 69 | tarfile="/tmp/`basename $1`.tgz" 70 | curl -sL $(echo $tgzbaseurl | sed -e "s|@SOURCE@|$1|" -e "s|@BUILDREF@|$2|") -o $tarfile 71 | tar -xf $tarfile 72 | rm $tarfile 73 | } 74 | 75 | download_single_folder () { 76 | echo "downloading $1/$3" 77 | if [ -d "$topdir/$1" ] 78 | then 79 | rm -rf "$topdir/$1" 80 | fi 81 | mkdir -p "$topdir/$1/$3" 82 | cd "$topdir/$1/$3" 83 | 84 | download_tarball $1 $2/$3 85 | 86 | cd "$topdir" 87 | } 88 | 89 | if [ "$skipsrc" == 'no' ] 90 | then 91 | 92 | mkdir -p "$topdir" 93 | cd "$topdir" 94 | 95 | 96 | for source in "${sources[@]}" 97 | do 98 | _buildref="$buildref" 99 | download "$source" "$_buildref" 100 | done 101 | 102 | cd "$topdir" 103 | 104 | if [[ "$skipbenches" == 'yes' ]] 105 | then 106 | find bionic -type d -name 'benchmarks' -exec rm -r {} + 107 | else 108 | download 'external/google-benchmark' $buildref 109 | fi 110 | 111 | fi 112 | 113 | if [[ "$skiptests" == 'yes' ]] 114 | then 115 | cd "$topdir" 116 | rm -r bionic/libc/malloc_debug || true 117 | 118 | #this and some other tests are essential for build as they are in main Android.mk 119 | tests=( 'system/core/libnativebridge/tests' 'libnativehelper/tests' 'external/compiler-rt/lib/sanitizer_common/tests' 'system/core/libmincrypt/test' ) 120 | 121 | for required_test in "${tests[@]}" 122 | do 123 | mv $required_test ${required_test}1 || true 124 | done 125 | 126 | find . -type d -name 'tests' -prune -exec rm -r {} + 127 | find . -type d -name 'test' -prune -exec rm -r {} + 128 | 129 | for required_test in "${tests[@]}" 130 | do 131 | mv ${required_test}1 $required_test || true 132 | done 133 | 134 | else 135 | download 'system/extras' $buildref 136 | download 'external/tinyxml2' $buildref 137 | fi 138 | 139 | for patch in $scriptdir/*.patch 140 | do 141 | patch -f -p1 < "$patch" || true 142 | done 143 | 144 | 145 | 146 | if [ "$skipindeps" == 'no' ] 147 | then 148 | _buildref="$buildref" 149 | for tool in "${prebuilts[@]}" 150 | do 151 | download "$tool" "$_buildref" 152 | done 153 | rm -r prebuilts/misc/common/android-support-test || true 154 | 155 | 156 | if [ "$usetgz" == 'no' ] 157 | then 158 | download 'prebuilts/misc' $_buildref 159 | else 160 | download_single_folder 'prebuilts/misc' $_buildref 'linux-x86/relocation_packer' 161 | fi 162 | fi 163 | 164 | if [ "$skipcross" == 'no' ] 165 | then 166 | crossgcc="prebuilts/gcc/linux-x86/$gccarch/$abi-$gccver" 167 | download $crossgcc $buildref 168 | fi 169 | 170 | cd "$topdir" 171 | 172 | source build/envsetup.sh 173 | lunch "aosp_$ndkarch-eng" > /dev/null 174 | m clobber 175 | 176 | if [ "$skiputil" == 'no' ] 177 | then 178 | #cd "$topdir/external/zlib" 179 | m libz -j5 180 | mmm external/iputils 181 | fi 182 | 183 | #cd "$topdir/bionic" 184 | m -j5 libc libc++ libdl libm libstdc++ liblog libbase linker 185 | 186 | outdir="$topdir/out/target/product/generic" 187 | test -d "${outdir}_$ndkarch" && outdir+="_$ndkarch" 188 | 189 | cd "$outdir" 190 | if [ "$skiputil" == 'no' ] 191 | then 192 | outfile="$topdir/../bionic_${arch}_${buildref}_utils.tar.xz" 193 | else 194 | outfile="$topdir/../bionic_${arch}_${buildref}.tar.xz" 195 | fi 196 | 197 | tar -cJf "$outfile" system 198 | 199 | set +e 200 | -------------------------------------------------------------------------------- /main.mk.patch: -------------------------------------------------------------------------------- 1 | --- ./build/core/main.mk 2016-11-23 23:00:18.051392631 +0530 2 | +++ ../main.mk 2016-11-23 23:19:48.349811417 +0530 3 | @@ -58,7 +58,7 @@ 4 | BUILD_SYSTEM := $(TOPDIR)build/core 5 | 6 | # Ensure JAVA_NOT_REQUIRED is not set externally. 7 | -JAVA_NOT_REQUIRED := false 8 | +JAVA_NOT_REQUIRED := true 9 | 10 | # This is the default target. It must be the first declared target. 11 | .PHONY: droid 12 | --------------------------------------------------------------------------------