diff --git a/llvm-build/build.py b/llvm-build/build.py index a200c11b05c49c4d812b26ca45e75c4eddc78405..11bddb21ffaaf642b9f20249806c692449559c5a 100755 --- a/llvm-build/build.py +++ b/llvm-build/build.py @@ -59,6 +59,7 @@ class BuildConfig(): self.OPENHOS_SFX = '-linux-ohos' self.LITEOS_SFX = '-liteos-ohos' self.LLDB_PY_VERSION = '3.10' + self.CLANG_VERSION = '12.0.1' logging.basicConfig(level=logging.INFO) @staticmethod @@ -464,7 +465,7 @@ class LlvmCore(BuildUtils): llvm_clang_install = os.path.abspath(os.path.join(self.build_config.REPOROOT_DIR, 'prebuilts/clang/ohos', self.use_platform(), - 'clang-10.0.1')) + 'clang-%s' % self.build_config.CLANG_VERSION)) llvm_path = self.merge_out_path('llvm_make') llvm_cc = os.path.join(llvm_clang_install, 'bin', 'clang') llvm_cxx = os.path.join(llvm_clang_install, 'bin', 'clang++') @@ -504,7 +505,7 @@ class LlvmCore(BuildUtils): llvm_defines['LLVM_BUILD_INSTRUMENTED'] = 'ON' llvm_defines['LLVM_PROFDATA'] = llvm_profdata - resource_dir = "lib/clang/10.0.1/lib/linux/libclang_rt.profile-x86_64.a" + resource_dir = "lib/clang/12.0.1/lib/linux/libclang_rt.profile-x86_64.a" ldflags += ' %s' % os.path.join(llvm_clang_install, resource_dir) self.llvm_compile_llvm_defines(llvm_defines, llvm_cc, llvm_cxx, cflags, ldflags) @@ -528,7 +529,7 @@ class LlvmCore(BuildUtils): windows_defines['LLDB_RELOCATABLE_PYTHON'] = 'OFF' win_sysroot = self.merge_out_path( - 'clang_mingw', 'clang-10.0.1', 'x86_64-w64-mingw32') + 'clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION, 'x86_64-w64-mingw32') windows_defines['LLDB_ENABLE_PYTHON'] = 'ON' windows_defines['LLDB_PYTHON_HOME'] = 'python' windows_defines['LLDB_PYTHON_RELATIVE_PATH'] = 'bin/python/lib/python%s' % (self.build_config.LLDB_PY_VERSION) @@ -631,11 +632,11 @@ class LlvmCore(BuildUtils): self.logger().info('Building llvm for windows.') build_dir = self.merge_out_path("windows-x86_64") - windowstool_path = self.merge_out_path('clang_mingw', 'clang-10.0.1') + windowstool_path = self.merge_out_path('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION) windows64_install = self.merge_out_path('windows-x86_64-install') windows_sysroot = os.path.join(windowstool_path, 'x86_64-w64-mingw32') - compiler_rt_path = self.merge_out_path('clang_mingw', 'clang-10.0.1', - 'lib', 'clang', '10.0.1', 'lib', 'windows') + compiler_rt_path = self.merge_out_path('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION, + 'lib', 'clang', self.build_config.CLANG_VERSION, 'lib', 'windows') self.check_create_dir(build_dir) @@ -1335,11 +1336,11 @@ class LlvmLibs(BuildUtils): def build_libs_for_windows(self, libname, enable_assertions): self.logger().info('Building libs for windows.') - toolchain_dir = self.merge_out_path('clang_mingw', 'clang-10.0.1') + toolchain_dir = self.merge_out_path('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION) install_dir = self.merge_out_path('windows-x86_64-install') - compiler_rt_path = self.merge_out_path('clang_mingw', 'clang-10.0.1', 'lib', 'clang', - '10.0.1', 'lib', 'windows') - windows_sysroot = self.merge_out_path('clang_mingw', 'clang-10.0.1', 'x86_64-w64-mingw32') + compiler_rt_path = self.merge_out_path('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION, 'lib', 'clang', + self.build_config.CLANG_VERSION, 'lib', 'windows') + windows_sysroot = self.merge_out_path('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION, 'x86_64-w64-mingw32') ldflags = ['-fuse-ld=lld', '--rtlib=compiler-rt', '-L%s' % compiler_rt_path, '-lunwind'] cflags = ['-stdlib=libc++', '--target=x86_64-pc-windows-gnu', '-D_LARGEFILE_SOURCE', @@ -1405,7 +1406,7 @@ class LldbMi(BuildUtils): self.logger().info('Building lldb-mi for linux.') llvm_path = os.path.abspath(os.path.join(self.build_config.REPOROOT_DIR, - 'prebuilts/clang/ohos', self.use_platform(), 'clang-10.0.1')) + 'prebuilts/clang/ohos', self.use_platform(), 'clang-%s' % self.build_config.CLANG_VERSION)) lldb_mi_cmake_path = os.path.join(self.build_config.LLVM_PROJECT_DIR, '../lldb-mi') lldb_mi_path = self.merge_out_path('lldb_mi_build') @@ -1495,17 +1496,17 @@ class LldbMi(BuildUtils): def build_lldb_mi_for_windows(self): self.logger().info('Building lldb-mi for windows.') - build_dir = self.merge_out_path('clang_mingw', 'clang-10.0.1') + build_dir = self.merge_out_path('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION) lldb_mi_windows64_path = self.merge_out_path('windows-x86_64-lldb-mi') lldb_mi_cmake_path = os.path.abspath(os.path.join(self.build_config.LLVM_PROJECT_DIR, '../lldb-mi')) windows64_install = self.merge_out_path('windows-x86_64-install') cc = os.path.join(build_dir, 'bin', 'clang') cxx = os.path.join(build_dir, 'bin', 'clang++') - windows_sysroot = self.merge_out_path('clang_mingw', 'clang-10.0.1', 'x86_64-w64-mingw32') + windows_sysroot = self.merge_out_path('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION, 'x86_64-w64-mingw32') self.check_create_dir(lldb_mi_windows64_path) - compiler_rt_path = self.merge_out_path('clang_mingw', 'clang-10.0.1', - 'lib', 'clang', '10.0.1', 'lib', 'windows') + compiler_rt_path = self.merge_out_path('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION, + 'lib', 'clang', self.build_config.CLANG_VERSION, 'lib', 'windows') ldflags = ['-fuse-ld=lld', '--rtlib=compiler-rt', @@ -1661,7 +1662,7 @@ class LlvmPackage(BuildUtils): def strip_lldb_server(self, host, install_dir): - clang_version_bin_dir = os.path.join(install_dir, 'lib', 'clang', '10.0.1', 'bin') + clang_version_bin_dir = os.path.join(install_dir, 'lib', 'clang', self.build_config.CLANG_VERSION, 'bin') if not host.startswith('linux') or not os.path.exists(clang_version_bin_dir): return @@ -1708,7 +1709,7 @@ class LlvmPackage(BuildUtils): if host.startswith('windows'): windows64_install = self.merge_out_path('windows-x86_64-install') clang_mingw_dir = self.merge_out_path('clang_mingw') - clang_mingw_sysroot_dir = os.path.join(clang_mingw_dir, 'clang-10.0.1', 'x86_64-w64-mingw32') + clang_mingw_sysroot_dir = os.path.join(clang_mingw_dir, 'clang-%s' % self.build_config.CLANG_VERSION, 'x86_64-w64-mingw32') package_name = 'clang-mingw-%s' % self.build_config.build_name clang_mingw_sysroot_lib_dir = os.path.join(clang_mingw_sysroot_dir, 'lib') clang_windows_lib_dir = os.path.join(windows64_install, 'lib') @@ -1721,19 +1722,19 @@ class LlvmPackage(BuildUtils): os.path.join(clang_mingw_sysroot_dir, 'include', 'c++')) lib_files = [] - if os.path.isdir(os.path.join(clang_mingw_dir, 'clang-10.0.1', 'lib')): - lib_files = os.listdir(os.path.join(clang_mingw_dir, 'clang-10.0.1', 'lib')) + if os.path.isdir(os.path.join(clang_mingw_dir, 'clang-%s' % self.build_config.CLANG_VERSION, 'lib')): + lib_files = os.listdir(os.path.join(clang_mingw_dir, 'clang-%s' % self.build_config.CLANG_VERSION, 'lib')) for lib_file in lib_files: if lib_file.endswith('.a'): - static_library = os.path.join(os.path.join(clang_mingw_dir, 'clang-10.0.1', 'lib'), lib_file) + static_library = os.path.join(os.path.join(clang_mingw_dir, 'clang-%s' % self.build_config.CLANG_VERSION, 'lib'), lib_file) os.remove(static_library) - self.check_rm_tree(os.path.join(clang_mingw_dir, 'clang-10.0.1', 'include')) + self.check_rm_tree(os.path.join(clang_mingw_dir, 'clang-%s' % self.build_config.CLANG_VERSION, 'include')) package_path = '%s%s' % (self.merge_out_path(package_name), '.tar.bz2') self.logger().info('Packaging %s', package_path) toolchain_name = 'clang-%s' % self.build_config.build_name - self.check_copy_tree(os.path.join(clang_mingw_dir, 'clang-10.0.1'), + self.check_copy_tree(os.path.join(clang_mingw_dir, 'clang-%s' % self.build_config.CLANG_VERSION), os.path.join(clang_mingw_dir, toolchain_name)) args = ['tar', '-cjC', clang_mingw_dir, '-f', package_path, toolchain_name] self.check_call(args) diff --git a/llvm-build/build_cpython-mingw.sh b/llvm-build/build_cpython-mingw.sh index 570741b720bcf31a2da8ca23b3880711483b8b19..354413452cb78a6c607e0870eedfed5ffe827671 100755 --- a/llvm-build/build_cpython-mingw.sh +++ b/llvm-build/build_cpython-mingw.sh @@ -23,8 +23,9 @@ cd ${CPYTHON_MINGW_BUILD} MINGW_PREFIX=${CPYTHON_MINGW_BUILD}/mingw64 MINGW_CHOST=x86_64-w64-mingw32 MINGW_BUILD=x86_64-unknown-linux-gnu -TOOLCHAIN_ROOT=${CLANG_MINGW_BUILD}/clang-10.0.1/bin -SYSROOT=${CLANG_MINGW_BUILD}/clang-10.0.1/x86_64-w64-mingw32 +CLANG_VERSION=clang-12.0.1 +TOOLCHAIN_ROOT=${CLANG_MINGW_BUILD}/${CLANG_VERSION}/bin +SYSROOT=${CLANG_MINGW_BUILD}/${CLANG_VERSION}/x86_64-w64-mingw32 mkdir $MINGW_BUILD export CC=$TOOLCHAIN_ROOT/clang diff --git a/llvm-build/env_prepare.sh b/llvm-build/env_prepare.sh index 527c69a51fd988e0e3261614b8b6c65a1d6c8f8d..56c2ad5988175e75c7325cb2694b19efcc4e7bb0 100755 --- a/llvm-build/env_prepare.sh +++ b/llvm-build/env_prepare.sh @@ -56,12 +56,12 @@ prebuilts/clang/ohos/${host_platform}-${host_cpu},https://mirrors.huaweicloud.co copy_config_linux_x86_64=""" prebuilts/cmake,https://mirrors.huaweicloud.com/harmonyos/compiler/cmake/3.16.5/${host_platform}/cmake-${host_platform}-x86-3.16.5.tar.gz -prebuilts/clang/ohos/${host_platform}-${host_cpu},https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang+llvm-10.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz +prebuilts/clang/ohos/${host_platform}-${host_cpu},https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.1/clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz """ copy_config_darwin_x86_64=""" prebuilts/cmake,https://mirrors.huaweicloud.com/harmonyos/compiler/cmake/3.16.5/${host_platform}/cmake-${host_platform}-x86-3.16.5.tar.gz -prebuilts/clang/ohos/${host_platform}-${host_cpu},https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang+llvm-10.0.1-x86_64-apple-darwin.tar.xz +prebuilts/clang/ohos/${host_platform}-${host_cpu},https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.1/clang+llvm-12.0.1-x86_64-apple-darwin.tar.xz """ # @@ -113,12 +113,12 @@ if [ -d "${code_dir}/prebuilts/clang/ohos/darwin-${host_cpu}/clang-530132" ];the fi fi -if [ -d "${code_dir}/prebuilts/clang/ohos/linux-x86_64/clang+llvm-10.0.1-x86_64-gnu-ubuntu-16.04.tar.xz" ];then - rm -rf "${code_dir}/prebuilts/clang/ohos/linux-x86_64/clang-10.0.1" - mv "${code_dir}/prebuilts/clang/ohos/linux-x86_64/clang+llvm-10.0.1-x86_64-gnu-ubuntu-16.04" "${code_dir}/prebuilts/clang/ohos/linux-x86_64/clang-10.0.1" +if [ -d "${code_dir}/prebuilts/clang/ohos/linux-x86_64/clang+llvm-12.0.1-x86_64-gnu-ubuntu-16.04.tar.xz" ];then + rm -rf "${code_dir}/prebuilts/clang/ohos/linux-x86_64/clang-12.0.1" + mv "${code_dir}/prebuilts/clang/ohos/linux-x86_64/clang+llvm-12.0.1-x86_64-gnu-ubuntu-16.04" "${code_dir}/prebuilts/clang/ohos/linux-x86_64/clang-12.0.1" fi -if [ -d "${code_dir}/prebuilts/clang/ohos/darwin-x86_64/clang+llvm-10.0.1-x86_64-apple-darwin" ];then - rm -rf "${code_dir}/prebuilts/clang/ohos/darwin-x86_64/clang-10.0.1" - mv "${code_dir}/prebuilts/clang/ohos/darwin-x86_64/clang+llvm-10.0.1-x86_64-apple-darwin" "${code_dir}/prebuilts/clang/ohos/darwin-x86_64/clang-10.0.1" +if [ -d "${code_dir}/prebuilts/clang/ohos/darwin-x86_64/clang+llvm-12.0.1-x86_64-apple-darwin" ];then + rm -rf "${code_dir}/prebuilts/clang/ohos/darwin-x86_64/clang-12.0.1" + mv "${code_dir}/prebuilts/clang/ohos/darwin-x86_64/clang+llvm-12.0.1-x86_64-apple-darwin" "${code_dir}/prebuilts/clang/ohos/darwin-x86_64/clang-12.0.1" fi diff --git a/llvm-build/mingw.py b/llvm-build/mingw.py index 8b73bca1749a1ea50a5c442f598be2be3c42dade..26d6b6495029951cdb378de7ff9f61cc6a8b1f06 100755 --- a/llvm-build/mingw.py +++ b/llvm-build/mingw.py @@ -25,9 +25,10 @@ import sys class BuildConfig(): def __init__(self): + self.CLANG_VERSION = '12.0.1' self.THIS_DIR = os.path.realpath(os.path.dirname(__file__)) self.OUT_DIR = os.environ.get('OUT_DIR', self.repo_root('out')) - self.MINGW_DIR = self.out_root('clang_mingw', 'clang-10.0.1', 'x86_64-w64-mingw32') + self.MINGW_DIR = self.out_root('clang_mingw', 'clang-%s' % self.CLANG_VERSION, 'x86_64-w64-mingw32') def repo_root(self, *args): return os.path.realpath(os.path.join(self.THIS_DIR, '../../', *args)) @@ -53,14 +54,14 @@ class LlvmMingw(): self.CMAKE_BIN_PATH = os.path.join(self.cmake_prebuilt_bin_dir(), 'cmake') self.NINJA_BIN_PATH = os.path.join(self.cmake_prebuilt_bin_dir(), 'ninja') - self.CLANG_PATH = self.build_config.out_root('clang_mingw', 'clang-10.0.1') + self.CLANG_PATH = self.build_config.out_root('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION) self.LLVM_CONFIG = os.path.join(self.CLANG_PATH, 'bin', 'llvm-config') - self.SYSROOT = self.build_config.out_root('clang_mingw', 'clang-10.0.1', 'x86_64-w64-mingw32') + self.SYSROOT = self.build_config.out_root('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION, 'x86_64-w64-mingw32') self.LLVM_TRIPLE = 'x86_64-windows-gnu' # out path self.CRT_PATH = self.build_config.out_root('clang_mingw', 'lib', 'clangrt-%s' % self.LLVM_TRIPLE) # install path - self.CRT_INSTALL = self.build_config.out_root('clang_mingw', 'clang-10.0.1', 'lib', 'clang', '10.0.1') + self.CRT_INSTALL = self.build_config.out_root('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION, 'lib', 'clang', self.build_config.CLANG_VERSION) # prefix & env self.prefix = build_config.mingw64_dir() common_flags = "-target x86_64-w64-mingw32 -rtlib=compiler-rt \ @@ -116,7 +117,7 @@ class LlvmMingw(): self.crt_defines['CMAKE_C_COMPILER'] = cc self.crt_defines['CMAKE_CXX_COMPILER'] = cxx self.crt_defines['LLVM_CONFIG_PATH'] = self.LLVM_CONFIG - clang_libcxx_lib = self.build_config.out_root('clang_mingw', 'clang-10.0.1', 'lib') + clang_libcxx_lib = self.build_config.out_root('clang_mingw', 'clang-%s' % self.build_config.CLANG_VERSION, 'lib') ldflags = [ '-L%s' % clang_libcxx_lib, '-fuse-ld=lld', @@ -197,17 +198,17 @@ class LlvmMingw(): if os.path.isdir(clang_mingw_dir): shutil.rmtree(clang_mingw_dir) os.makedirs(clang_mingw_dir) - shutil.copytree(self.build_config.repo_root('prebuilts/clang/ohos/linux-x86_64/clang-10.0.1'), - '%s/clang-10.0.1' % clang_mingw_dir) + shutil.copytree(self.build_config.repo_root('prebuilts/clang/ohos/linux-x86_64/clang-%s' % self.build_config.CLANG_VERSION), + '%s/clang-%s' % (clang_mingw_dir, self.build_config.CLANG_VERSION)) # Replace clang binaries to avoid dependency on libtinfo # TODO: Use `prebuilts/clang/ohos/linux-x86_64/llvm` instead of # `prebuilts/clang/ohos/linux-x86_64/clang-10.0.1` shutil.copy(self.build_config.repo_root('prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang'), - '%s/clang-10.0.1/bin/clang' % clang_mingw_dir) + '%s/clang-%s/bin/clang' % (clang_mingw_dir, self.build_config.CLANG_VERSION)) shutil.copy(self.build_config.repo_root('prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang++'), - '%s/clang-10.0.1/bin/clang++' % clang_mingw_dir) + '%s/clang-%s/bin/clang++' % (clang_mingw_dir, self.build_config.CLANG_VERSION)) shutil.copy(self.build_config.repo_root('prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang-10'), - '%s/clang-10.0.1/bin/clang-10' % clang_mingw_dir) + '%s/clang-%s/bin/clang-10' % (clang_mingw_dir, self.build_config.CLANG_VERSION)) def build_mingw64_headers(self): headers_dir = self.build_config.repo_root('third_party', 'mingw-w64', 'mingw-w64-headers', 'build') diff --git a/llvm-build/windres.sh b/llvm-build/windres.sh index 054bed7b811595104e3a2a54e9f28b4839de8b3c..6a51d1df7e4b0831c8097c4270a09ad7ffbdb40c 100755 --- a/llvm-build/windres.sh +++ b/llvm-build/windres.sh @@ -16,7 +16,7 @@ set -e #default variables MYDIR=$(dirname $0) -CLANG_BIN_ROOT="$MYDIR/../../out/clang_mingw/clang-10.0.1/bin/" +CLANG_BIN_ROOT="$MYDIR/../../out/clang_mingw/clang-12.0.1/bin/" CLANG_FLAGS="clang -target x86_64-w64-mingw32 -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld -Qunused-arguments -E -xc -DRC_INVOKED=1" LLVM_RC_FLAGS="llvm-rc -I ../src src/.libs/version.o.preproc.rc -c 1252 -fo src/.libs/version.o.out.res" LLVM_CVTRES_FLAGS="llvm-cvtres src/.libs/version.o.out.res -machine:X64 -out:"