xref: /aosp_15_r20/external/cronet/build/config/fuchsia/BUILD.gn (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2017 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build/config/clang/clang.gni")
6import("//build/config/fuchsia/generate_runner_scripts.gni")
7import("//build/config/fuchsia/gn_configs.gni")
8
9assert(is_fuchsia)
10assert(!is_posix, "Fuchsia is not POSIX.")
11
12config("compiler") {
13  configs = [ "//third_party/fuchsia-gn-sdk/src/config:compiler" ]
14
15  # TODO(https://crbug.com/706592): The stack defaults to 256k on Fuchsia (see
16  # https://fuchsia.googlesource.com/zircon/+/master/system/private/zircon/stack.h#9),
17  # but on other platforms it's much higher, so a variety of code assumes more
18  # will be available. Raise to 8M which matches e.g. macOS.
19  ldflags = [
20    "-Wl,-z,stack-size=0x800000",
21    "-fexperimental-relative-c++-abi-vtables",
22  ]
23  cflags_cc = [ "-fexperimental-relative-c++-abi-vtables" ]
24}
25
26# Files required to run on Fuchsia on isolated swarming clients.
27group("deployment_resources") {
28  data = [
29    "//build/fuchsia/",
30    "//build/util/lib/",
31    "//third_party/fuchsia-sdk/sdk/.build-id/",
32    "//third_party/fuchsia-sdk/sdk/meta/manifest.json",
33    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/ffx",
34    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/ffx-meta.json",
35    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/fvm",
36    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/fvm-meta.json",
37    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/merkleroot",
38    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/merkleroot-meta.json",
39    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/pm",
40    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/pm-meta.json",
41    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/symbolizer",
42    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/symbolizer-meta.json",
43    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/zbi",
44    "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/zbi-meta.json",
45  ]
46
47  if (fuchsia_additional_boot_images == []) {
48    data += [ "${boot_image_root}" ]
49  }
50
51  foreach(fuchsia_additional_boot_image, fuchsia_additional_boot_images) {
52    data += [ "${fuchsia_additional_boot_image}/" ]
53  }
54
55  if (test_isolate_uses_emulator) {
56    data += [
57      "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/ffx_tools/ffx-emu",
58      "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/ffx_tools/ffx-emu.json",
59      "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/ffx_tools/ffx-emu-meta.json",
60    ]
61    if (test_host_cpu == "x64") {
62      data += [
63        "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/aemu_internal",
64        "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/aemu_internal-meta.json",
65        "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/qemu_internal",
66        "//third_party/fuchsia-sdk/sdk/tools/${test_host_cpu}/qemu_internal-meta.json",
67      ]
68    } else if (test_host_cpu == "arm64") {
69      data += [
70        "//third_party/qemu-${host_os}-${test_host_cpu}/",
71
72        # TODO(https://crbug.com/1336776): remove when ffx has native support
73        # for starting emulator on arm64 host.
74        "//third_party/fuchsia-sdk/sdk/tools/x64/qemu_internal-meta.json",
75      ]
76    }
77  }
78}
79
80# Copy the loader to place it at the expected path in the final package.
81copy("sysroot_asan_libs") {
82  sources = [ "${fuchsia_arch_root}/sysroot/dist/lib/asan/ld.so.1" ]
83  outputs = [ "${root_out_dir}/lib/asan/{{source_file_part}}" ]
84}
85
86# Copy the loader to place it at the expected path in the final package.
87copy("sysroot_asan_runtime_libs") {
88  sources = [ "$clang_base_path/lib/clang/$clang_version/lib/x86_64-unknown-fuchsia/libclang_rt.asan.so" ]
89  outputs = [ "${root_out_dir}/lib/{{source_file_part}}" ]
90}
91
92# This adds the runtime deps for Fuchsia ASAN builds.
93group("asan_runtime_library") {
94  data_deps = [
95    ":sysroot_asan_libs",
96    ":sysroot_asan_runtime_libs",
97  ]
98}
99
100# rustc gives the linker (clang++) "-pie" directives. clang++ complains on
101# Fuchsia that these don't make any sense. On Fuchsia alone, for Rust-linked
102# targets only, disable these warnings.
103config("rustc_no_pie_warning") {
104  ldflags = [ "-Wno-unused-command-line-argument" ]
105}
106