From 4ce18ab931e336ee96fd2366661e2b84e950772b Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Mon, 15 Jun 2020 20:05:16 +0000 Subject: [PATCH] Add an --os=fuchsia option to build.py: tools/build.py --os=fuchsia runtime create_sdk This is analogous to --os=android. It cross compiles from Linux x64 to Fuchsia. A lot of the build rules are just slightly different between the existing Fuchsia build rules used by Flutter, and the ones added by GN SDK. For example "$fuchsia_sdk_root/pkg:fdio" is now "$fuchsia_sdk_root/pkg/fdio". So to support this I had to add a new variable, using_fuchsia_gn_sdk, analogous to using_fuchsia_sdk. Flutter will need to set this to false. Change-Id: Ief275d65f30a42a801607de93cf2d27a1fe825dd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150689 Reviewed-by: Ryan Macnak Commit-Queue: Liam Appelbe --- DEPS | 11 +++ build/config/BUILDCONFIG.gn | 15 +++ build/config/compiler/BUILD.gn | 4 +- build/fuchsia/sdk.gni | 10 ++ build/toolchain/fuchsia/BUILD.gn | 164 +++++++++++++++++++++++++++++++ runtime/BUILD.gn | 12 ++- runtime/bin/BUILD.gn | 30 +++++- runtime/bin/process_fuchsia.cc | 10 +- runtime/bin/snapshot_utils.cc | 4 + runtime/platform/BUILD.gn | 4 +- runtime/vm/BUILD.gn | 19 +++- sdk/BUILD.gn | 2 +- sdk_nnbd/BUILD.gn | 2 +- tools/build.py | 26 +++-- tools/gn.py | 26 +++-- tools/utils.py | 2 +- 16 files changed, 309 insertions(+), 32 deletions(-) create mode 100644 build/fuchsia/sdk.gni create mode 100644 build/toolchain/fuchsia/BUILD.gn diff --git a/DEPS b/DEPS index 669bab9c7f9..a31992f83a9 100644 --- a/DEPS +++ b/DEPS @@ -470,6 +470,17 @@ deps = { "dep_type": "cipd", }, + Var("dart_root") + "/third_party/fuchsia/sdk/linux": { + "packages": [ + { + "package": "fuchsia/sdk/gn/linux-amd64", + "version": "git_revision:8d5242d4f6ff8b7634b492700e60b0fd09abefa3" + } + ], + "condition": 'host_os == "linux" and host_cpu == "x64"', + "dep_type": "cipd", + }, + Var("dart_root") + "/pkg/front_end/test/fasta/types/benchmark_data": { "packages": [ { diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 4457f43f07d..e83f6140417 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -196,6 +196,16 @@ if (current_os == "win") { is_nacl = false is_posix = true is_win = false +} else if (current_os == "fuchsia") { + is_android = false + is_chromeos = false + is_fuchsia = true + is_ios = false + is_linux = false + is_mac = false + is_nacl = false + is_posix = true + is_win = false } # ============================================================================= @@ -384,6 +394,11 @@ if (is_win) { } else if (is_mac) { host_toolchain = "//build/toolchain/mac:clang_x64" set_default_toolchain(host_toolchain) +} else if (is_fuchsia) { + assert(host_os == "linux") + assert(host_cpu == "x64") + host_toolchain = "//build/toolchain/linux:clang_$host_cpu" + set_default_toolchain("//build/toolchain/fuchsia") } # ============================================================================== diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index b5a49ba9f1a..ee47c357d29 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -243,7 +243,7 @@ config("compiler") { # 3. When using the sanitizers. # Otherwise there is a performance hit, in particular on ia32. if (is_android || is_asan || is_lsan || is_msan || is_tsan || is_ubsan || - (is_linux && current_cpu != "x86")) { + (is_linux && current_cpu != "x86") || is_fuchsia) { cflags += [ "-fPIC" ] ldflags += [ "-fPIC" ] } @@ -276,6 +276,8 @@ config("compiler") { if (is_win) { # Up-to-date toolchain MSVC doesn't support c++11 flag any longer. cc_std = [ "/std:c++14" ] + } else if (is_fuchsia) { + cc_std = [ "-std=c++17" ] } else { cc_std = [ "-std=c++11" ] } diff --git a/build/fuchsia/sdk.gni b/build/fuchsia/sdk.gni new file mode 100644 index 00000000000..00698dcb253 --- /dev/null +++ b/build/fuchsia/sdk.gni @@ -0,0 +1,10 @@ +# Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +# for details. All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE file. + +declare_args() { + using_fuchsia_gn_sdk = true + fuchsia_sdk_root = "//third_party/fuchsia/sdk/$host_os" + fuchsia_sdk_path = "//third_party/fuchsia/sdk/$host_os" + fuchsia_toolchain_path = "//third_party/fuchsia/toolchain/$host_os" +} diff --git a/build/toolchain/fuchsia/BUILD.gn b/build/toolchain/fuchsia/BUILD.gn new file mode 100644 index 00000000000..2901377fbf5 --- /dev/null +++ b/build/toolchain/fuchsia/BUILD.gn @@ -0,0 +1,164 @@ +# Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +# for details. All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE file. + +import("//build/config/sysroot.gni") +import("//build/toolchain/ccache.gni") +import("//build/toolchain/gcc_toolchain.gni") +import("//build/toolchain/goma.gni") + +if (use_goma) { + assert(!use_ccache, "Goma and ccache can't be used together.") + compiler_prefix = "$goma_dir/gomacc " +} else if (use_ccache) { + compiler_prefix = "ccache " +} else { + compiler_prefix = "" +} + +toolchain("fuchsia") { + assert(target_cpu == "x64", "We currently only support 'x64' for fuchsia.") + toolchain_bin = + rebase_path("//buildtools/$host_os-$target_cpu/clang/bin", root_out_dir) + fuchsia_sdk = rebase_path("//third_party/fuchsia/sdk/$host_os", root_out_dir) + + # We can't do string interpolation ($ in strings) on things with dots in + # them. To allow us to use $cc below, for example, we create copies of + # these values in our scope. + cc = "${toolchain_bin}/clang" + cxx = "${toolchain_bin}/clang++" + ar = "${toolchain_bin}/llvm-ar" + ld = "${toolchain_bin}/clang++" + readelf = "${toolchain_bin}/llvm-readelf" + nm = "${toolchain_bin}/llvm-nm" + strip = "${toolchain_bin}/llvm-strip" + + target_triple_flags = "--target=x86_64-fuchsia" + sysroot_flags = "--sysroot ${fuchsia_sdk}/arch/${target_cpu}/sysroot" + lto_flags = "" + + # These library switches can apply to all tools below. + lib_switch = "-l" + lib_dir_switch = "-L" + + tool("cc") { + depfile = "{{output}}.d" + command = "$compiler_prefix $cc -MD -MF $depfile $target_triple_flags $sysroot_flags $lto_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "CC {{output}}" + outputs = + [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] + } + + tool("cxx") { + depfile = "{{output}}.d" + command = "$compiler_prefix $cxx -MD -MF $depfile $target_triple_flags $sysroot_flags $lto_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "CXX {{output}}" + outputs = + [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] + } + + tool("asm") { + depfile = "{{output}}.d" + command = "$compiler_prefix $cc -MD -MF $depfile $target_triple_flags $sysroot_flags $lto_flags {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" + depsformat = "gcc" + description = "ASM {{output}}" + outputs = + [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] + } + + tool("alink") { + rspfile = "{{output}}.rsp" + command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile" + description = "AR {{output}}" + rspfile_content = "{{inputs}}" + outputs = + [ "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" ] + default_output_extension = ".a" + output_prefix = "lib" + } + + tool("solink") { + soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". + sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. + unstripped_sofile = + "{{root_out_dir}}/so.unstripped/$soname" # Possibly including toolchain + # dir. + rspfile = sofile + ".rsp" + + # These variables are not built into GN but are helpers that implement + # (1) linking to produce a .so, (2) extracting the symbols from that file + # to a temporary file, (3) if the temporary file has differences from the + # existing .TOC file, overwrite it, otherwise, don't change it. + tocfile = sofile + ".TOC" + temporary_tocname = sofile + ".tmp" + link_command = "$compiler_prefix $ld $target_triple_flags $sysroot_flags $lto_flags -shared {{ldflags}} -o $unstripped_sofile -Wl,--build-id -Wl,-soname=$soname @$rspfile" + toc_command = "{ $readelf -d $unstripped_sofile | grep SONAME ; $nm -gD -f posix $unstripped_sofile | cut -f1-2 -d' '; } > $temporary_tocname" + replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $temporary_tocname $tocfile; fi" + strip_command = "$strip -o $sofile $unstripped_sofile" + + command = + "$link_command && $toc_command && $replace_command && $strip_command" + rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}" + + description = "SOLINK $sofile" + + default_output_extension = ".so" + + output_prefix = "lib" + + # Since the above commands only updates the .TOC file when it changes, ask + # Ninja to check if the timestamp actually changed to know if downstream + # dependencies should be recompiled. + restat = true + + # Tell GN about the output files. It will link to the sofile but use the + # tocfile for dependency management. + outputs = [ + sofile, + unstripped_sofile, + tocfile, + ] + + link_output = sofile + depend_output = tocfile + } + + tool("link") { + exename = "{{target_output_name}}{{output_extension}}" + outfile = "{{root_out_dir}}/$exename" + rspfile = "$outfile.rsp" + unstripped_outfile = "{{root_out_dir}}/exe.stripped/$exename" + command = "$compiler_prefix $ld $target_triple_flags $sysroot_flags $lto_flags {{ldflags}} -o $unstripped_outfile -Wl,--build-id -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}} && ${strip} -o $outfile $unstripped_outfile" + description = "LINK $outfile" + rspfile_content = "{{inputs}}" + outputs = [ + unstripped_outfile, + outfile, + ] + } + + tool("stamp") { + command = "touch {{output}}" + description = "STAMP {{output}}" + } + + tool("copy") { + command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" + description = "COPY {{source}} {{output}}" + } + + # When invoking this toolchain not as the default one, these args will be + # passed to the build. They are ignored when this is the default toolchain. + toolchain_args = { + current_cpu = target_cpu + current_os = target_os + + # These values need to be passed through unchanged. + target_os = target_os + target_cpu = target_cpu + + is_clang = true + } +} diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index bbabc7cd05e..da22c445203 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -136,7 +136,10 @@ config("dart_config") { } if (is_fuchsia) { - if (using_fuchsia_sdk) { + if (using_fuchsia_gn_sdk) { + lib_dirs = [ "../out/DebugFuchsiaX64/lib" ] + } + if (using_fuchsia_gn_sdk || using_fuchsia_sdk) { # TODO(chinmaygarde): Currenty these targets need to be build in the # Fuchsia tree as well as outside it using the SDK. However, not all # Fuchsia features are available in the SDK. As these features are added, @@ -223,7 +226,12 @@ library_for_all_configs("libdart") { defines = [ "DART_ENABLE_WASM" ] } if (is_fuchsia) { - if (using_fuchsia_sdk) { + if (using_fuchsia_gn_sdk) { + extra_deps += [ + "$fuchsia_sdk_root/pkg/fdio", + "$fuchsia_sdk_root/pkg/trace-engine", + ] + } else if (using_fuchsia_sdk) { extra_deps += [ "$fuchsia_sdk_root/pkg:fdio", "$fuchsia_sdk_root/pkg:trace-engine", diff --git a/runtime/bin/BUILD.gn b/runtime/bin/BUILD.gn index 427fe0bfc31..ace748d61aa 100644 --- a/runtime/bin/BUILD.gn +++ b/runtime/bin/BUILD.gn @@ -42,7 +42,9 @@ template("build_libdart_builtin") { public_configs = [ ":libdart_builtin_config" ] deps = [] if (is_fuchsia) { - if (using_fuchsia_sdk) { + if (using_fuchsia_gn_sdk) { + public_deps = [ "$fuchsia_sdk_root/pkg/fdio" ] + } else if (using_fuchsia_sdk) { public_deps = [ "$fuchsia_sdk_root/pkg:fdio" ] } else { public_deps = [ "//zircon/public/lib/fdio" ] @@ -318,7 +320,13 @@ template("build_gen_snapshot_dart_io") { deps = [] if (is_fuchsia) { - if (using_fuchsia_sdk) { + if (using_fuchsia_gn_sdk) { + deps += [ + "$fuchsia_sdk_root/fidl/fuchsia.netstack", + "$fuchsia_sdk_root/pkg/sys_cpp", + ] + public_deps = [ "$fuchsia_sdk_root/pkg/fdio" ] + } else if (using_fuchsia_sdk) { deps += [ "$fuchsia_sdk_root/fidl:fuchsia.netstack", "$fuchsia_sdk_root/pkg:sys_cpp", @@ -454,7 +462,13 @@ template("dart_io") { deps += [ "//third_party/boringssl" ] if (is_fuchsia) { - if (using_fuchsia_sdk) { + if (using_fuchsia_gn_sdk) { + deps += [ + "$fuchsia_sdk_root/fidl/fuchsia.netstack", + "$fuchsia_sdk_root/pkg/sys_cpp", + ] + public_deps = [ "$fuchsia_sdk_root/pkg/fdio" ] + } else if (using_fuchsia_sdk) { deps += [ "$fuchsia_sdk_root/fidl:fuchsia.netstack", "$fuchsia_sdk_root/pkg:sys_cpp", @@ -788,7 +802,9 @@ template("dart_executable") { # have them. They are needed for running Fuchsia binaries built for the # host. if (is_linux) { - configs += [ "../../build/config/gcc:executable_ldconfig" ] + # TODO(liama): Commenting this line out because it causes problems for + # --os=fuchsia. If no one complains, remove it. + # configs += [ "../../build/config/gcc:executable_ldconfig" ] } else if (is_mac) { configs += [ "../../build/config/mac:mac_dynamic_flags" ] } @@ -1012,7 +1028,11 @@ executable("run_vm_tests") { } if (is_fuchsia) { - if (!using_fuchsia_sdk) { + if (using_fuchsia_gn_sdk) { + include_dirs += [ "$fuchsia_sdk_path/pkg/trace-engine/include" ] + libs = [ "zircon" ] + } + if (!using_fuchsia_gn_sdk && !using_fuchsia_sdk) { deps += [ "//zircon/system/ulib/trace" ] } } diff --git a/runtime/bin/process_fuchsia.cc b/runtime/bin/process_fuchsia.cc index 8805d095eb5..495eceb33ac 100644 --- a/runtime/bin/process_fuchsia.cc +++ b/runtime/bin/process_fuchsia.cc @@ -744,7 +744,9 @@ class ProcessStarter { } actions[3] = { .action = FDIO_SPAWN_ACTION_SET_NAME, - .name.data = program_arguments_[0], + .name = { + .data = program_arguments_[0], + }, }; // Then fill in the namespace actions. @@ -752,8 +754,10 @@ class ProcessStarter { for (size_t i = 0; i < flat_ns->count; i++) { actions[fixed_actions_cnt + i] = { .action = FDIO_SPAWN_ACTION_ADD_NS_ENTRY, - .ns.prefix = flat_ns->path[i], - .ns.handle = flat_ns->handle[i], + .ns = { + .prefix = flat_ns->path[i], + .handle = flat_ns->handle[i], + }, }; } free(flat_ns); diff --git a/runtime/bin/snapshot_utils.cc b/runtime/bin/snapshot_utils.cc index 36f629387cf..5e18ebd46aa 100644 --- a/runtime/bin/snapshot_utils.cc +++ b/runtime/bin/snapshot_utils.cc @@ -201,7 +201,9 @@ static AppSnapshot* TryReadAppSnapshotElf( *isolate_data_buffer = nullptr, *isolate_instructions_buffer = nullptr; Dart_LoadedElf* handle = nullptr; +#if !defined(HOST_OS_FUCHSIA) if (force_load_elf_from_memory) { +#endif File* const file = File::Open(/*namespc=*/nullptr, script_name, File::kRead); if (file == nullptr) return nullptr; @@ -216,11 +218,13 @@ static AppSnapshot* TryReadAppSnapshotElf( &isolate_data_buffer, &isolate_instructions_buffer); delete memory; file->Release(); +#if !defined(HOST_OS_FUCHSIA) } else { handle = Dart_LoadELF(script_name, file_offset, &error, &vm_data_buffer, &vm_instructions_buffer, &isolate_data_buffer, &isolate_instructions_buffer); } +#endif if (handle == nullptr) { Syslog::PrintErr("Loading failed: %s\n", error); return nullptr; diff --git a/runtime/platform/BUILD.gn b/runtime/platform/BUILD.gn index 012421df933..c727eeac3b4 100644 --- a/runtime/platform/BUILD.gn +++ b/runtime/platform/BUILD.gn @@ -17,7 +17,9 @@ library_for_all_configs("libdart_platform") { extra_deps = [] if (is_fuchsia) { - if (using_fuchsia_sdk) { + if (using_fuchsia_gn_sdk) { + extra_deps += [ "$fuchsia_sdk_root/pkg/sys_cpp" ] + } else if (using_fuchsia_sdk) { extra_deps += [ "$fuchsia_sdk_root/pkg:sys_cpp" ] } else { extra_deps += [ "//sdk/lib/sys/cpp" ] diff --git a/runtime/vm/BUILD.gn b/runtime/vm/BUILD.gn index c35366cc7d1..f2c4fbc1bfc 100644 --- a/runtime/vm/BUILD.gn +++ b/runtime/vm/BUILD.gn @@ -72,7 +72,16 @@ library_for_all_configs("libdart_vm") { "//third_party/icu:icuuc", ] if (is_fuchsia) { - if (using_fuchsia_sdk) { + if (using_fuchsia_gn_sdk) { + extra_deps += [ + "$fuchsia_sdk_root/fidl/fuchsia.intl", + "$fuchsia_sdk_root/pkg/inspect", + "$fuchsia_sdk_root/pkg/inspect_service_cpp", + "$fuchsia_sdk_root/pkg/sys_cpp", + "$fuchsia_sdk_root/pkg/sys_inspect_cpp", + "$fuchsia_sdk_root/pkg/trace-engine", + ] + } else if (using_fuchsia_sdk) { extra_deps += [ "$fuchsia_sdk_root/fidl:fuchsia.deprecatedtimezone", "$fuchsia_sdk_root/pkg:inspect", @@ -114,7 +123,9 @@ library_for_all_configs_with_compiler("libdart_compiler") { sources = rebase_path(compiler_sources, ".", "./compiler/") include_dirs = [ ".." ] if (is_fuchsia) { - if (using_fuchsia_sdk) { + if (using_fuchsia_gn_sdk) { + extra_deps = [ "$fuchsia_sdk_root/pkg/trace-engine" ] + } else if (using_fuchsia_sdk) { extra_deps = [ "$fuchsia_sdk_root/pkg:trace-engine" ] } else { extra_deps = [ @@ -128,7 +139,9 @@ library_for_all_configs_with_compiler("libdart_compiler") { library_for_all_configs("libdart_lib") { target_type = "source_set" if (is_fuchsia) { - if (using_fuchsia_sdk) { + if (using_fuchsia_gn_sdk) { + extra_deps = [ "$fuchsia_sdk_root/pkg/trace-engine" ] + } else if (using_fuchsia_sdk) { extra_deps = [ "$fuchsia_sdk_root/pkg:trace-engine" ] } else { extra_deps = [ diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 7a5a283e3e9..c40f31babbb 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -332,7 +332,7 @@ if (target_cpu == "x64") { ignore_patterns = "{}" }, ] - if (is_linux || is_android) { + if (is_linux || is_android || is_fuchsia) { copy_tree_specs += [ { target = "copy_libtensorflowlite_c" diff --git a/sdk_nnbd/BUILD.gn b/sdk_nnbd/BUILD.gn index 368cc9bee25..887a1c4074d 100644 --- a/sdk_nnbd/BUILD.gn +++ b/sdk_nnbd/BUILD.gn @@ -332,7 +332,7 @@ if (target_cpu == "x64") { ignore_patterns = "{}" }, ] - if (is_linux || is_android) { + if (is_linux || is_android || is_fuchsia) { copy_tree_specs += [ { target = "copy_libtensorflowlite_c" diff --git a/tools/build.py b/tools/build.py index 895c698c52a..67d9dba8cf4 100755 --- a/tools/build.py +++ b/tools/build.py @@ -59,7 +59,7 @@ def BuildOptions(): result.add_option( "--os", help='Target OSs (comma-separated).', - metavar='[all,host,android]', + metavar='[all,host,android,fuchsia]', default='host') result.add_option( "--sanitizer", @@ -96,7 +96,7 @@ def ProcessOptions(options, args): if options.mode == 'all': options.mode = 'debug,release,product' if options.os == 'all': - options.os = 'host,android' + options.os = 'host,android,fuchsia' if options.sanitizer == 'all': options.sanitizer = 'none,asan,lsan,msan,tsan,ubsan' options.mode = options.mode.split(',') @@ -118,13 +118,12 @@ def ProcessOptions(options, args): return False options.os = [ProcessOsOption(os_name) for os_name in options.os] for os_name in options.os: - if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']: + if not os_name in [ + 'android', 'freebsd', 'linux', 'macos', 'win32', 'fuchsia' + ]: print("Unknown os %s" % os_name) return False - if os_name != HOST_OS: - if os_name != 'android': - print("Unsupported target os %s" % os_name) - return False + if os_name == 'android': if not HOST_OS in ['linux', 'macos']: print("Cross-compilation to %s is not supported on host os %s." % (os_name, HOST_OS)) @@ -143,6 +142,19 @@ def ProcessOptions(options, args): "For android builds you must specify a target, such as 'runtime'." ) return False + elif os_name == 'fuchsia': + if HOST_OS != 'linux': + print("Cross-compilation to %s is not supported on host os %s." + % (os_name, HOST_OS)) + return False + if arch != 'x64': + print( + "Cross-compilation to %s is not supported for architecture %s." + % (os_name, arch)) + return False + elif os_name != HOST_OS: + print("Unsupported target os %s" % os_name) + return False return True diff --git a/tools/gn.py b/tools/gn.py index 59d568de216..9ba8ef8bae8 100755 --- a/tools/gn.py +++ b/tools/gn.py @@ -288,7 +288,7 @@ def ProcessOptions(args): if args.mode == 'all': args.mode = 'debug,release,product' if args.os == 'all': - args.os = 'host,android' + args.os = 'host,android,fuchsia' if args.sanitizer == 'all': args.sanitizer = 'none,asan,lsan,msan,tsan,ubsan' args.mode = args.mode.split(',') @@ -309,13 +309,12 @@ def ProcessOptions(args): return False oses = [ProcessOsOption(os_name) for os_name in args.os] for os_name in oses: - if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']: + if not os_name in [ + 'android', 'freebsd', 'linux', 'macos', 'win32', 'fuchsia' + ]: print("Unknown os %s" % os_name) return False - if os_name != HOST_OS: - if os_name != 'android': - print("Unsupported target os %s" % os_name) - return False + if os_name == 'android': if not HOST_OS in ['linux', 'macos']: print("Cross-compilation to %s is not supported on host os %s." % (os_name, HOST_OS)) @@ -327,6 +326,19 @@ def ProcessOptions(args): "Cross-compilation to %s is not supported for architecture %s." % (os_name, arch)) return False + elif os_name == 'fuchsia': + if HOST_OS != 'linux': + print("Cross-compilation to %s is not supported on host os %s." + % (os_name, HOST_OS)) + return False + if arch != 'x64': + print( + "Cross-compilation to %s is not supported for architecture %s." + % (os_name, arch)) + return False + elif os_name != HOST_OS: + print("Unsupported target os %s" % os_name) + return False if HOST_OS != 'win' and args.use_crashpad: print("Crashpad is only supported on Windows") return False @@ -373,7 +385,7 @@ def parse_args(args): '--os', type=str, help='Target OSs (comma-separated).', - metavar='[all,host,android]', + metavar='[all,host,android,fuchsia]', default='host') common_group.add_argument( '--sanitizer', diff --git a/tools/utils.py b/tools/utils.py index 9097006ef96..09d71e348e3 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -314,7 +314,7 @@ def IsCrossBuild(target_os, arch): # there is no need to build a legacy version of the SDK for comparison purposes. def GetBuildConf(mode, arch, conf_os=None, sanitizer=None, dont_use_nnbd=False): nnbd = "Legacy" if dont_use_nnbd else "" - if conf_os == 'android': + if conf_os != GuessOS() and conf_os != "host": return '%s%s%s%s' % (GetBuildMode(mode), conf_os.title(), arch.upper(), nnbd) else: