Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: tools/clang/scripts/update.py

Issue 1172363002: Revert of update.py: Check out and build libc++ libc++abi on OS X, set deployment target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/clang/scripts/update.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/scripts/update.py
diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py
index 29b185af09b93d2a9a36f8d3174b8e4ed455b897..aa74bdc37afc7500c412c5cd063524a1386874ce 100755
--- a/tools/clang/scripts/update.py
+++ b/tools/clang/scripts/update.py
@@ -52,8 +52,6 @@
CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang')
LLD_DIR = os.path.join(LLVM_DIR, 'tools', 'lld')
COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt')
-LIBCXX_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxx')
-LIBCXXABI_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxxabi')
LLVM_BUILD_TOOLS_DIR = os.path.abspath(
os.path.join(LLVM_DIR, '..', 'llvm-build-tools'))
STAMP_FILE = os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision')
@@ -102,15 +100,15 @@
def WriteStampFile(s):
"""Write s to the stamp file."""
- if not os.path.exists(os.path.dirname(STAMP_FILE)):
- os.makedirs(os.path.dirname(STAMP_FILE))
+ if not os.path.exists(LLVM_BUILD_DIR):
+ os.makedirs(LLVM_BUILD_DIR)
with open(STAMP_FILE, 'w') as f:
f.write(s)
def GetSvnRevision(svn_repo):
"""Returns current revision of the svn repo at svn_repo."""
- svn_info = subprocess.check_output('svn info ' + svn_repo, shell=True)
+ svn_info = subprocess.check_output(['svn', 'info', svn_repo], shell=True)
m = re.search(r'Revision: (\d+)', svn_info)
return m.group(1)
@@ -127,12 +125,12 @@
shutil.rmtree(dir, onerror=ChmodAndRetry)
-def RunCommand(command, env=None, fail_hard=True):
+def RunCommand(command, fail_hard=True):
"""Run command and return success (True) or failure; or if fail_hard is
True, exit on failure."""
print 'Running %s' % (str(command))
- if subprocess.call(' '.join(command), env=env, shell=True) == 0:
+ if subprocess.call(command, shell=True) == 0:
return True
print 'Failed.'
if fail_hard:
@@ -223,8 +221,7 @@
if zip_name.endswith('.zip'):
zipfile.ZipFile(f).extractall(path=LLVM_BUILD_TOOLS_DIR)
else:
- tarfile.open(mode='r:gz', fileobj=f).extractall(path=
- LLVM_BUILD_TOOLS_DIR)
+ tarfile.open(mode='r:gz', fileobj=f).extractall(path=LLVM_BUILD_DIR)
os.environ['PATH'] = cmake_dir + os.pathsep + os.environ.get('PATH', '')
vs_version = None
@@ -282,40 +279,19 @@
DeleteChromeToolsShim();
Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR)
Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR)
- if sys.platform == 'win32':
- Checkout('LLD', LLVM_REPO_URL + '/lld/trunk', LLD_DIR)
+ Checkout('LLD', LLVM_REPO_URL + '/lld/trunk', LLD_DIR)
Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR)
- if sys.platform == 'darwin':
- # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes
- # (i.e. this is needed for bootstrap builds).
- Checkout('libcxx', LLVM_REPO_URL + '/libcxx/trunk', LIBCXX_DIR)
- # While we're bundling our own libc++ on OS X, we need to compile libc++abi
- # into it too (since OS X 10.6 doesn't have libc++abi.dylib either).
- Checkout('libcxxabi', LLVM_REPO_URL + '/libcxxabi/trunk', LIBCXXABI_DIR)
-
CreateChromeToolsShim();
- cc, cxx = None, None
- cflags = cxxflags = ldflags = ''
-
- # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is
- # needed, on OS X it requires libc++. clang only automatically links to libc++
- # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run
- # on OS X versions as old as 10.7.
- # TODO(thakis): Some bots are still on 10.6 (nacl...), so for now bundle
- # libc++.dylib. Remove this once all bots are on 10.7+, then use
- # -DLLVM_ENABLE_LIBCXX=ON and change deployment_target to 10.7.
- deployment_target = ''
-
- if sys.platform == 'darwin':
- # When building on 10.9, /usr/include usually doesn't exist, and while
- # Xcode's clang automatically sets a sysroot, self-built clangs don't.
- cflags = "-isysroot " + subprocess.check_output(
- ['xcrun', '--show-sdk-path']).rstrip()
- cxxflags = '-stdlib=libc++ -nostdinc++ -I%s %s' % (
- os.path.join(LIBCXX_DIR, 'include'), cflags)
- if args.bootstrap:
- deployment_target = '10.6'
+ # If building at head, define a macro that plugins can use for #ifdefing
+ # out code that builds at head, but not at CLANG_REVISION or vice versa.
+ cflags = cxxflags = ''
+
+ # If building at head, define a macro that plugins can use for #ifdefing
+ # out code that builds at head, but not at LLVM_WIN_REVISION or vice versa.
+ if use_head_revision:
+ cflags += ' -DLLVM_FORCE_HEAD_REVISION'
+ cxxflags += ' -DLLVM_FORCE_HEAD_REVISION'
base_cmake_args = ['-GNinja',
'-DCMAKE_BUILD_TYPE=Release',
@@ -323,6 +299,7 @@
'-DLLVM_ENABLE_THREADS=OFF',
]
+ cc, cxx = None, None
if args.bootstrap:
print 'Building bootstrap compiler'
if not os.path.exists(LLVM_BOOTSTRAP_DIR):
@@ -353,60 +330,15 @@
cxx = cxx.replace('\\', '/')
print 'Building final compiler'
- if sys.platform == 'darwin':
- # Build libc++.dylib while some bots are still on OS X 10.6.
- RmTree(os.path.join(LLVM_BUILD_DIR, 'libcxxbuild'))
- libcxxflags = "-O3 -std=c++11 -fstrict-aliasing"
-
- # libcxx and libcxxabi both have a file stdexcept.cpp, so put their .o files
- # into different subdirectories.
- os.makedirs(os.path.join(LLVM_BUILD_DIR, 'libcxxbuild', 'libcxx'))
- os.chdir(os.path.join(LLVM_BUILD_DIR, 'libcxxbuild', 'libcxx'))
- RunCommand(['c++', '-c', cxxflags, libcxxflags,
- os.path.join(LIBCXX_DIR, 'src', '*.cpp')])
-
- os.makedirs(os.path.join(LLVM_BUILD_DIR, 'libcxxbuild', 'libcxxabi'))
- os.chdir(os.path.join(LLVM_BUILD_DIR, 'libcxxbuild', 'libcxxabi'))
- RunCommand(['c++', '-c', cxxflags, libcxxflags,
- os.path.join(LIBCXXABI_DIR, 'src', '*.cpp'),
- '-I' + os.path.join(LIBCXXABI_DIR, 'include')])
-
- os.chdir(os.path.join(LLVM_BUILD_DIR, 'libcxxbuild'))
- libdir = os.path.join(LIBCXX_DIR, 'lib')
- RunCommand(['cc', 'libcxx/*.o', 'libcxxabi/*.o', '-o', 'libc++.1.dylib',
- '-dynamiclib', '-nodefaultlibs', '-current_version', '1',
- '-compatibility_version', '1', '-lSystem', '-install_name',
- '@executable_path/libc++.dylib',
- '-Wl,-unexported_symbols_list,' + libdir + '/libc++unexp.exp',
- '-Wl,-force_symbols_not_weak_list,' + libdir + '/notweak.exp',
- '-Wl,-force_symbols_weak_list,' + libdir + '/weak.exp'])
- if os.path.exists('libc++.dylib'):
- os.remove('libc++.dylib')
- os.symlink('libc++.1.dylib', 'libc++.dylib')
- ldflags += '-stdlib=libc++ -L' + os.path.join(LLVM_BUILD_DIR, 'libcxxbuild')
-
# Build clang.
binutils_incdir = ''
if sys.platform.startswith('linux'):
binutils_incdir = os.path.join(BINUTILS_DIR, 'Linux_x64/Release/include')
- # If building at head, define a macro that plugins can use for #ifdefing
- # out code that builds at head, but not at LLVM_WIN_REVISION or vice versa.
- if use_head_revision:
- cflags += ' -DLLVM_FORCE_HEAD_REVISION'
- cxxflags += ' -DLLVM_FORCE_HEAD_REVISION'
-
- deployment_env = os.environ.copy()
- if deployment_target:
- deployment_env['MACOSX_DEPLOYMENT_TARGET'] = deployment_target
-
cmake_args = base_cmake_args + [
'-DLLVM_BINUTILS_INCDIR=' + binutils_incdir,
'-DCMAKE_C_FLAGS=' + cflags,
'-DCMAKE_CXX_FLAGS=' + cxxflags,
- '-DCMAKE_EXE_LINKER_FLAGS="' + ldflags,
- '-DCMAKE_SHARED_LINKER_FLAGS="' + ldflags,
- '-DCMAKE_MODULE_LINKER_FLAGS="' + ldflags,
'-DCHROMIUM_TOOLS_SRC=%s' % os.path.join(CHROMIUM_DIR, 'tools', 'clang'),
'-DCHROMIUM_TOOLS=%s' % ';'.join(args.tools)]
# TODO(thakis): Append this to base_cmake_args instead once compiler-rt
@@ -417,15 +349,9 @@
if not os.path.exists(LLVM_BUILD_DIR):
os.makedirs(LLVM_BUILD_DIR)
os.chdir(LLVM_BUILD_DIR)
- RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'cmake'] + cmake_args +
- [LLVM_DIR], env=deployment_env)
+ RunCommand(GetVSVersion().SetupScript('x64') +
+ ['&&', 'cmake'] + cmake_args + [LLVM_DIR])
RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all'])
-
- # TODO(thakis): Run `strip bin/clang` on posix (with -x on darwin)
-
- if sys.platform == 'darwin':
- CopyFile(os.path.join(LLVM_BUILD_DIR, 'libc++.1.dylib'),
- os.path.join(LLVM_BUILD_DIR, 'bin'))
# Do an x86 build of compiler-rt to get the 32-bit ASan run-time.
# TODO(hans): Remove once the regular build above produces this.
@@ -441,8 +367,8 @@
compiler_rt_args = base_cmake_args + [
'-DCMAKE_C_FLAGS=' + cflags,
'-DCMAKE_CXX_FLAGS=' + cxxflags]
- RunCommand(GetVSVersion().SetupScript('x86') + ['&&', 'cmake'] +
- compiler_rt_args + [LLVM_DIR], env=deployment_env)
+ RunCommand(GetVSVersion().SetupScript('x86') +
+ ['&&', 'cmake'] + compiler_rt_args + [LLVM_DIR])
RunCommand(GetVSVersion().SetupScript('x86') + ['&&', 'ninja', 'compiler-rt'])
# TODO(hans): Make this (and the .gypi and .isolate files) version number
« no previous file with comments | « no previous file | tools/clang/scripts/update.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698