Skip to content

Commit

Permalink
Partial revert of mips64 toolchain for 32-bit.
Browse files Browse the repository at this point in the history
https://android-review.googlesource.com/c/247064/

We need to drop this because neither Clang nor GCC is able to
correctly find the gnustl headers if only the 32-bit ones are present.

This might be worth revisiting at some point, but for now I'm just
moving standalone toolchains back to the 32-bit toolchain to get
things back into working condition. This change is working fine for
cmake and ndk-build though, so it's only a partial revert.

Tests are in the next commit so we don't accidentally revert the
tests if we revisit this.

Test: ./validate.py --filter standalone_toolchain_gnustl*
Bug: android/ndk#310
Change-Id: I2df811c5a67db9a64d3d352e08d60f660e075012
  • Loading branch information
DanAlbert committed Mar 7, 2017
1 parent 69b99f3 commit 40d8abb
Showing 1 changed file with 10 additions and 32 deletions.
42 changes: 10 additions & 32 deletions build/tools/make_standalone_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ def check_ndk_or_die():

def get_triple(arch):
"""Return the triple for the given architecture."""
# Use same GCC toolchain for both mips arches.
return {
'arm': 'arm-linux-androideabi',
'arm64': 'aarch64-linux-android',
'mips': 'mips64el-linux-android',
'mips': 'mipsel-linux-android',
'mips64': 'mips64el-linux-android',
'x86': 'i686-linux-android',
'x86_64': 'x86_64-linux-android',
Expand All @@ -81,18 +80,6 @@ def get_abis(arch):
}[arch]


def get_dst_dir(arch):
"""Return directory for the given architecture."""
return {
'arm': 'arm-linux-androideabi',
'arm64': 'aarch64-linux-android',
'mips': 'mipsel-linux-android',
'mips64': 'mips64el-linux-android',
'x86': 'i686-linux-android',
'x86_64': 'x86_64-linux-android',
}[arch]


def get_host_tag_or_die():
"""Return the host tag for this platform. Die if not supported."""
if platform.system() == 'Linux':
Expand Down Expand Up @@ -130,7 +117,7 @@ def get_gcc_path_or_die(arch, host_tag):
toolchain = {
'arm': 'arm-linux-androideabi',
'arm64': 'aarch64-linux-android',
'mips': 'mips64el-linux-android',
'mips': 'mipsel-linux-android',
'mips64': 'mips64el-linux-android',
'x86': 'x86',
'x86_64': 'x86_64',
Expand Down Expand Up @@ -193,8 +180,7 @@ def copy_directory_contents(src, dst):
shutil.copy2(src_file, dst_dir)


def make_clang_scripts(install_dir, target_arch, triple, api, windows,
unified_headers):
def make_clang_scripts(install_dir, triple, api, windows, unified_headers):
"""Creates Clang wrapper scripts.
The Clang in standalone toolchains historically was designed to be used as
Expand Down Expand Up @@ -222,20 +208,12 @@ def make_clang_scripts(install_dir, target_arch, triple, api, windows,
os.path.join(bin_dir, 'clang{}++'.format(
version_number) + exe))

extra_flags = ''
arch, os_name, env = triple.split('-')
if arch == 'arm':
arch = 'armv7a' # Target armv7, not armv5.
elif arch == 'mips64el' and target_arch == 'mips':
arch = 'mipsel'
extra_flags = ' -mips32' # Target mips32 on mips64el compiler
# Help clang use mips64el multilib GCC
mips_gcc_libpath = 'lib/gcc/mips64el-linux-android/4.9.x/32/mips-r1/'
extra_flags += ' -L`dirname $0`/../' + mips_gcc_libpath

target = '-'.join([arch, 'none', os_name, env])
flags = '-target {}{} --sysroot `dirname $0`/../sysroot'.format(
target, extra_flags)
flags = '-target {} --sysroot `dirname $0`/../sysroot'.format(target)

if unified_headers:
flags += ' -D__ANDROID_API__={}'.format(api)
Expand Down Expand Up @@ -313,7 +291,7 @@ def make_clang_scripts(install_dir, target_arch, triple, api, windows,
os.path.join(install_dir, 'bin', triple + '-clang++.cmd'))


def copy_gnustl_abi_headers(src_dir, dst_dir, gcc_ver, arch, abi,
def copy_gnustl_abi_headers(src_dir, dst_dir, gcc_ver, triple, abi,
thumb=False):
"""Copy the ABI specific headers for gnustl."""
abi_src_dir = os.path.join(
Expand All @@ -327,7 +305,7 @@ def copy_gnustl_abi_headers(src_dir, dst_dir, gcc_ver, arch, abi,
if abi == 'armeabi-v7a':
bits_dst_dir = os.path.join('armv7-a', bits_dst_dir)
abi_dst_dir = os.path.join(
dst_dir, 'include/c++', gcc_ver, get_dst_dir(arch), bits_dst_dir)
dst_dir, 'include/c++', gcc_ver, triple, bits_dst_dir)

shutil.copytree(abi_src_dir, abi_dst_dir)

Expand Down Expand Up @@ -389,7 +367,7 @@ def create_toolchain(install_path, arch, api, gcc_path, clang_path,
copy_directory_contents(clang_path, install_path)
triple = get_triple(arch)
make_clang_scripts(
install_path, arch, triple, api, host_tag.startswith('windows'),
install_path, triple, api, host_tag.startswith('windows'),
unified_headers)

if unified_headers:
Expand Down Expand Up @@ -438,12 +416,12 @@ def create_toolchain(install_path, arch, api, gcc_path, clang_path,
shutil.copytree(os.path.join(gnustl_dir, 'include'), cxx_headers)

for abi in get_abis(arch):
copy_gnustl_abi_headers(gnustl_dir, install_path, gcc_ver, arch,
copy_gnustl_abi_headers(gnustl_dir, install_path, gcc_ver, triple,
abi)
copy_gnustl_libs(gnustl_dir, install_path, triple, abi)
if arch == 'arm':
copy_gnustl_abi_headers(gnustl_dir, install_path, gcc_ver,
arch, abi, thumb=True)
triple, abi, thumb=True)
elif stl == 'libc++':
libcxx_dir = os.path.join(NDK_DIR, 'sources/cxx-stl/llvm-libc++')
libcxxabi_dir = os.path.join(NDK_DIR, 'sources/cxx-stl/llvm-libc++abi')
Expand Down Expand Up @@ -536,7 +514,7 @@ def create_toolchain(install_path, arch, api, gcc_path, clang_path,

# Not needed for every STL, but the old one does this. Keep it for the sake
# of diff. Done at the end so copytree works.
cxx_target_headers = os.path.join(cxx_headers, get_dst_dir(arch))
cxx_target_headers = os.path.join(cxx_headers, triple)
if not os.path.exists(cxx_target_headers):
os.makedirs(cxx_target_headers)

Expand Down

0 comments on commit 40d8abb

Please sign in to comment.