diff --git a/attachment/repos/build.patch b/attachment/repos/build.patch index bbe17f9809dd6752ee533c0b15c1ec6c84574e57..84c50014e1c32ce13efa69e053f54a61fca03a3e 100644 --- a/attachment/repos/build.patch +++ b/attachment/repos/build.patch @@ -102,16 +102,16 @@ index b8d0f47..a3d1ed9 100644 @@ -313,7 +334,7 @@ if (!is_clang && using_sanitizer) { is_clang = true } - + -use_flutter_cxx = is_clang && (is_linux || is_android || is_mac || is_ios) +use_flutter_cxx = is_clang && (is_linux || is_android || is_mac || is_ios || is_ohos ) - + if (is_msan && !is_linux) { assert(false, "Memory sanitizer is only available on Linux.") @@ -365,7 +386,9 @@ if (is_posix) { ] } - + -if (is_linux) { +if (is_ohos || (is_linux && host_os == "mac")) { + _native_compiler_configs += [ "//build/config/ohos:sdk" ] @@ -160,7 +160,7 @@ index b8d0f47..a3d1ed9 100644 if (is_clang) { host_toolchain = "//build/toolchain/linux:clang_$host_cpu" diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn -index ba20010..17e0487 100644 +index ba20010..5f27c8c 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -191,10 +191,16 @@ config("compiler") { @@ -185,7 +185,7 @@ index ba20010..17e0487 100644 } else if (current_cpu == "x86") { cflags += [ "-m32" ] @@ -315,7 +321,7 @@ config("compiler") { - + # Linux/Android common flags setup. # --------------------------------- - if (is_linux || is_android) { @@ -193,8 +193,8 @@ index ba20010..17e0487 100644 cflags += [ "-fPIC", "-pipe", # Use pipes for communicating between sub-processes. Faster. -@@ -334,7 +340,16 @@ config("compiler") { - +@@ -334,7 +340,28 @@ config("compiler") { + # Linux-specific compiler flags setup. # ------------------------------------ - if (is_linux) { @@ -202,7 +202,19 @@ index ba20010..17e0487 100644 + cflags += [ "-pthread" ] + ldflags += [ "-pthread" ] + -+ if (current_cpu == "arm64") { ++ if (current_cpu == "x86") { ++ cflags += [ "--target=x86-linux-ohos" ] ++ ldflags += [ "--target=x86-linux-ohos" ] ++ cflags += [ "-DBORINGSSL_CLANG_SUPPORTS_DOT_ARCH" ] ++ } else if (current_cpu == "x64") { ++ cflags += [ "--target=x86_64-linux-ohos" ] ++ ldflags += [ "--target=x86_64-linux-ohos" ] ++ cflags += [ "-DBORINGSSL_CLANG_SUPPORTS_DOT_ARCH" ] ++ } else if (current_cpu == "arm") { ++ cflags += [ "--target=aarch-linux-ohos" ] ++ ldflags += [ "--target=aarch-linux-ohos" ] ++ cflags += [ "-DBORINGSSL_CLANG_SUPPORTS_DOT_ARCH" ] ++ } else if (current_cpu == "arm64") { + cflags += [ "--target=aarch64-linux-ohos" ] + ldflags += [ "--target=aarch64-linux-ohos" ] + cflags += [ "-DBORINGSSL_CLANG_SUPPORTS_DOT_ARCH" ] @@ -210,8 +222,8 @@ index ba20010..17e0487 100644 + } else if (is_linux) { cflags += [ "-pthread" ] ldflags += [ "-pthread" ] - -@@ -521,9 +536,13 @@ config("runtime_library") { + +@@ -521,9 +548,13 @@ config("runtime_library") { ldflags += [ "-nostdlib++" ] } include_dirs = [ @@ -224,9 +236,9 @@ index ba20010..17e0487 100644 + include_dirs += [ "//third_party/libcxx/include" ] + } } - + # Android standard library setup. -@@ -860,17 +879,35 @@ config("optimize") { +@@ -860,12 +891,14 @@ config("optimize") { cflags = [ "-Oz" ] + common_optimize_on_cflags # Favor size over speed. } else if (is_wasm) { cflags = [ "-Oz" ] @@ -235,34 +247,13 @@ index ba20010..17e0487 100644 } else { cflags = [ "-O2" ] + common_optimize_on_cflags } - + lto_flags = [] - if (enable_lto && (is_ios || is_android || is_fuchsia || is_wasm)) { + if (enable_lto && (is_ios || is_android || is_fuchsia || is_wasm || is_ohos)) { lto_flags += [ "-flto" ] } - -+ if (is_ohos) { -+ cflags += [ -+ "-mcpu=tsv110", -+ "-fwhole-program-vtables", -+ ] -+ } -+ - ldflags = common_optimize_on_ldflags + lto_flags - cflags += lto_flags -+ -+ if (is_ohos) { -+ ldflags += [ -+ "-Wl,--lto-O2", -+ "-Wl,--plugin-opt=-mcpu=tsv110", -+ "-Wl,-mllvm", -+ "-Wl,-wholeprogramdevirt-check=fallback", -+ ] -+ } - } - - # Turn off optimizations. + diff --git a/build/config/ohos/BUILD.gn b/build/config/ohos/BUILD.gn new file mode 100644 index 0000000..b2675d2 @@ -300,10 +291,10 @@ index 0000000..b2675d2 +} diff --git a/build/config/ohos/config.gni b/build/config/ohos/config.gni new file mode 100644 -index 0000000..0022d70 +index 0000000..add7249 --- /dev/null +++ b/build/config/ohos/config.gni -@@ -0,0 +1,13 @@ +@@ -0,0 +1,32 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. @@ -311,7 +302,26 @@ index 0000000..0022d70 +# This file contains common system config stuff for the Ohos build. + +if (is_ohos) { -+ if (current_cpu == "arm64") { ++ # Defines host_os ++ if (host_os == "linux") { ++ ohos_host_os = "linux" ++ } else if (host_os == "mac") { ++ ohos_host_os = "darwin" ++ } else if (host_os == "win") { ++ ohos_host_os = "win" ++ } else { ++ assert(false, "Need Ohos toolchain support for your build OS.") ++ } ++ ++ ++ # ABI ------------------------------------------------------------------------ ++ if (current_cpu == "x86") { ++ ohos_app_abi = "x86" ++ } else if (current_cpu == "x64") { ++ ohos_app_abi = "x86_64" ++ } else if (current_cpu == "arm") { ++ ohos_app_abi = "armeabi-v7a" ++ } else if (current_cpu == "arm64") { + ohos_app_abi = "arm64-v8a" + } else { + assert(false, "Unknown Ohos ABI: " + current_cpu) @@ -864,7 +874,7 @@ index cad6cbc..c17950b 100644 +++ b/build/secondary/third_party/glfw/BUILD.gn @@ -47,6 +47,34 @@ source_set("glfw") { ] - + defines = [ "_GLFW_WIN32" ] + } else if (is_ohos) { + sources += [ @@ -914,6 +924,6 @@ index 65b1623..a89742a 100644 + readelf = "${toolchain_bin}/llvm-readelf" + nm = "${toolchain_bin}/llvm-nm" + strip = "${toolchain_bin}/llvm-strip" - + target_triple_flags = "--target=${custom_target_triple}" sysroot_flags = "--sysroot ${custom_sysroot}" diff --git a/attachment/repos/dart.patch0 b/attachment/repos/dart.patch0 index 04ca043cec6ffd71361c290ec56a2728f68b4704..21a27ac0369a01e4b4dc5f9257435945f768d7e1 100644 --- a/attachment/repos/dart.patch0 +++ b/attachment/repos/dart.patch0 @@ -1,4 +1,4 @@ -diff --git a/pkg/dds/lib/dds.dart b/pkg/dds/lib/dds.dart +diff --git a/pkg/dds/lib/dds.dart b/pkg/dds/lib/dds.dart index 177a9265649..c7038c56ad7 100644 --- a/pkg/dds/lib/dds.dart +++ b/pkg/dds/lib/dds.dart @@ -5575,27 +5575,28 @@ index 66fa5a8d564..cc5eb834b3d 100644 #if DART_TARGET_OS_MACOS_IOS #define DART_TARGET_OS_NAME IOS diff --git a/runtime/vm/compiler/ffi/abi.h b/runtime/vm/compiler/ffi/abi.h -index b693ef85255..54b15f48890 100644 +index b693ef85255..6a3f42bd949 100644 --- a/runtime/vm/compiler/ffi/abi.h +++ b/runtime/vm/compiler/ffi/abi.h -@@ -24,6 +24,8 @@ enum class Abi { +@@ -24,6 +24,9 @@ enum class Abi { kAndroidArm64, kAndroidIA32, kAndroidX64, + kOhosArm, + kOhosArm64, ++ kOhosX64, kFuchsiaArm64, kFuchsiaX64, kIOSArm, -@@ -49,9 +51,9 @@ const int64_t num_abis = static_cast(Abi::kWindowsX64) + 1; +@@ -49,9 +52,9 @@ const int64_t num_abis = static_cast(Abi::kWindowsX64) + 1; // - runtime/vm/compiler/frontend/kernel_to_il.cc static_assert(static_cast(Abi::kAndroidArm) == 0, "Enum value unexpected."); -static_assert(static_cast(Abi::kWindowsX64) == 19, -+static_assert(static_cast(Abi::kWindowsX64) == 21, ++static_assert(static_cast(Abi::kWindowsX64) == 22, "Enum value unexpected."); -static_assert(num_abis == 20, "Enum value unexpected."); -+static_assert(num_abis == 22, "Enum value unexpected."); ++static_assert(num_abis == 23, "Enum value unexpected."); // The target ABI. Defines sizes and alignment of native types. Abi TargetAbi(); diff --git a/attachment/scripts/ohos.py b/attachment/scripts/ohos.py index 49f44d38657caa856a78706731ed16738aaf13d7..6021f9605870767d28cb519cb599dac57c9e62c0 100644 --- a/attachment/scripts/ohos.py +++ b/attachment/scripts/ohos.py @@ -28,6 +28,12 @@ from datetime import datetime SUPPORT_BUILD_NAMES = ("clean", "config", "har", "compile", "zip", "zip2", "upload") SUPPORT_BUILD_TYPES = ("debug", "profile", "release") +SUPPORT_ABIS = { + "x86": "x86", + "x64": "x86_64", + "arm": "armeabi-v7a", + "arm64": "arm64-v8a", +} DIR_ROOT = os.path.abspath(os.path.join(sys.argv[0], os.pardir)) OS_NAME = platform.system().lower() IS_WINDOWS = OS_NAME.startswith("win") @@ -61,14 +67,12 @@ class BuildInfo: buildType="release", targetOS="ohos", targetArch="arm64", - targetTriple="arm64-%s-ohos" % OS_NAME, - abi="arm64-v8a", ): self.buildType = buildType self.targetOS = targetOS self.targetArch = targetArch - self.targetTriple = targetTriple - self.abi = abi + self.targetTriple = "%s-%s-%s" % (targetArch, OS_NAME, targetOS) + self.abi = SUPPORT_ABIS[targetArch] def __repr__(self): return "BuildInfo(buildType=%s)" % (self.buildType) @@ -330,6 +334,9 @@ def addParseParam(parser): parser.add_argument( "--ohos_api_int", type=int, choices=[11, 12], default=12, help="Ohos api int." ) + parser.add_argument( + "--ohos-cpu", type=str, choices=['x64', 'x86', 'arm64', 'arm'], default="arm64" + ) parser.add_argument( "--har-unstripped", action="store_true", help="Use so.unstripped or not." ) @@ -365,7 +372,7 @@ def buildByNameAndType(args): for buildType in SUPPORT_BUILD_TYPES: if not buildType in buildTypes: continue - buildInfo = BuildInfo(buildType=buildType) + buildInfo = BuildInfo(buildType=buildType, targetArch=args.ohos_cpu) for buildName in SUPPORT_BUILD_NAMES: if not buildName in buildNames: continue diff --git a/tools/gn b/tools/gn index dab248aff26714073cea71e65bf69211f8a47b05..1f6336a445beed935827bb68139b86c231250c8b 100755 --- a/tools/gn +++ b/tools/gn @@ -344,8 +344,8 @@ def to_gn_args(args): gn_args['target_os'] = args.target_os gn_args['target_cpu'] = get_target_cpu(args) gn_args['dart_target_arch'] = gn_args['target_cpu'] - if (args.target_os == 'ohos'): - gn_args['host_cpu'] = get_host_cpu() + #if (args.target_os == 'ohos'): + # gn_args['host_cpu'] = get_host_cpu() print("ARGS.target_os:%s-%s" % (args.target_os,gn_args['target_os'] ) ) # We cannot cross-compile for 32 bit arm on a Windows host. We work around