blob: 2a389acf75f07da3a0e860fca4c854da3b750eb7 [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")
import("//zircon/kernel/arch/$zircon_cpu/phys/phys.gni")
import("zbi_executable.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" ] + phys_configs
# 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.
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" ]
include_dirs = [ "include" ]
}
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" ]
}
config("includes") {
include_dirs = [ "include" ]
}
source_set("symbolize") {
public = [
"include/phys/frame-pointer.h",
"include/phys/stack.h",
"include/phys/symbolize.h",
]
sources = [
"frame-pointer.cc",
"panic.cc",
"stack.cc",
"symbolize.cc",
]
deps = [
"//zircon/kernel/arch/$zircon_cpu/phys",
"//zircon/kernel/lib/ktl",
"//zircon/kernel/lib/libc",
]
public_deps = [
# "symbolize.h" has #include <phys/main.h>.
":main",
]
public_configs = [ ":includes" ]
}
# This is used implicitly by phys_executable() targets,
# including zbi_executable() targets.
source_set("phys_executable.deps") {
deps = [ ":symbolize" ]
}
# This is used implicitly by zbi_executable() targets.
source_set("zbi_executable.deps") {
sources = [
"zbi-header.S",
"zbi-main.cc",
]
deps = [
":arch-header",
":main",
":zbi-memory",
"//zircon/kernel/arch/$zircon_cpu/phys",
"//zircon/kernel/lib/arch",
"//zircon/kernel/lib/boot-options",
"//zircon/system/ulib/uart",
"//zircon/system/ulib/zbitl",
]
public_configs =
[ "//zircon/kernel/arch/$zircon_cpu/phys:zbi_executable.config" ]
}
# Transitive dependencies for the <phys/main.h> header.
source_set("main") {
public = [ "include/phys/main.h" ]
public_configs = [ ":includes" ]
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) {
public_deps += [
# "main.h" has #include <lib/static-pie/static-pie.h>
"//zircon/system/ulib/static-pie",
]
}
}
# Transitive dependencies for the <phys/arch.h> header.
source_set("arch-header") {
public = [ "include/phys/arch.h" ]
public_configs = [ ":includes" ]
public_deps = [
"//zircon/kernel/lib/libc",
"//zircon/kernel/phys/lib/memalloc",
"//zircon/system/ulib/zbitl",
]
}
# 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" ]
}
source_set("allocation") {
public = [ "include/phys/allocation.h" ]
sources = [ "allocation.cc" ]
deps = [
":main",
"//zircon/kernel/phys/lib/memalloc",
]
public_deps = [
"//zircon/kernel/lib/ktl",
"//zircon/kernel/lib/libc",
# allocation.h has #include <fbl/alloc_checker.h>.
"//zircon/system/ulib/fbl",
# allocation.h has #include <lib/fitx/result.h>.
"//zircon/system/ulib/zxc",
]
public_configs = [ ":includes" ]
}
source_set("zbitl-allocation") {
public = [ "include/phys/zbitl-allocation.h" ]
sources = [ "zbitl-allocation.cc" ]
deps = [
":allocation",
"//zircon/system/ulib/fbl",
]
public_deps = [
"//zircon/kernel/lib/ktl",
"//zircon/kernel/lib/libc",
# zbitl-allocation.h has #include <lib/fitx/result.h>.
"//zircon/system/ulib/zxc",
]
public_configs = [ ":includes" ]
}
# This is a little library instead of a source_set() so it can be included
# implicitly by zbi_executable() without adding bloat to the tiny tests that
# don't use it.
static_library("zbi-memory") {
sources = [ "zbi-memory.cc" ]
deps = [
":allocation",
":arch-header",
":main",
"//zircon/kernel/arch/$zircon_cpu/phys:address-space",
"//zircon/kernel/lib/arch",
"//zircon/kernel/phys/lib/memalloc",
"//zircon/kernel/phys/lib/page-table",
"//zircon/system/ulib/zbitl",
]
public_deps = [
"//zircon/kernel/lib/ktl",
"//zircon/kernel/lib/libc",
# allocation.h has #include <fbl/alloc_checker.h>.
"//zircon/system/ulib/fbl",
]
}
source_set("boot-zbi") {
public = [ "include/phys/boot-zbi.h" ]
sources = [ "boot-zbi.cc" ]
deps = [ "//zircon/kernel/lib/arch" ]
public_deps = [
":allocation",
"//zircon/kernel/lib/ktl",
"//zircon/kernel/lib/libc",
"//zircon/system/ulib/zbitl",
"//zircon/system/ulib/zxc",
]
}
}
group("tests") {
testonly = true
deps = [
"boot-shim:tests",
"lib:tests",
"test",
]
}
zbi_executable("physboot") {
sources = [ "physboot.cc" ]
deps = [
":allocation",
":boot-zbi",
":main",
":symbolize",
":zbitl-allocation",
"//zircon/kernel/lib/arch",
"//zircon/kernel/lib/boot-options",
"//zircon/kernel/lib/ktl",
"//zircon/kernel/lib/libc",
"//zircon/system/ulib/pretty",
"//zircon/system/ulib/zbitl",
]
}