blob: eba327add67d17a1cedcb2663e079837f41a4a34 [file] [log] [blame]
# Copyright 2019 The Fuchsia 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("$zx_build/public/gn/toolchain/environment_redirect.gni")
zx_library("mini-process") {
testonly = true
shared = true
sources = [
"mini-process.c",
]
deps = [
":subprocess",
"$zx/system/ulib/elf-psabi",
"$zx/system/ulib/elfload",
"$zx/system/ulib/zircon",
]
}
# This code goes into the mini-process where it doesn't have any runtime
# environment, so it must be compiled specially.
if (toolchain.tags + [ "instrumented" ] - [ "instrumented" ] !=
toolchain.tags) {
# Instrumented variants will just never work for this code. So
# redirect to the default uninstrumented variant to compile this file.
environment_redirect("subprocess") {
visibility = [ ":*" ]
testonly = true
exclude_variant_tags = [ "instrumented" ]
deps = [
":subprocess",
]
}
} else {
source_set("subprocess") {
visibility = [ ":*" ]
testonly = true
sources = [
"subprocess.c",
]
deps = [
":headers",
"$zx/system/ulib/backtrace-request",
"$zx/system/ulib/zircon",
]
configs += [
# No real sanitizers should be enabled in this variant anyway.
# But this also disables SafeStack, which is on by default.
"$zx_build/public/gn/config:no_sanitizers",
# This defeats optimizations that break the assumptions.
":subprocess.config",
]
}
config("subprocess.config") {
visibility = [ ":subprocess" ]
# Always compile with some optimization so that always_inline functions
# actually get inlined (which they don't at -O0). Less optimization than
# the default should not be a problem for this code and might actually be
# helpful because of its special constraints (see subprocess.c).
cflags = [ "-O1" ]
}
}