blob: fda8300345ef97cd83dc49255cb4ae1a766651ed [file] [log] [blame]
# Copyright 2025 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("//src/zircon/lib/zircon/libzircon.gni")
import("../libc.gni")
# This is only included in the new implementation.
libc_source_set("threads") {
sources = []
libc_deps = [
":thread-storage",
# TODO(https://fxbug.dev/342469121): This is still needed by the musl
# threads code post-startup. When thread creation uses ThreadStorage
# too, this can be removed.
":thread-list.musl-glue",
]
}
# This doesn't need to be libc_source_set() because it's just a header.
source_set("shadow-call-stack") {
public = [ "shadow-call-stack.h" ]
public_deps = [ "//zircon/kernel/lib/arch" ]
sources = []
}
libc_source_set("thread-storage") {
public = [ "thread-storage.h" ]
libc_public_deps = [ "../zircon:vmar" ]
public_deps = [
":shadow-call-stack",
"//src/lib/elfldltl:headers",
"//zircon/system/ulib/zx",
# TODO(https://fxbug.dev/342469121): remove when :musl-tls is removed
"..:asm-linkage",
]
sources = [ "thread-storage.cc" ]
deps = [ "//zircon/third_party/ulib/musl:musl_internal" ]
}
group("unittests") {
testonly = true
deps = [ ":thread-storage-tests" ]
}
libc_test("thread-storage-tests") {
sources = [ "thread-storage-tests.cc" ]
include_dirs = [ "//sdk/lib/ld/test/modules" ]
deps = [
":thread-storage.testonly",
"../test:safe-zero-construction",
"//sdk/lib/fit",
"//sdk/lib/ld:headers",
"//sdk/lib/ld/test/modules:tls-desc-dep.shared_library",
"//sdk/lib/ld/testing:ld-abi-testing",
"//src/lib/elfldltl",
"//zircon/third_party/ulib/musl:musl_internal",
]
}
source_set("mutex") {
public = [ "mutex.h" ]
public_deps = [ "//zircon/system/ulib/sync:sync-cpp" ]
sources = []
}
libc_source_set("thread-list") {
public_deps = [ ":thread-list.headers" ]
sources = [ "thread-list.cc" ]
}
# TODO(https://fxbug.dev/342469121): This can be folded into :thread-list when
# musl-glue doesn't use basic_abi.
source_set("thread-list.headers") {
visibility = [ ":*" ]
public = [ "thread-list.h" ]
public_deps = [
":mutex",
"//zircon/third_party/ulib/musl:musl_internal",
]
deps = [ "..:asm-linkage" ]
}
# This is linked into the legacy libc.so to implement the entry points used by
# the legacy implementation.
libc_source_set("musl-glue") {
sources = []
libc_deps = [
":thread-list",
":thread-list.musl-glue",
]
}
libc_source_set("thread-list.musl-glue") {
visibility = [ ":*" ]
basic_abi = true
global_symbols = [
"__thread_list_add",
"__thread_list_erase",
"__thread_list_start",
]
undefined_symbols = [
"${libc_namespace}_gAllThreads",
"${libc_namespace}_gAllThreadsLock",
"${libc_namespace}_gLog",
"_zx_thread_self",
]
undefined_symbols += libzircon_linkage_names
sources = [ "musl-thread-list.cc" ]
deps = [
":thread-list.headers",
"../ld:log-panic",
"//zircon/third_party/ulib/musl:musl_internal",
]
}
source_set("zxr-tls") {
visibility = [
"../*",
"//zircon/third_party/ulib/musl/*",
]
public = [ "zxr-tls.h" ]
public_deps = [ "//src/zircon/lib/zircon:headers" ]
}
libc_source_set("zxr-thread") {
visibility = [
"../*",
"//zircon/third_party/ulib/musl/*",
]
public = [ "zxr-thread.h" ]
sources = [ "zxr-thread.cc" ]
deps = [
"//src/lib/elfldltl:headers",
"//src/zircon/lib/zircon:zircon.as-needed",
"//zircon/system/ulib/zircon-internal",
]
# This code is used in early startup, where safe-stack is not ready yet.
configs = [ "//build/config/sanitizers:no_sanitizers" ]
# This might be necessary if something from libc++ didn't get inlined. A
# libc++ ABI symbol that's supposedly the same might be COMDAT'd with another
# TU's version that didn't disable the sanitizers.
defines = [ "_LIBCPP_HIDE_FROM_ABI_PER_TU=1" ]
# Make sure the thread_trampoline function has a frame pointer so that
# user-visible thread backtraces are consistent across collection methods.
remove_configs = [ "//build/config:default_frame_pointers" ]
configs += [ "//build/config:frame_pointers" ]
}