Upgrade bundled clang+llvm to 5.0.0, fixes #41

This commit is contained in:
Fangrui Song 2017-11-26 14:43:59 -08:00 committed by Jacob Dufault
parent 2b54296992
commit 7df44f75a7

50
wscript
View File

@ -7,11 +7,11 @@ except ImportError:
from urllib.request import urlopen # Python 3
import os.path
from subprocess import call
import subprocess
import sys
VERSION='0.0.1'
APPNAME='indexer'
VERSION = '0.0.1'
APPNAME = 'cquery'
top = '.'
out = 'build'
@ -21,40 +21,27 @@ out = 'build'
# http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu16.04.tar.xz
# http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz
# http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-x86_64-apple-darwin.tar.xz
# TODO: windows support (it's an exe!)
global CLANG_PLATFORM_NAME
global CLANG_TARBALL_PLATFORM_NAME
# Version of clang to download and use.
CLANG_VERSION = '5.0.0'
if sys.platform == 'linux' or sys.platform == 'linux2':
#CLANG_PLATFORM_NAME = 'linux-x86_64-ubuntu14.04'
CLANG_PLATFORM_NAME = 'x86_64-linux-gnu-ubuntu-14.04'
CLANG_TARBALL_PLATFORM_NAME = 'clang+llvm'
elif sys.platform == 'darwin':
CLANG_PLATFORM_NAME = 'x86_64-apple-darwin'
CLANG_TARBALL_PLATFORM_NAME = 'clang+llvm'
if sys.platform == 'darwin':
CLANG_TARBALL_NAME = 'clang+llvm-{0}-x86_64-apple-darwin'.format(CLANG_VERSION)
elif sys.platform.startswith('freebsd'):
CLANG_TARBALL_NAME = 'clang+llvm-{0}-amd64-unknown-freebsd10'.format(CLANG_VERSION)
# It is either 'linux2' or 'linux3' before Python 3.3
elif sys.platform.startswith('linux'):
# These executable depend on libtinfo.so.5
CLANG_TARBALL_NAME = 'clang+llvm-{0}-linux-x86_64-ubuntu14.04'.format(CLANG_VERSION)
else:
# TODO: windows support (it's an exe!)
sys.stderr.write('ERROR: Unknown platform {0}\n'.format(sys.platform))
sys.exit(1)
# Version of clang to download and use.
#CLANG_VERSION = '5.0.0'
CLANG_VERSION = '4.0.0'
# Tarball name on clang servers that should be used.
CLANG_TARBALL_NAME = '{0}-{1}-{2}'.format(CLANG_TARBALL_PLATFORM_NAME, CLANG_VERSION, CLANG_PLATFORM_NAME)
# Directory clang has been extracted to.
CLANG_DIRECTORY = '{0}/{1}'.format(out, CLANG_TARBALL_NAME)
# URL of the tarball to download.
CLANG_TARBALL_URL = 'http://releases.llvm.org/{0}/{1}.tar.xz'.format(CLANG_VERSION, CLANG_TARBALL_NAME)
# Path to locally tarball.
CLANG_TARBALL_LOCAL_PATH = '{0}.tar.xz'.format(CLANG_DIRECTORY)
# Directory libcxx will be extracted to.
LIBCXX_DIRECTORY = '{0}/libcxx'.format(out)
# URL to download libcxx from.
LIBCXX_URL = 'http://releases.llvm.org/4.0.0/libcxx-4.0.0.src.tar.xz'
# Absolute path for where to download the URL.
LIBCXX_LOCAL_PATH = '{0}/libcxx-4.0.0.src.tar.xz'.format(out)
from waflib.Tools.compiler_cxx import cxx_compiler
cxx_compiler['linux'] = ['clang++', 'g++']
@ -69,7 +56,8 @@ def options(opt):
grp.add_option('--clang-prefix', dest='clang_prefix', default='',
help='enable fallback configuration method by specifying a clang installation prefix (e.g. /opt/llvm)')
def download_and_extract(destdir, dest, url):
def download_and_extract(destdir, url):
dest = destdir + '.tar.xz'
# Download and save the compressed tarball as |compressed_file_name|.
if not os.path.isfile(dest):
print('Downloading tarball')
@ -86,7 +74,7 @@ def download_and_extract(destdir, dest, url):
if not os.path.isdir(destdir):
print('Extracting')
# TODO: make portable.
call(['tar', 'xf', dest, '-C', out])
subprocess.call(['tar', '-x', '-C', out, '-f', dest])
else:
print('Found extracted at {0}'.format(destdir))
@ -126,7 +114,7 @@ def configure(conf):
else:
print('Checking for clang')
download_and_extract(CLANG_DIRECTORY, CLANG_TARBALL_LOCAL_PATH, CLANG_TARBALL_URL)
download_and_extract(CLANG_DIRECTORY, CLANG_TARBALL_URL)
clang_node = conf.path.find_dir(CLANG_DIRECTORY)
conf.check_cxx(uselib_store='clang',
@ -165,7 +153,7 @@ def build(bld):
cc_files = bld.path.ant_glob(['src/*.cc'])
lib = []
if sys.platform == 'linux' or sys.platform == 'linux2':
if sys.platform.startswith('linux'):
lib.append('rt')
lib.append('pthread')
lib.append('dl')