diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index 4106cd9cfa688d53e7b7b0bf2a35efe7f5a0cd7d..cbd64e597976273b8c3ad5e148a882434bbb71e3 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2105,7 +2105,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( "x86_64-redhat-linux", "x86_64-suse-linux", "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", "x86_64-slackware-linux", "x86_64-unknown-linux", - "x86_64-amazon-linux", "x86_64-linux-android"}; + "x86_64-amazon-linux", "x86_64-linux-android", + "x86_64-linux-ohos"}; static const char *const X32LibDirs[] = {"/libx32"}; static const char *const X86LibDirs[] = {"/lib32", "/lib"}; static const char *const X86Triples[] = { diff --git a/clang/test/Driver/ohos.c b/clang/test/Driver/ohos.c index 170c0da0ce068cbaae76f2b4c5cc95fbd0326853..e20d6bfd2177d579e5ca34b8e6e035c9e18bd3fc 100644 --- a/clang/test/Driver/ohos.c +++ b/clang/test/Driver/ohos.c @@ -56,6 +56,8 @@ // RUN: | FileCheck %s -check-prefix=CHECK-RUNTIME // RUN: %clang %s -### --target=aarch64-linux-ohos -fuse-ld=lld 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-RUNTIME +// RUN: %clang %s -### --target=x86_64-linux-ohos -fuse-ld=lld 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-RUNTIME // CHECK-RUNTIME: "{{.*}}/libclang_rt.builtins.a" // CHECK-RUNTIME: "-l:libunwind.a" // CHECK-LIBM: "-lm" diff --git a/clang/test/Preprocessor/ohos.c b/clang/test/Preprocessor/ohos.c index bd1060133c4e3b229e679b52148cc1d665143dd4..9c3a81bbceed9d09c8aa933bf1cbe2a455af4fda 100644 --- a/clang/test/Preprocessor/ohos.c +++ b/clang/test/Preprocessor/ohos.c @@ -1,11 +1,13 @@ // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=arm-linux-ohos < /dev/null | FileCheck %s -match-full-lines -check-prefix=ARM-OHOS-CXX // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=aarch64-linux-ohos < /dev/null | FileCheck %s -match-full-lines -check-prefix=ARM64-OHOS-CXX +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-linux-ohos < /dev/null | FileCheck %s -match-full-lines -check-prefix=X86_64-OHOS-CXX // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-linux-ohos < /dev/null | FileCheck %s -check-prefix=OHOS-DEFS // ARM-HOS-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // ARM-OHOS-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // ARM64-HOS-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // ARM64-OHOS-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL +// X86_64-OHOS-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // OHOS-DEFS: __OHOS_FAMILY__ // OHOS-DEFS: __OHOS__ // OHOS-DEFS-NOT: __OHOS__ diff --git a/compiler-rt/lib/asan/asan_malloc_linux.cpp b/compiler-rt/lib/asan/asan_malloc_linux.cpp index 9c3f0a5338ee5b090a1dae0e2a192c74b85340fc..ca45b86e1aa1520ff677a320fdaf1240adb20620 100644 --- a/compiler-rt/lib/asan/asan_malloc_linux.cpp +++ b/compiler-rt/lib/asan/asan_malloc_linux.cpp @@ -243,7 +243,7 @@ INTERCEPTOR(void, malloc_stats, void) { __asan_print_accumulated_stats(); } -#if SANITIZER_ANDROID +#if SANITIZER_BIONIC // Format of __libc_malloc_dispatch has changed in Android L. // While we are moving towards a solution that does not depend on bionic // internals, here is something to support both K* and L releases. @@ -295,7 +295,7 @@ void ReplaceSystemMalloc() { } } // namespace __asan -#else // SANITIZER_ANDROID +#else // SANITIZER_BIONIC namespace __asan { void ReplaceSystemMalloc() { diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp index c4a1b2807a84eff72dbedb2e17bd48ec97e06321..a31947c08016eab96aa8d19081a9147f3bd57348 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp @@ -98,7 +98,6 @@ // Do not include asm/sigcontext.h on behalf of asm/ptrace.h // to avoid multiple definiton errors. #define __ASM_SIGCONTEXT_H 1 -#include #endif #if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \ @@ -143,6 +142,7 @@ typedef struct user_fpregs elf_fpregset_t; #if SANITIZER_ANDROID #include #elif SANITIZER_OHOS +#include #include #include #include diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index df46466655c3503dff0a3c5febd66dbb5a87f6d9..d83f54ca62bcaa3dd45f7547217766249adf8de7 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -580,6 +580,8 @@ public: virtual Status Unlink(const FileSpec &file_spec); + virtual ConstString GetMmapSymbolName(const ArchSpec &arch); + virtual MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr, lldb::addr_t length, diff --git a/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp b/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp index f76e016bb6aa4eed576eceac0d0f4b3efa726594..249cd5e9d801a55fbf5fafa4b2201b49f3be5eac 100644 --- a/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp +++ b/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.cpp @@ -1,4 +1,4 @@ -//===-- PlatformOHOS.cpp -------------------------------------*- C++ -*-===// +//===-- PlatformOHOS.cpp ----------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Config/config.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" @@ -30,13 +31,13 @@ static uint32_t g_initialize_count = 0; static const unsigned int g_ohos_default_cache_size = 2048; // Fits inside 4k adb packet. -LLDB_PLUGIN_DEFINE(PlatformOHOS); +LLDB_PLUGIN_DEFINE(PlatformOHOS) void PlatformOHOS::Initialize() { PlatformLinux::Initialize(); if (g_initialize_count++ == 0) { -#if defined(__OHOS_FAMILY__) +#if defined(__OHOS__) PlatformSP default_platform_sp(new PlatformOHOS(true)); default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetHostPlatform(default_platform_sp); @@ -112,7 +113,8 @@ PlatformSP PlatformOHOS::CreateInstance(bool force, const ArchSpec *arch) { return PlatformSP(); } -PlatformOHOS::PlatformOHOS(bool is_host) : PlatformLinux(is_host) {} +PlatformOHOS::PlatformOHOS(bool is_host) + : PlatformLinux(is_host), m_sdk_version(0) {} PlatformOHOS::~PlatformOHOS() {} @@ -128,9 +130,9 @@ ConstString PlatformOHOS::GetPluginNameStatic(bool is_host) { const char *PlatformOHOS::GetPluginDescriptionStatic(bool is_host) { if (is_host) - return "Local OpenHarmony OS user platform plug-in."; + return "Local Open HarmonyOS user platform plug-in."; else - return "Remote OpenHarmony OS user platform plug-in."; + return "Remote Open HarmonyOS user platform plug-in."; } ConstString PlatformOHOS::GetPluginName() { @@ -216,8 +218,10 @@ Status PlatformOHOS::DownloadModuleSlice(const FileSpec &src_file_spec, Status PlatformOHOS::DisconnectRemote() { Status error = PlatformLinux::DisconnectRemote(); - if (error.Success()) + if (error.Success()) { m_device_id.clear(); + m_sdk_version = 0; + } return error; } @@ -229,8 +233,25 @@ uint32_t PlatformOHOS::GetSdkVersion() { if (!IsConnected()) return 0; - // TBD - return 1; + if (m_sdk_version != 0) + return m_sdk_version; + + std::string version_string; + HdcClient hdc(m_device_id); + Status error = + hdc.Shell("getprop ro.build.version.sdk", seconds(5), &version_string); + version_string = llvm::StringRef(version_string).trim().str(); + + if (error.Fail() || version_string.empty()) { + Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM); + if (log) + log->Printf("Get SDK version failed. (error: %s, output: %s)", + error.AsCString(), version_string.c_str()); + return 0; + } + + m_sdk_version = StringConvert::ToUInt32(version_string.c_str()); + return m_sdk_version; } bool PlatformOHOS::GetRemoteOSVersion() { @@ -264,3 +285,7 @@ PlatformOHOS::GetLibdlFunctionDeclarations(lldb_private::Process *process) { return PlatformPOSIX::GetLibdlFunctionDeclarations(process); } + +ConstString PlatformOHOS::GetMmapSymbolName(const ArchSpec &arch) { + return arch.GetTriple().isArch32Bit() ? ConstString("__lldb_mmap") : PlatformLinux::GetMmapSymbolName(arch); +} diff --git a/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.h b/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.h index 643b7ae3f75fdedf9f94c52c5aabcad629b39e3c..886ca74ed84be1d661873bc8a1dd26ffc9b23c0f 100644 --- a/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.h +++ b/lldb/source/Plugins/Platform/OHOS/PlatformOHOS.h @@ -1,4 +1,4 @@ -//===-- PlatformOHOS.h ---------------------------------------*- C++ -*-===// +//===-- PlatformOHOS.h ------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -57,6 +57,8 @@ public: uint32_t GetDefaultMemoryCacheLineSize() override; + ConstString GetMmapSymbolName(const ArchSpec &arch) override; + protected: const char *GetCacheHostname() override; @@ -69,12 +71,13 @@ protected: private: std::string m_device_id; + uint32_t m_sdk_version; PlatformOHOS(const PlatformOHOS &other) = delete; PlatformOHOS& operator=(const PlatformOHOS &other) = delete; }; -} // namespace platofor_ohos +} // namespace platform_ohos } // namespace lldb_private #endif // liblldb_PlatformOHOS_h_ diff --git a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp index 0f331933f2ea2071058a4f7de5adb22b9418d3c4..c59e79306a4b30566efdbafe5e3512773ab40b0a 100644 --- a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp +++ b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp @@ -41,11 +41,13 @@ bool lldb_private::InferiorCallMmap(Process *process, addr_t &allocated_addr, if (thread == nullptr) return false; + const ArchSpec arch = process->GetTarget().GetArchitecture(); + auto mmap_name = process->GetTarget().GetPlatform()->GetMmapSymbolName(arch); const bool include_symbols = true; const bool include_inlines = false; SymbolContextList sc_list; process->GetTarget().GetImages().FindFunctions( - ConstString("mmap"), eFunctionNameTypeFull, include_symbols, + mmap_name, eFunctionNameTypeFull, include_symbols, include_inlines, sc_list); const uint32_t count = sc_list.GetSize(); if (count > 0) { @@ -89,7 +91,6 @@ bool lldb_private::InferiorCallMmap(Process *process, addr_t &allocated_addr, CompilerType void_ptr_type = type_system_or_err->GetBasicTypeFromAST(eBasicTypeVoid) .GetPointerType(); - const ArchSpec arch = process->GetTarget().GetArchitecture(); MmapArgList args = process->GetTarget().GetPlatform()->GetMmapArgumentList( arch, addr, length, prot_arg, flags, fd, offset); diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index a77ecddfbab655d3ff7e5f07a1acb32fa1f71d94..8c3c2c0134541afb75258fd4c5010439711fcb5b 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -1301,6 +1301,10 @@ Status Platform::Unlink(const FileSpec &path) { return error; } +ConstString Platform::GetMmapSymbolName(const ArchSpec &) { + return ConstString("mmap"); +} + MmapArgList Platform::GetMmapArgumentList(const ArchSpec &arch, addr_t addr, addr_t length, unsigned prot, unsigned flags, addr_t fd, diff --git a/llvm-build/Makefile b/llvm-build/Makefile index 5a8c15452bf1c65bd71756f922e301f2d846e0fb..d6e8933dc328f3e2b417fd98de8ff378089dcd3f 100644 --- a/llvm-build/Makefile +++ b/llvm-build/Makefile @@ -73,16 +73,24 @@ else ifeq ($(ARCH),aarch64) ARCH_CFLAGS = else +ifeq ($(ARCH),x86_64) +ARCH_CFLAGS = +else $(warning *** warning: ARCH $(ARCH) has not been tested yet, use with cautions!) ARCH_CFLAGS = endif endif +endif ifeq ($(ARCH),aarch64) CFLAGS = -march=armv8 -O2 -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack else +ifeq ($(ARCH),x86_64) +CFLAGS = -march=x86-64 -O2 -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack +else CFLAGS = -march=armv7-a -O2 -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack endif +endif .PHONY: $(TARGETS:%=musl_copy_for_%) .PHONY: $(TARGETS:%=musl_patch_for_%) @@ -201,4 +209,4 @@ clean: $(HIDE) rm -rf musl_copy_for_* linux_header_install_for_* distclean: clean - $(HIDE) rm -rf $(SYSROOTDIR)/lib $(SYSROOTDIR)/usr \ No newline at end of file + $(HIDE) rm -rf $(SYSROOTDIR)/lib $(SYSROOTDIR)/usr diff --git a/llvm-build/build.py b/llvm-build/build.py index f6f079f025b9f1494bae9da5afbcb25140f20674..a200c11b05c49c4d812b26ca45e75c4eddc78405 100755 --- a/llvm-build/build.py +++ b/llvm-build/build.py @@ -193,7 +193,7 @@ class BuildUtils(object): self.build_config = build_config self.CMAKE_BIN_DIR = os.path.abspath( - os.path.join(self.build_config.REPOROOT_DIR, 'prebuilts/cmake', self.use_platform()[:-3], 'bin')) + os.path.join(self.build_config.REPOROOT_DIR, 'prebuilts/cmake', self.platform_prefix(), 'bin')) def open_ohos_triple(self, arch): return arch + self.build_config.OPENHOS_SFX @@ -293,17 +293,21 @@ class BuildUtils(object): @staticmethod def use_platform(): - sysstr = platform.system() - if (sysstr == "Linux"): - return 'linux-x86_64' - else: - return 'darwin-x86_64' + sysstr = platform.system().lower() + arch = platform.machine() + return "%s-%s" % (sysstr, arch) + + def platform_prefix(self): + prefix = self.use_platform() + if (prefix.endswith('x86_64')): + return prefix[:-3] + return prefix def host_is_linux(self): - return self.use_platform() == 'linux-x86_64' + return self.use_platform().startswith('linux-') def host_is_darwin(self): - return self.use_platform() == 'darwin-x86_64' + return self.use_platform().startswith('darwin-') def rm_cmake_cache(self, cache_dir): for dirpath, dirs, files in os.walk(cache_dir): @@ -694,7 +698,7 @@ class SysrootComposer(BuildUtils): # but it didn't contain these two lines, so we still need OHOS.cmake. ohos_cmake = 'OHOS.cmake' dst_dir = self.merge_out_path( - '../prebuilts/cmake/linux-x86/share/cmake-3.16/Modules/Platform') + '../prebuilts/cmake/%s/share/cmake-3.16/Modules/Platform' % self.platform_prefix()) src_file = '%s/%s' % (self.build_config.CURRENT_DIR, ohos_cmake) if os.path.exists(os.path.join(dst_dir, ohos_cmake)): os.remove(os.path.join(dst_dir, ohos_cmake)) @@ -711,13 +715,14 @@ class SysrootComposer(BuildUtils): os.chdir(cur_dir) def install_linux_headers(self, arch, target): + dir_sufix = 'x86' if arch == 'x86_64' else arch linux_kernel_dir = os.path.join('kernel_linux_patches', 'linux-5.10') linux_kernel_path = os.path.join(self.build_config.OUT_PATH, '..', linux_kernel_dir) ohosmusl_sysroot_dst = self.merge_out_path('sysroot', target, 'usr') headers_tmp_dir = os.path.join(linux_kernel_path, 'prebuilts', 'usr', 'include') self.check_copy_tree(os.path.join(headers_tmp_dir, 'linux'), os.path.join(ohosmusl_sysroot_dst, 'include/linux')) - self.check_copy_tree(os.path.join(headers_tmp_dir, 'asm-%s' % arch, 'asm'), + self.check_copy_tree(os.path.join(headers_tmp_dir, 'asm-%s' % dir_sufix,'asm'), os.path.join(ohosmusl_sysroot_dst, 'include', 'asm')) self.check_copy_tree(os.path.join(headers_tmp_dir, 'asm-generic'), os.path.join(ohosmusl_sysroot_dst, 'include/asm-generic')) @@ -765,6 +770,7 @@ class LlvmLibs(BuildUtils): defines, cc, cxx, + ar, llvm_config, ldflags, cflags, @@ -774,6 +780,7 @@ class LlvmLibs(BuildUtils): defines['CMAKE_C_COMPILER'] = cc defines['CMAKE_CXX_COMPILER'] = cxx + defines['CMAKE_AR'] = ar defines['LLVM_CONFIG_PATH'] = llvm_config defines['CMAKE_SYSROOT'] = sysroot defines['CMAKE_FIND_ROOT_PATH_MODE_INCLUDE'] = 'ONLY' @@ -821,10 +828,12 @@ class LlvmLibs(BuildUtils): '-march=armv7-a -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4', 'a7_softfp_neon-vfpv4'), ('arm', self.open_ohos_triple('arm'), '-march=armv7-a -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4', 'a7_hard_neon-vfpv4'), - ('aarch64', self.open_ohos_triple('aarch64'), '', ''), ] + ('aarch64', self.open_ohos_triple('aarch64'), '', ''), + ('x86_64', self.open_ohos_triple('x86_64'), '', ''),] cc = os.path.join(llvm_install, 'bin', 'clang') cxx = os.path.join(llvm_install, 'bin', 'clang++') + ar = os.path.join(llvm_install, 'bin', 'llvm-ar') llvm_config = os.path.join(llvm_install, 'bin', 'llvm-config') seen_arch_list = [self.liteos_triple('arm')] @@ -837,10 +846,11 @@ class LlvmLibs(BuildUtils): ldflags = [] cflags = [] self.logger().info('Build libs for %s', llvm_triple) - self.build_libs_defines(llvm_triple, defines, cc, cxx, llvm_config, ldflags, cflags, extra_flags) + self.build_libs_defines(llvm_triple, defines, cc, cxx, ar, llvm_config, ldflags, cflags, extra_flags) llvm_path = self.merge_out_path('llvm_make') - arch_list = [self.liteos_triple('arm'), self.open_ohos_triple('arm'), self.open_ohos_triple('aarch64')] + arch_list = [self.liteos_triple('arm'), self.open_ohos_triple('arm'), self.open_ohos_triple('aarch64'), + self.open_ohos_triple('x86_64')] if precompilation: self.build_crts(llvm_install, arch, llvm_triple, cflags, ldflags, multilib_suffix, defines) continue @@ -1063,7 +1073,7 @@ class LlvmLibs(BuildUtils): else: libcxx_defines['LIBCXX_ABI_NAMESPACE'] = '__n1' libcxx_defines['CMAKE_INSTALL_PREFIX'] = libcxx_ndk_install - libcxx_defines['LIBCXX_INSTALL_HEADER_PREFIX'] = libcxx_ndk_install + '/' + libcxx_defines['LIBCXX_INSTALL_HEADER_PREFIX'] = os.path.join(libcxx_ndk_install, 'include', 'libcxx-ohos', '') libcxx_defines['LIBCXX_OUTPUT_NAME'] = 'c++_shared' libcxx_defines['LIBCXX_OUTPUT_STATIC_NAME'] = 'c++_static' @@ -1404,18 +1414,21 @@ class LldbMi(BuildUtils): if self.host_is_darwin(): cflags = [] + cxxflags =[] ldflags = ['-Wl,-rpath,%s' % '@loader_path/../lib'] else: cflags = [] + cxxflags =[] ldflags = ['-fuse-ld=lld', '-Wl,-rpath,%s' % '\$ORIGIN/../lib'] ldflags.append('-L%s' % os.path.join(llvm_path, 'lib')) + cxxflags.append('-std=c++14') lldb_mi_defines = {} lldb_mi_defines['CMAKE_C_COMPILER'] = os.path.join(llvm_path, 'bin', 'clang') lldb_mi_defines['CMAKE_CXX_COMPILER'] = os.path.join(llvm_path, 'bin', 'clang++') lldb_mi_defines['CMAKE_C_FLAGS'] = ' '.join(cflags) - lldb_mi_defines['CMAKE_CXX_FLAGS'] = ' '.join(cflags) + lldb_mi_defines['CMAKE_CXX_FLAGS'] = ' '.join(cxxflags) lldb_mi_defines['CMAKE_EXE_LINKER_FLAGS'] = ' '.join(ldflags) lldb_mi_defines['CMAKE_SHARED_LINKER_FLAGS'] = ' '.join(ldflags) lldb_mi_defines['CMAKE_MODULE_LINKER_FLAGS'] = ' '.join(ldflags) @@ -1573,8 +1586,8 @@ class LlvmPackage(BuildUtils): def package_libcxx(self): libcxx_ndk_install=self.merge_out_path('libcxx-ndk') - libcxx_ndk_install_include=self.merge_out_path(libcxx_ndk_install, 'include', 'c++', 'v1') - hosts_list=['linux-x86_64', 'darwin-x86_64', 'windows-x86_64'] + libcxx_ndk_install_include=self.merge_out_path(libcxx_ndk_install, 'include', 'libcxx-ohos', 'include', 'c++', 'v1') + hosts_list=['linux-x86_64', 'darwin-x86_64', 'windows-x86_64', 'darwin-arm64'] if os.path.exists(libcxx_ndk_install): for headerfile in os.listdir(libcxx_ndk_install_include): @@ -1650,7 +1663,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') - if not host == 'linux-x86_64' or not os.path.exists(clang_version_bin_dir): + if not host.startswith('linux') or not os.path.exists(clang_version_bin_dir): return llvm_strip = os.path.join(install_dir, 'bin', 'llvm-strip') for llvm_triple_dir in os.listdir(clang_version_bin_dir): @@ -1680,7 +1693,7 @@ class LlvmPackage(BuildUtils): with open(zlib_license_file) as notice_file: notices.append(notice_file.read()) - if host == 'windows-x86_64': + if host.startswith('windows'): mingw_license_file = os.path.abspath(os.path.join(self.build_config.REPOROOT_DIR, 'third_party/mingw-w64/COPYING')) with open(mingw_license_file) as notice_file: @@ -1692,7 +1705,7 @@ class LlvmPackage(BuildUtils): def tar_windows_mingw(self, host): - if host == 'windows-x86_64': + 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') @@ -1820,7 +1833,7 @@ class LlvmPackage(BuildUtils): lib_files = [] if os.path.isdir(lib_dir): lib_files = os.listdir(lib_dir) - if host == 'windows-x86_64': + if host.startswith('windows'): vers_major = int(self.build_config.VERSION.split('.')[0]) # Redefining necessary bin files for Windows. windows_forbidden_list_bin_files = ['clang-%s%s' % (vers_major, ext), 'scan-build%s' % ext, @@ -1847,7 +1860,7 @@ class LlvmPackage(BuildUtils): package_path = '%s%s' % (self.merge_out_path(tarball_name), '.tar.bz2') self.logger().info('Packaging %s', package_path) args = ['tar', '-cjC', install_host_dir, '-f', package_path, package_name] - if host == 'windows-x86_64': + if host.startswith('windows'): # windows do not support symlinks, # replace them with file copies args.insert(1, '--dereference') @@ -1855,7 +1868,7 @@ class LlvmPackage(BuildUtils): self.check_call(args) # Package ohos NDK - if host == 'linux-x86_64' and os.path.exists(self.merge_out_path('sysroot')): + if os.path.exists(self.merge_out_path('sysroot')): tarball_ndk_name = 'ohos-sysroot-%s' % self.build_config.build_name package_ndk_path = '%s%s' % (self.merge_out_path(tarball_ndk_name), '.tar.bz2') self.logger().info('Packaging %s', package_ndk_path) @@ -1870,10 +1883,10 @@ class LlvmPackage(BuildUtils): package_name = 'clang-%s' % self.build_config.build_name self.set_clang_version(build_dir) - if host == 'windows-x86_64': + if host.startswith('windows'): ext = '.exe' shlib_ext = '.dll' - elif host == 'linux-x86_64': + elif host.startswith('linux'): ext = '' shlib_ext = '.so' else: @@ -1956,6 +1969,10 @@ def main(): if not build_config.no_build_aarch64: configs.append(('arm64', build_utils.open_ohos_triple('aarch64'))) + if not build_config.no_build_x86_64: + configs.append(('x86_64', build_utils.open_ohos_triple('x86_64'))) + + if build_config.do_build and need_host: llvm_core.llvm_compile( build_config.build_name, diff --git a/llvm-build/build_musl.sh b/llvm-build/build_musl.sh index 2d67800641e679a7491baa965e33ea4fec1dd73d..a05b87229d3c5c4cca5f5e8fad9f180f261d0a06 100755 --- a/llvm-build/build_musl.sh +++ b/llvm-build/build_musl.sh @@ -72,6 +72,9 @@ if [ $TARGET_TRIPLE == "arm-liteos-ohos" ]; then elif [ $TARGET_TRIPLE == "arm-linux-ohos" ]; then TARGET_USER="linux_user" TARGETS_PREFIX="arm" +elif [ $TARGET_TRIPLE == "x86_64-linux-ohos" ]; then + TARGET_USER="linux_user" + TARGETS_PREFIX="x86_64" else TARGET_USER="linux_user" TARGETS_PREFIX="aarch64" @@ -91,7 +94,7 @@ make musl_header_install_for_${TARGET_USER} CLANG="${CLANG_BIN_ROOT}/clang" TOPD # build musl_libs if ((make_libs == 1)); then - if [ $TARGET_TRIPLE == "aarch64-linux-ohos" ]; then + if [ $TARGET_TRIPLE == "aarch64-linux-ohos" ] || [ $TARGET_TRIPLE == "x86_64-linux-ohos" ]; then make CLANG="${CLANG_BIN_ROOT}/clang" TOPDIR=${PWD}/../../ SYSROOTDIR=${OUT}/sysroot TARGETS=${TARGET_USER}\ TARGET=${TARGET_TRIPLE} ARCH=${TARGETS_PREFIX} -f Makefile else @@ -102,4 +105,4 @@ if ((make_libs == 1)); then done fi fi -make distclean -f Makefile \ No newline at end of file +make distclean -f Makefile