blob: 1ac310125662240c1537b7aff033a1a31f0d3739 [file] [log] [blame]
# Copyright 2020 The Fuchsia Authors
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT
import("//build/config/zircon/standard.gni")
import("//build/toolchain/zircon/zircon_toolchain_suite.gni")
import("//build/unification/global_variables.gni")
if (current_toolchain == default_toolchain) {
# Default toolchain (current_cpu == "") just defines the phys environment.
# Note: see //zircon/kernel/arch/x86/phys:kernel.phys32 too.
foreach(cpu, standard_fuchsia_cpus) {
kernel_cpu = cpu
if (kernel_cpu == "x64") {
kernel_cpu = "x86"
}
zircon_toolchain_suite("kernel.phys_$cpu") {
cpu = cpu
os = "fuchsia"
environment = "kernel.phys"
with_shared = false
toolchain_tags = [ "kernel" ]
configs = [ "//zircon/kernel/phys:phys_config" ]
# Always enable frame pointers. This works because frame_pointers
# is added as part of :phys_config below.
remove_common_configs = [ "//build/config/zircon:default_frame_pointers" ]
exclude_variant_tags = [
# There is no possibility of fancy runtimes like ASan for phys.
"instrumentation-runtime",
# TOOD(51994): Remove this when profile is supported.
"instrumented",
]
# Append the arch-specific lists. The phys/phys.gni file in each
# arch subdirectory defines phys_* lists to append to the parameters.
import("//zircon/kernel/arch/$kernel_cpu/phys/phys.gni")
toolchain_tags += phys_tags
exclude_variant_tags += phys_exclude_variant_tags
}
}
} else if (toolchain.environment == "kernel.phys") {
kernel_cpu = current_cpu
if (current_cpu == "x64") {
kernel_cpu = "x86"
}
config("phys_config") {
configs = [
"//zircon/kernel:standalone",
"//zircon/kernel:warnings",
"//zircon/kernel/arch/$kernel_cpu:abi",
":defines",
# Don't emit extra code making static initializers thread-safe (we don't
# have threads or any of the corresponding library support.)
"//build/config/zircon:no_threadsafe_statics",
# All physmem code is inherently sensitive and in a position for
# any bug to be unusually dangerous. So compile with minimal
# undefined behavior checking in all builds, regardless of variant.
"//build/config/zircon/instrumentation:ubsan-trap",
]
# Always enable frame pointers.
configs += [ "//build/config/zircon:frame_pointers" ]
# Add arch-specific configs here. The reason this is not done
# in the zircon_toolchain_suite() call is because every config listed
# in toolchain_variant_args.configs 'foo' needs to have a corresponding
# 'foo_deps' group.
import("//zircon/kernel/arch/$kernel_cpu/phys/phys.gni")
configs += phys_configs
}
group("phys_config_deps") {
}
}
if (toolchain.environment == "kernel.phys" ||
toolchain.environment == "kernel.phys32") {
# All the code gets built here in the phys environment.
config("defines") {
# Always enable tests and asserts in phys code.
defines = [ "LK_DEBUGLEVEL=2" ]
}
source_set("phys_executable.headers") {
public = [
"frame-pointer.h",
"stack.h",
"symbolize.h",
]
# symnbolize.h includes main.h
public_deps = [ ":main" ]
}
# This is used implicitly by phys_executable() targets,
# including zbi_executable() targets.
source_set("phys_executable.deps") {
sources = [
"frame-pointer.cc",
"panic.cc",
"stack.cc",
"symbolize.cc",
]
deps = [
":main",
":phys_executable.headers",
"//zircon/kernel/arch/$zircon_cpu/phys",
"//zircon/kernel/lib/ktl",
"//zircon/kernel/lib/libc",
]
}
# This is used implicitly by zbi_executable() targets.
source_set("zbi_executable.deps") {
sources = [
"decompress.cc",
"memory.cc",
"zbi-header.S",
"zbi-main.cc",
]
deps = [
":main",
"//zircon/kernel/lib/arch",
"//zircon/kernel/lib/boot-options",
"//zircon/kernel/phys/lib/memalloc",
"//zircon/system/ulib/uart",
"//zircon/system/ulib/zbitl",
]
public_configs =
[ "//zircon/kernel/arch/$zircon_cpu/phys:zbi_executable.config" ]
}
# Things in other directories include main.h by source-absolute path.
# But they put this in their deps to get its transitive deps.
source_set("main") {
sources = [ "main.h" ]
public_deps = [
# "main.h" has #include <lib/arch/ticks.h>.
"//zircon/kernel/lib/arch",
]
# If the toolchain is compiling a PIE executable, include required libraries.
if (toolchain.tags + [ "static-pie" ] - [ "static-pie" ] !=
toolchain.tags) {
# "main.h" has #include <lib/static-pie/static-pie.h>
public_deps += [ "//zircon/system/ulib/static-pie" ]
}
}
# This is linked into the special-case phys_executable() tests that
# are run directly as QEMU kernels.
source_set("qemu-header") {
sources = [ "qemu-header.S" ]
public_configs = [ "//zircon/kernel/arch/$zircon_cpu/phys:qemu.config" ]
}
}
group("tests") {
testonly = true
deps = [
"lib:tests",
"test",
]
}