diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /third_party/libwebrtc/build/config/nacl | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/build/config/nacl')
-rw-r--r-- | third_party/libwebrtc/build/config/nacl/BUILD.gn | 143 | ||||
-rw-r--r-- | third_party/libwebrtc/build/config/nacl/config.gni | 61 | ||||
-rw-r--r-- | third_party/libwebrtc/build/config/nacl/rules.gni | 180 |
3 files changed, 384 insertions, 0 deletions
diff --git a/third_party/libwebrtc/build/config/nacl/BUILD.gn b/third_party/libwebrtc/build/config/nacl/BUILD.gn new file mode 100644 index 0000000000..89fbf85aa5 --- /dev/null +++ b/third_party/libwebrtc/build/config/nacl/BUILD.gn @@ -0,0 +1,143 @@ +# Copyright (c) 2014 The Native Client Authors. 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/nacl/config.gni") + +# Native Client Definitions +config("nacl_defines") { + if (is_linux || is_chromeos || is_android || is_nacl) { + defines = [ + "_POSIX_C_SOURCE=199506", + "_XOPEN_SOURCE=600", + "_GNU_SOURCE=1", + "__STDC_LIMIT_MACROS=1", + ] + } else if (is_win) { + defines = [ "__STDC_LIMIT_MACROS=1" ] + } + + if (target_cpu == "pnacl" && !is_nacl_nonsfi) { + # TODO: Remove the following definition once NACL_BUILD_ARCH and + # NACL_BUILD_SUBARCH are defined by the PNaCl toolchain. + defines += [ "NACL_BUILD_ARCH=pnacl" ] + } +} + +config("nexe_defines") { + defines = [ + "DYNAMIC_ANNOTATIONS_ENABLED=1", + "DYNAMIC_ANNOTATIONS_PREFIX=NACL_", + ] +} + +config("nacl_warnings") { + if (is_win) { + # Some NaCl code uses forward declarations of static const variables, + # with initialized definitions later on. (The alternative would be + # many, many more forward declarations of everything used in that + # const variable's initializer before the definition.) The Windows + # compiler is too stupid to notice that there is an initializer later + # in the file, and warns about the forward declaration. + cflags = [ "/wd4132" ] + } +} + +# The base target that all targets in the NaCl build should depend on. +# This allows configs to be modified for everything in the NaCl build, even when +# the NaCl build is composed into the Chrome build. (GN has no functionality to +# add flags to everything in //native_client, having a base target works around +# that limitation.) +source_set("nacl_base") { + public_configs = [ + ":nacl_defines", + ":nacl_warnings", + ] + if (current_os == "nacl") { + public_configs += [ ":nexe_defines" ] + } +} + +config("compiler") { + configs = [] + cflags = [] + ldflags = [] + libs = [] + + if (is_clang && target_cpu != "pnacl") { + # -no-integrated-as is the default in nacl-clang for historical + # compatibility with inline assembly code and so forth. But there + # are no such cases in Chromium code, and -integrated-as is nicer in + # general. Moreover, the IRT must be built using LLVM's assembler + # on x86-64 to preserve sandbox base address hiding. Use it + # everywhere for consistency (and possibly quicker builds). + cflags += [ "-integrated-as" ] + } + if (is_nacl_nonsfi) { + cflags += [ "--pnacl-allow-translate" ] + ldflags += [ + "--pnacl-allow-translate", + "--pnacl-allow-native", + "-Wl,--noirt", + "-Wt,--noirt", + "-Wt,--noirtshim", + + # The clang driver automatically injects -lpthread when using libc++, but + # the toolchain doesn't have it yet. To get around this, use + # -nodefaultlibs and make each executable target depend on + # "//native_client/src/nonsfi/irt:nacl_sys_private". + "-nodefaultlibs", + ] + libs += [ + "c++", + "m", + "c", + "pnaclmm", + ] + include_dirs = [ "//native_client/src/public/linux_syscalls" ] + } + + asmflags = cflags +} + +config("compiler_codegen") { + cflags = [] + + if (is_nacl_irt) { + cflags += [ + # A debugger should be able to unwind IRT call frames. This is + # the default behavior on x86-64 and when compiling C++ with + # exceptions enabled; the change is for the benefit of x86-32 C. + # The frame pointer is unnecessary when unwind tables are used. + "-fasynchronous-unwind-tables", + "-fomit-frame-pointer", + ] + + if (target_cpu == "x86") { + # The x86-32 IRT needs to be callable with an under-aligned + # stack; so we disable SSE instructions, which can fault on + # misaligned addresses. See + # https://code.google.com/p/nativeclient/issues/detail?id=3935 + cflags += [ + "-mstackrealign", + "-mno-sse", + ] + } + } + + asmflags = cflags +} + +config("irt_optimize") { + cflags = [ + # Optimize for space, keep the IRT nexe small. + "-Os", + + # These are omitted from non-IRT libraries to keep the libraries + # themselves small. + "-ffunction-sections", + "-fdata-sections", + ] + + ldflags = [ "-Wl,--gc-sections" ] +} diff --git a/third_party/libwebrtc/build/config/nacl/config.gni b/third_party/libwebrtc/build/config/nacl/config.gni new file mode 100644 index 0000000000..9ebdb39c35 --- /dev/null +++ b/third_party/libwebrtc/build/config/nacl/config.gni @@ -0,0 +1,61 @@ +# Copyright 2015 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. + +declare_args() { + # Native Client supports multiple toolchains: + # - nacl_glibc, based on gcc and glibc. + # - pnacl_newlib, based on llvm 3.7 and newlib (default). + # - saigo_newlib, based on llvm 12+ and newlib. + + # True if nacl_glibc is used. + is_nacl_glibc = false + + # True if saigo_newlib is used. + is_nacl_saigo = false +} + +is_nacl_irt = false +is_nacl_nonsfi = false + +nacl_toolchain_dir = "//native_client/toolchain/${host_os}_x86" + +if (is_nacl_glibc) { + if (target_cpu == "x86" || target_cpu == "x64") { + nacl_toolchain_package = "nacl_x86_glibc" + } else if (target_cpu == "arm") { + nacl_toolchain_package = "nacl_arm_glibc" + } +} else { + nacl_toolchain_package = "pnacl_newlib" +} + +if (target_cpu == "pnacl") { + _nacl_tuple = "pnacl" +} else if (target_cpu == "x86" || target_cpu == "x64") { + _nacl_tuple = "x86_64-nacl" +} else if (target_cpu == "arm") { + _nacl_tuple = "arm-nacl" +} else if (target_cpu == "mipsel") { + _nacl_tuple = "mipsel-nacl" +} else { + # In order to allow this file to be included unconditionally + # from build files that can't depend on //components/nacl/features.gni + # we provide a dummy value that should be harmless if nacl isn't needed. + # If nacl *is* needed this will result in a real error, indicating that + # people need to set the toolchain path correctly. + _nacl_tuple = "unknown" +} + +nacl_toolchain_bindir = "${nacl_toolchain_dir}/${nacl_toolchain_package}/bin" +nacl_toolchain_tooldir = + "${nacl_toolchain_dir}/${nacl_toolchain_package}/${_nacl_tuple}" +nacl_toolprefix = "${nacl_toolchain_bindir}/${_nacl_tuple}-" + +nacl_irt_toolchain = "//build/toolchain/nacl:irt_" + target_cpu +is_nacl_irt = current_toolchain == nacl_irt_toolchain + +# Non-SFI mode is a lightweight sandbox used by Chrome OS for running ARC +# applications. +nacl_nonsfi_toolchain = "//build/toolchain/nacl:newlib_pnacl_nonsfi" +is_nacl_nonsfi = current_toolchain == nacl_nonsfi_toolchain diff --git a/third_party/libwebrtc/build/config/nacl/rules.gni b/third_party/libwebrtc/build/config/nacl/rules.gni new file mode 100644 index 0000000000..42bb248357 --- /dev/null +++ b/third_party/libwebrtc/build/config/nacl/rules.gni @@ -0,0 +1,180 @@ +# Copyright 2015 The Native Client Authors. 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/nacl/config.gni") + +# Generate a nmf file +# +# Native Client Manifest (nmf) is a JSON file that tells the browser where to +# download and load Native Client application files and libraries. +# +# Variables: +# executables: .nexe/.pexe/.bc executables to generate nmf for +# lib_prefix: path to prepend to shared libraries in the nmf +# nmf: the name and the path of the output file +# nmfflags: additional flags for the nmf generator +# stage_dependencies: directory for staging libraries +template("generate_nmf") { + assert(defined(invoker.executables), "Must define executables") + assert(defined(invoker.nmf), "Must define nmf") + + action(target_name) { + forward_variables_from(invoker, + [ + "deps", + "data_deps", + "executables", + "lib_prefix", + "nmf", + "nmfflags", + "public_deps", + "stage_dependencies", + "testonly", + "visibility", + ]) + if (!defined(nmfflags)) { + nmfflags = [] + } + + # TODO(phosek): Remove this conditional once + # https://bugs.chromium.org/p/nativeclient/issues/detail?id=4339 is + # resolved. + if (target_cpu == "pnacl") { + objdump = rebase_path("${nacl_toolchain_bindir}/x86_64-nacl-objdump") + } else { + objdump = rebase_path("${nacl_toolprefix}objdump") + } + if (host_os == "win") { + objdump += ".exe" + } + + script = "//native_client_sdk/src/tools/create_nmf.py" + inputs = [ objdump ] + sources = executables + outputs = [ nmf ] + if (is_nacl_glibc) { + if (defined(stage_dependencies)) { + nmfflags += [ "--stage-dependencies=" + + rebase_path(stage_dependencies, root_build_dir) ] + lib_path = stage_dependencies + } else { + lib_path = root_build_dir + } + if (defined(lib_prefix)) { + nmfflags += [ "--lib-prefix=" + lib_prefix ] + lib_path += "/${lib_prefix}" + } + + # Starts empty so the code below can use += everywhere. + data = [] + + nmfflags += + [ "--library-path=" + rebase_path(root_out_dir, root_build_dir) ] + + # NOTE: There is no explicit dependency for the lib directory + # (lib32 and lib64 for x86/x64) created in the product directory. + # They are created as a side-effect of nmf creation. + if (target_cpu != "x86" && target_cpu != "x64") { + nmfflags += + [ "--library-path=" + + rebase_path("${nacl_toolchain_tooldir}/lib", root_build_dir) ] + if (target_cpu == "arm") { + data += [ "${lib_path}/libarm/" ] + } else { + data += [ "${lib_path}/lib/" ] + } + } else { + # For x86-32, the lib/ directory is called lib32/ instead. + if (target_cpu == "x86") { + nmfflags += + [ "--library-path=" + + rebase_path("${nacl_toolchain_tooldir}/lib32", root_build_dir) ] + data += [ "${lib_path}/lib32/" ] + } + + # x86-32 Windows needs to build both x86-32 and x86-64 NaCl + # binaries into the same nmf covering both architectures. That + # gets handled at a higher level (see the nacl_test_data template), + # so a single generate_nmf invocation gets both x86-32 and x86-64 + # nexes listed in executables. + if (target_cpu == "x64" || target_os == "win") { + # For x86-64, the lib/ directory is called lib64/ instead + # when copied by create_nmf.py. + glibc_tc = "//build/toolchain/nacl:glibc" + assert(current_toolchain == "${glibc_tc}_${target_cpu}") + if (target_cpu == "x64") { + x64_out_dir = root_out_dir + } else { + x64_out_dir = get_label_info(":${target_name}(${glibc_tc}_x64)", + "root_out_dir") + } + nmfflags += [ + "--library-path=" + rebase_path(x64_out_dir, root_build_dir), + "--library-path=" + + rebase_path("${nacl_toolchain_tooldir}/lib", root_build_dir), + ] + data += [ "${lib_path}/lib64/" ] + } + } + } + args = [ + "--no-default-libpath", + "--objdump=" + rebase_path(objdump, root_build_dir), + "--output=" + rebase_path(nmf, root_build_dir), + ] + nmfflags + rebase_path(sources, root_build_dir) + if (is_nacl_glibc && target_cpu == "arm") { + deps += [ "//native_client/src/untrusted/elf_loader:elf_loader" ] + } + } +} + +# Generate a nmf file for Non-SFI tests +# +# Non-SFI tests use a different manifest format from regular Native Client and +# as such requires a different generator. +# +# Variables: +# executable: Non-SFI .nexe executable to generate nmf for +# nmf: the name and the path of the output file +# nmfflags: additional flags for the nmf generator +template("generate_nonsfi_test_nmf") { + assert(defined(invoker.executable), "Must define executable") + assert(defined(invoker.nmf), "Must define nmf") + + action(target_name) { + forward_variables_from(invoker, + [ + "deps", + "data_deps", + "executable", + "nmf", + "testonly", + "public_deps", + "visibility", + ]) + + script = "//ppapi/tests/create_nonsfi_test_nmf.py" + sources = [ executable ] + outputs = [ nmf ] + + # NOTE: We use target_cpu rather than target_cpu on purpose because + # target_cpu is always going to be pnacl for Non-SFI, but the Non-SFI + # .nexe executable is always translated to run on the target machine. + if (target_cpu == "x86") { + arch = "x86-32" + } else if (target_cpu == "x64") { + arch = "x86-64" + } else { + arch = target_cpu + } + args = [ + "--program=" + rebase_path(executable, root_build_dir), + "--arch=${arch}", + "--output=" + rebase_path(nmf, root_build_dir), + ] + if (defined(invoker.nmfflags)) { + args += invoker.nmfflags + } + } +} |