1 Star 0 Fork 554

孙超/third_party_musl

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
musl_template.gni 27.69 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
import("//base/startup/init/begetd.gni")
import("//build/config/clang/clang.gni")
import("//build/ohos.gni")
import("//third_party/optimized-routines/optimized-routines.gni")
import("musl_src.gni")
template("musl_libs") {
no_default_deps = true
forward_variables_from(invoker, [ "*" ])
_libs_path_prefix = "."
_libs_out_dir = "usr/lib/${musl_target_triple}"
dfx_deps = [ "//base/hiviewdfx/faultloggerd/interfaces/innerkits/signal_handler:dfxsignalhandler" ]
porting_deps = [
"//third_party/musl:create_alltypes_h",
"//third_party/musl:create_porting_src",
"//third_party/musl:create_syscall_h",
"//third_party/musl:create_version_h",
]
group(target_name) {
deps = [
":soft_create_linker",
":soft_libc_musl_shared",
":soft_libc_musl_static",
":soft_musl_crt_libs",
]
}
group("soft_shared_libs") {
deps = [
":musl_headers",
":soft_libc_musl_shared",
":soft_libcrypt",
":soft_libdl",
":soft_libm",
":soft_libpthread",
":soft_libresolv",
":soft_librt",
":soft_libutil",
":soft_libxnet",
":soft_musl_crt_libs",
]
}
group("soft_static_libs") {
deps = [
":musl_headers",
":soft_libc_musl_static",
":soft_libcrypt",
":soft_libdl",
":soft_libm",
":soft_libpthread",
":soft_libresolv",
":soft_librt",
":soft_libutil",
":soft_libxnet",
":soft_musl_crt_libs",
]
}
group("soft_musl_crt_libs") {
deps = [ ":soft_musl_crt_install_action" ]
}
# part of default_compiler_configs from build/config/BUILDCONFIG.gn
musl_inherited_configs = [
"//build/config/compiler:afdo",
"//build/config/compiler:afdo_optimize_size",
"//build/config/compiler:compiler",
"//build/config/compiler:compiler_arm_fpu",
"//build/config/compiler:compiler_arm_thumb",
"//build/config/compiler:chromium_code",
"//build/config/compiler:default_include_dirs",
"//build/config/compiler:default_optimization",
"//build/config/compiler:default_stack_frames",
"//build/config/compiler:default_symbols",
"//build/config/compiler:export_dynamic",
"//build/config/compiler:no_exceptions",
"//build/config/compiler:no_rtti",
"//build/config/compiler:runtime_library",
"//build/config/compiler:thin_archive",
"//build/config/sanitizers:default_sanitizer_flags",
]
config("soft_musl_config") {
configs = [
"//build/config/compiler:compiler_cpu_abi",
"//build/config/coverage:default_coverage",
]
include_dirs = [
"${target_out_dir}/${musl_ported_dir}/arch/${musl_arch}",
"${target_out_dir}/${musl_ported_dir}/arch/generic",
"${target_out_dir}/${musl_ported_dir}/src/internal",
"${target_out_dir}/${musl_ported_dir}/src/include",
"${target_out_dir}/${musl_ported_dir}/include",
"${target_out_dir}/${musl_inc_out_dir}",
]
cflags_basic = [
"--target=${musl_target_triple}",
"-Wall",
"-D_FORTIFY_SOURCE=2",
"-Wl,-z,relro,-z,now,-z,noexecstack",
]
if (musl_arch == "arm") {
cflags_basic += [ "-mtp=cp15" ]
} else if (musl_arch == "aarch64") {
}
cflags_auto = [
"-D_XOPEN_SOURCE=700",
"-g",
"-pipe",
"-fno-omit-frame-pointer",
"-funwind-tables",
"-fasynchronous-unwind-tables",
"-ffunction-sections",
"-fdata-sections",
"-Werror=implicit-function-declaration",
"-Werror=implicit-int",
"-Werror=pointer-sign",
"-Werror=pointer-arith",
"-Qunused-arguments",
"-Wno-int-conversion",
]
if (!is_asan) {
cflags_auto += [
"-DHOOK_ENABLE",
"-DOHOS_SOCKET_HOOK_ENABLE",
]
}
if (use_pthread_cancel) {
cflags_auto += [ "-DFEATURE_PTHREAD_CANCEL" ]
}
cflags_auto += [ "-DRESERVE_SIGNAL_STACK" ]
cflags_auto += [ "-DDFX_SIGNAL_LIBC" ]
cflags_c99fse = [
"-std=c99",
"-nostdinc",
"-Wa,--noexecstack",
]
cflags_all = cflags_basic + cflags_c99fse + cflags_auto
cflags = cflags_all
defines = [ "BROKEN_VFP_ASM" ]
defines += [ "FEATURE_ATEXIT_CB_PROTECT" ]
if (is_standard_system) {
defines += [
"OHOS_DNS_PROXY_BY_NETSYS=1",
"OHOS_PERMISSION_INTERNET=1",
"STANDARD_SYSTEM",
]
}
if (!is_standard_system && defined(enable_musl_log)) {
if (enable_musl_log) {
defines += [ "ENABLE_MUSL_LOG" ]
}
}
dynamic_list =
rebase_path("${target_out_dir}/${musl_ported_dir}/dynamic.list")
ldflags = cflags_all
ldflags += [
"--target=${musl_target_triple}",
"-fuse-ld=lld",
"-Wl,--sort-section,alignment",
"-Wl,--sort-common",
"-Wl,--gc-sections",
"-Wl,--hash-style=both",
"-Wl,--no-undefined",
"-Wl,--exclude-libs=ALL",
"-Wl,--dynamic-list=${dynamic_list}",
]
asmflags = cflags
}
config("soft_hook") {
defines = []
configs = [ "//build/config/coverage:default_coverage" ]
if (is_posix) {
configs += [ "//build/config/posix:runtime_library" ]
}
cflags_cc = []
defines = [
"__GNU_SOURCE=1", # Necessary for clone().
"CHROMIUM_CXX_TWEAK_INLINES", # Saves binary size.
]
defines += [
"__MUSL__",
"_LIBCPP_HAS_MUSL_LIBC",
"__BUILD_LINUX_WITH_CLANG",
]
if (!is_asan) {
defines += [
"HOOK_ENABLE",
"OHOS_SOCKET_HOOK_ENABLE",
]
}
ldflags = [ "-nostdlib" ]
libs = []
if (is_component_build) {
defines += [ "COMPONENT_BUILD" ]
}
}
config("soft_jemalloc") {
configs = [ "//build/config/coverage:default_coverage" ]
include_dirs = [
"${target_out_dir}/${musl_ported_dir}/arch/${musl_arch}",
"${target_out_dir}/${musl_ported_dir}/arch/generic",
"${target_out_dir}/${musl_ported_dir}/src/internal",
"${target_out_dir}/${musl_ported_dir}/src/include",
"${target_out_dir}/${musl_ported_dir}/include",
"${target_out_dir}/${musl_inc_out_dir}",
"${clang_base_path}/lib/clang/${clang_version}/include",
]
cflags = [
"--target=${musl_target_triple}",
"-D_GNU_SOURCE",
"-D_REENTRANT",
"-Wall",
"-Wshorten-64-to-32",
"-Wsign-compare",
"-Wundef",
"-Wno-format-zero-length",
"-pipe",
"-g3",
"-fvisibility=hidden",
"-O3",
"-funroll-loops",
"-funwind-tables",
# The following flags are for avoiding errors when compiling.
"-Wno-unused-parameter",
"-Wno-unused-function",
"-Wno-missing-field-initializers",
"-U_FORTIFY_SOURCE",
"-DOHOS_ENABLE_TCACHE", # For jemalloc 5.X
"-DJEMALLOC_TCACHE", # For jemalloc 4.X
"-DOHOS_LG_TCACHE_MAXCLASS_DEFAULT=16",
"-DOHOS_NUM_ARENAS=2", # For jemalloc 5.X
"-DOHOS_MAX_ARENAS=2", # For jemalloc 4.X
"-DOHOS_TCACHE_NSLOTS_SMALL_MAX=8",
"-DOHOS_TCACHE_NSLOTS_LARGE=16",
]
if (is_debug || musl_secure_level > 1) {
cflags += [ "-DOHOS_TCACHE_NSLOTS_RANDOM" ]
}
if (musl_arch == "arm") {
cflags += [
"-march=armv7-a",
"-DOHOS_LG_CHUNK_DEFAULT=19", # For jemalloc 4.X
]
} else if (musl_arch == "aarch64") {
cflags += [
"-march=armv8",
"-DOHOS_LG_CHUNK_DEFAULT=19", # For jemalloc 4.X
]
} else if (musl_arch == "x86_64") {
cflags += [ "-march=x86-64" ]
}
include_dirs += [
"//third_party",
"//third_party/musl/src/include/",
"//third_party/jemalloc/include/",
"//third_party/jemalloc/include/jemalloc/internal",
"//third_party/jemalloc/include/jemalloc",
]
}
source_set("soft_musl_crt") {
sources = [
"${target_out_dir}/${musl_ported_dir}/crt/${musl_arch}/crti.s",
"${target_out_dir}/${musl_ported_dir}/crt/${musl_arch}/crtn.s",
"${target_out_dir}/${musl_ported_dir}/crt/Scrt1.c",
"${target_out_dir}/${musl_ported_dir}/crt/crt1.c",
"${target_out_dir}/${musl_ported_dir}/crt/crtplus.c",
"${target_out_dir}/${musl_ported_dir}/crt/rcrt1.c",
]
defines = [ "CRT" ]
configs -= musl_inherited_configs
configs += [ ":soft_musl_config" ]
cflags = [
"-fPIC",
"-ffreestanding",
"-fno-stack-protector",
]
deps = porting_deps
asmflags = cflags
}
source_set("soft_musl_src") {
sources_orig = []
sources = []
sources_orig = musl_src_arch_file + musl_src_file
sources_orig -= musl_src_filterout
sources_orig -= [
"src/string/mempcpy.c",
"src/string/memset.c",
"src/env/__init_tls.c",
"src/env/__libc_start_main.c",
"src/env/__stack_chk_fail.c",
]
if (musl_arch == "arm") {
sources_orig -= [
"src/thread/${musl_arch}/__set_thread_area.c",
"src/string/arm/memcpy.S",
"src/string/memchr.c",
"src/string/strcmp.c",
"src/string/strlen.c",
"src/math/sincosf.c",
"src/math/expf.c",
"src/math/exp2f.c",
"src/math/exp2l.c",
"src/math/exp2.c",
"src/math/log.c",
"src/math/logl.c",
"src/math/log2.c",
"src/math/log2f.c",
"src/math/log2l.c",
"src/math/logf.c",
"src/math/log_data.c",
"src/math/logf_data.c",
"src/math/log2_data.c",
"src/math/log2f_data.c",
"src/math/exp2f_data.c",
"src/math/pow.c",
"src/math/powf.c",
"src/math/powl.c",
"src/math/sinf.c",
"src/math/cosf.c",
]
} else if (musl_arch == "aarch64") {
sources_orig -= [
"src/thread/${musl_arch}/__set_thread_area.s",
"src/string/memcpy.c",
"src/string/memmove.c",
"src/string/memchr.c",
"src/string/memcmp.c",
"src/string/strcpy.c",
"src/string/strcmp.c",
"src/string/strlen.c",
"src/string/stpcpy.c",
"src/string/strchr.c",
"src/string/strrchr.c",
"src/string/strnlen.c",
"src/string/strncmp.c",
"src/math/sincosf.c",
"src/math/sinf.c",
"src/math/cosf.c",
"src/math/cos.c",
"src/math/exp.c",
"src/math/exp2.c",
"src/math/exp2f.c",
"src/math/expf.c",
"src/math/log.c",
"src/math/log10.c",
"src/math/log2.c",
"src/math/log2f.c",
"src/math/logb.c",
"src/math/logf.c",
"src/math/sin.c",
"src/math/sincos.c",
"src/math/pow.c",
"src/math/powf.c",
]
} else if (musl_arch == "x86_64") {
sources_orig -= [ "src/thread/${musl_arch}/__set_thread_area.s" ]
}
defines = []
if (musl_arch == "arm") {
defines += [ "MUSL_ARM_ARCH" ]
}
if (musl_arch == "aarch64") {
defines += [ "MUSL_AARCH64_ARCH" ]
}
if (musl_arch == "x86_64") {
defines += [ "MUSL_X86_64_ARCH" ]
}
if (musl_secure_level > 0) {
defines += [ "MALLOC_FREELIST_HARDENED" ]
}
if (musl_secure_level > 1) {
defines += [ "MALLOC_FREELIST_QUARANTINE" ]
}
if (musl_secure_level > 2) {
defines += [ "MALLOC_RED_ZONE" ]
}
if (is_debug || musl_secure_level >= 3) {
defines += [ "MALLOC_SECURE_ALL" ]
}
if (musl_iterate_and_stats_api) {
defines += [ "MUSL_ITERATE_AND_STATS_API" ]
}
foreach(s, sources_orig) {
sources += [ "${target_out_dir}/${musl_ported_dir}/${s}" ]
}
if (musl_arch == "arm") {
sources += [
"$OPTRTDIR/math/cosf.c",
"$OPTRTDIR/math/exp2.c",
"$OPTRTDIR/math/exp2f.c",
"$OPTRTDIR/math/exp2f_data.c",
"$OPTRTDIR/math/expf.c",
"$OPTRTDIR/math/log.c",
"$OPTRTDIR/math/log2.c",
"$OPTRTDIR/math/log2_data.c",
"$OPTRTDIR/math/log2f.c",
"$OPTRTDIR/math/log2f_data.c",
"$OPTRTDIR/math/log_data.c",
"$OPTRTDIR/math/logf.c",
"$OPTRTDIR/math/logf_data.c",
"$OPTRTDIR/math/pow.c",
"$OPTRTDIR/math/powf.c",
"$OPTRTDIR/math/sincosf.c",
"$OPTRTDIR/math/sincosf_data.c",
"$OPTRTDIR/math/sinf.c",
"$OPTRTDIR/string/arm/memchr.S",
"$OPTRTDIR/string/arm/memcpy.S",
"$OPTRTDIR/string/arm/memset.S",
"$OPTRTDIR/string/arm/strcmp.S",
"$OPTRTDIR/string/arm/strlen-armv6t2.S",
]
asmflags = [
"-D__memcpy_arm = memcpy",
"-D__memchr_arm = memchr",
"-D__memset_arm = memset",
"-D__strcmp_arm = strcmp",
"-D__strlen_armv6t2 = strlen",
]
} else if (musl_arch == "aarch64") {
if (defined(ARM_FEATURE_SVE)) {
sources += [
"$OPTRTDIR/string/aarch64/memchr-sve.S",
"$OPTRTDIR/string/aarch64/memcmp-sve.S",
"$OPTRTDIR/string/aarch64/memcpy.S",
"$OPTRTDIR/string/aarch64/memset.S",
"$OPTRTDIR/string/aarch64/stpcpy-sve.S",
"$OPTRTDIR/string/aarch64/strchr-sve.S",
"$OPTRTDIR/string/aarch64/strchrnul-sve.S",
"$OPTRTDIR/string/aarch64/strcmp-sve.S",
"$OPTRTDIR/string/aarch64/strcpy-sve.S",
"$OPTRTDIR/string/aarch64/strlen-sve.S",
"$OPTRTDIR/string/aarch64/strncmp-sve.S",
"$OPTRTDIR/string/aarch64/strnlen-sve.S",
"$OPTRTDIR/string/aarch64/strrchr-sve.S",
]
asmflags = [
"-D__memcpy_aarch64 = memcpy",
"-D__memset_aarch64 = memset",
"-D__memcmp_aarch64_sve = memcmp",
"-D__memchr_aarch64_sve = memchr",
"-D__strcmp_aarch64_sve = strcmp",
"-D__strlen_aarch64_sve = strlen",
"-D__strcpy_aarch64_sve = strcpy",
"-D__stpcpy_aarch64_sve = stpcpy",
"-D__strchr_aarch64_sve = strchr",
"-D__strrchr_aarch64_sve = strrchr",
"-D__strchrnul_aarch64_sve = strchrnul",
"-D__strnlen_aarch64_sve = strnlen",
"-D__strncmp_aarch64_sve = strncmp",
]
} else if (defined(ARM_FEATURE_MTE)) {
sources += [
"$OPTRTDIR/string/aarch64/memchr-mte.S",
"$OPTRTDIR/string/aarch64/memcmp.S",
"$OPTRTDIR/string/aarch64/memcpy.S",
"$OPTRTDIR/string/aarch64/memset.S",
"$OPTRTDIR/string/aarch64/stpcpy-mte.S",
"$OPTRTDIR/string/aarch64/strchr-mte.S",
"$OPTRTDIR/string/aarch64/strchrnul-mte.S",
"$OPTRTDIR/string/aarch64/strcmp-mte.S",
"$OPTRTDIR/string/aarch64/strcpy-mte.S",
"$OPTRTDIR/string/aarch64/strlen-mte.S",
"$OPTRTDIR/string/aarch64/strncmp-mte.S",
"$OPTRTDIR/string/aarch64/strnlen.S",
"$OPTRTDIR/string/aarch64/strrchr-mte.S",
]
asmflags = [
"-D__memcpy_aarch64 = memcpy",
"-D__memset_aarch64 = memset",
"-D__memcmp_aarch64 = memcmp",
"-D__memchr_aarch64_mte = memchr",
"-D__strcmp_aarch64_mte = strcmp",
"-D__strlen_aarch64_mte = strlen",
"-D__strcpy_aarch64_mte = strcpy",
"-D__stpcpy_aarch64_mte = stpcpy",
"-D__strchr_aarch64_mte = strchr",
"-D__strrchr_aarch64_mte = strrchr",
"-D__strchrnul_aarch64_mte = strchrnul",
"-D__strnlen_aarch64 = strnlen",
"-D__strncmp_aarch64_mte = strncmp",
]
} else {
sources += [
"$OPTRTDIR/string/aarch64/memchr.S",
"$OPTRTDIR/string/aarch64/memcmp.S",
"$OPTRTDIR/string/aarch64/memcpy.S",
"$OPTRTDIR/string/aarch64/memset.S",
"$OPTRTDIR/string/aarch64/stpcpy.S",
"$OPTRTDIR/string/aarch64/strchr.S",
"$OPTRTDIR/string/aarch64/strchrnul.S",
"$OPTRTDIR/string/aarch64/strcmp.S",
"$OPTRTDIR/string/aarch64/strcpy.S",
"$OPTRTDIR/string/aarch64/strlen.S",
"$OPTRTDIR/string/aarch64/strncmp.S",
"$OPTRTDIR/string/aarch64/strnlen.S",
"$OPTRTDIR/string/aarch64/strrchr.S",
]
asmflags = [
"-D__memmove_aarch64 = memmove",
"-D__memcpy_aarch64 = memcpy",
"-D__memchr_aarch64 = memchr",
"-D__memset_aarch64 = memset",
"-D__memcmp_aarch64 = memcmp",
"-D__strcmp_aarch64 = strcmp",
"-D__strlen_aarch64 = strlen",
"-D__strcpy_aarch64 = strcpy",
"-D__stpcpy_aarch64 = stpcpy",
"-D__strchr_aarch64 = strchr",
"-D__strrchr_aarch64 = strrchr",
"-D__strchrnul_aarch64 = strchrnul",
"-D__strnlen_aarch64 = strnlen",
"-D__strncmp_aarch64 = strncmp",
]
}
}
cflags = [
"-O3",
"-fPIC",
"-ffreestanding",
"-fstack-protector-strong",
]
if (use_jemalloc) {
defines += [ "USE_JEMALLOC" ]
if (use_jemalloc_dfx_intf) {
defines += [ "USE_JEMALLOC_DFX_INTF" ]
}
include_dirs = [ "//third_party/jemalloc/include/jemalloc" ]
}
configs -= musl_inherited_configs
configs += [ ":soft_musl_config" ]
if (!defined(defines)) {
defines = []
}
if (musl_target_os == "linux" && product_path != "" &&
product_path != rebase_path("//productdefine/common/products")) {
_product_config = read_file("${product_path}/config.json", "json")
if (defined(_product_config.device_stack_size)) {
defines += [ "TARGET_STACK_SIZE=${_product_config.device_stack_size}" ]
}
if (defined(_product_config.device_guard_size)) {
defines += [ "TARGET_GUARD_SIZE=${_product_config.device_guard_size}" ]
}
}
deps = porting_deps
if (!startup_init_with_param_base) {
defines += [ "OHOS_ENABLE_PARAMETER" ]
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
}
}
source_set("soft_musl_src_optimize") {
sources = []
sources_orig = []
if (musl_arch == "aarch64") {
sources_orig += [
"src/math/cos.c",
"src/math/exp.c",
"src/math/exp2.c",
"src/math/exp2f.c",
"src/math/expf.c",
"src/math/log.c",
"src/math/log10.c",
"src/math/log2.c",
"src/math/log2f.c",
"src/math/logb.c",
"src/math/logf.c",
"src/math/sin.c",
"src/math/sincos.c",
"src/math/pow.c",
"src/math/powf.c",
]
}
foreach(s, sources_orig) {
sources += [ "${target_out_dir}/${musl_ported_dir}/${s}" ]
}
if (musl_arch == "aarch64") {
sources += [
"$OPTRTDIR/math/cosf.c",
"$OPTRTDIR/math/sincosf.c",
"$OPTRTDIR/math/sincosf_data.c",
"$OPTRTDIR/math/sinf.c",
]
}
configs -= musl_inherited_configs
configs += [ ":soft_musl_config" ]
cflags = [
"-mllvm",
"-instcombine-max-iterations=0",
"-ffp-contract=fast",
"-O3",
"-fPIC",
"-fstack-protector-strong",
]
deps = porting_deps
}
source_set("soft_musl_src_nossp") {
sources = []
sources_orig = [
"src/string/mempcpy.c",
"src/env/__init_tls.c",
"src/env/__libc_start_main.c",
"src/env/__stack_chk_fail.c",
]
defines = []
if (musl_iterate_and_stats_api) {
defines += [ "MUSL_ITERATE_AND_STATS_API" ]
}
if (musl_arch == "arm") {
sources_orig += [ "src/thread/${musl_arch}/__set_thread_area.c" ]
} else if (musl_arch == "aarch64") {
sources_orig += [ "src/thread/${musl_arch}/__set_thread_area.s" ]
} else if (musl_arch == "x86_64") {
sources_orig += [
"src/thread/${musl_arch}/__set_thread_area.s",
"src/string/memset.c",
]
}
foreach(s, sources_orig) {
sources += [ "${target_out_dir}/${musl_ported_dir}/${s}" ]
}
configs -= musl_inherited_configs
configs += [ ":soft_musl_config" ]
cflags = [
"-O3",
"-fPIC",
"-ffreestanding",
"-fno-stack-protector",
]
deps = porting_deps
}
source_set("soft_musl_ldso") {
sources = []
sources_orig = musl_src_ldso
foreach(s, sources_orig) {
sources += [ "${target_out_dir}/${musl_ported_dir}/${s}" ]
}
configs -= musl_inherited_configs
configs += [ ":soft_musl_config" ]
cflags = [
"-fPIC",
"-ffreestanding",
"-fno-stack-protector",
"-O3",
]
if (is_asan) {
defines = [
"NSLIST_DEFAULT_SIZE=1600",
"DSOLIST_DEFAULT_SIZE=1600",
"INHERIT_DEFAULT_SIZE=1600",
]
} else {
defines = [
"HANDLE_RANDOMIZATION",
"LOAD_ORDER_RANDOMIZATION",
]
}
deps = porting_deps
if (!startup_init_with_param_base) {
defines += [ "OHOS_ENABLE_PARAMETER" ]
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
}
if (musl_unit_test_flag) {
defines += [
"UNIT_TEST_STATIC",
"DL_NOMMU_SUPPORT=1",
]
}
}
source_set("soft_musl_hook") {
sources = [
"./porting/linux/user/src/hook/malloc_common.c",
"./porting/linux/user/src/hook/memory_trace.c",
"./porting/linux/user/src/hook/musl_preinit.c",
"./porting/linux/user/src/hook/musl_preinit_common.c",
"./porting/linux/user/src/hook/musl_socket_preinit.c",
"./porting/linux/user/src/hook/musl_socket_preinit_common.c",
"./porting/linux/user/src/hook/socket_common.c",
]
deps = [
"//third_party/musl:create_alltypes_h",
"//third_party/musl:create_porting_src",
"//third_party/musl:create_syscall_h",
"//third_party/musl:create_version_h",
"//third_party/musl:musl_copy_inc_bits",
"//third_party/musl:musl_copy_inc_fortify",
"//third_party/musl:musl_copy_inc_root",
"//third_party/musl:musl_copy_inc_sys",
]
if (!startup_init_with_param_base) {
defines = [ "OHOS_ENABLE_PARAMETER" ]
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
}
if (musl_unit_test_flag) {
defines += [ "UNIT_TEST_STATIC" ]
}
if (use_jemalloc) {
defines += [ "USE_JEMALLOC" ]
if (use_jemalloc_dfx_intf) {
defines += [ "USE_JEMALLOC_DFX_INTF" ]
}
include_dirs = [ "//third_party/jemalloc/include/jemalloc" ]
}
configs -= musl_inherited_configs
configs += [
"//build/config/compiler:compiler",
":soft_hook",
]
cflags = [
"-mllvm",
"--instcombine-max-iterations=0",
"-ffp-contract=fast",
"-O3",
"-Wno-int-conversion",
]
}
source_set("soft_musl_jemalloc") {
sources = [ "./porting/linux/user/src/malloc/jemalloc/jemalloc.c" ]
deps = [
"//third_party/musl:create_alltypes_h",
"//third_party/musl:create_porting_src",
"//third_party/musl:create_syscall_h",
"//third_party/musl:create_version_h",
"//third_party/musl:musl_copy_inc_bits",
"//third_party/musl:musl_copy_inc_root",
"//third_party/musl:musl_copy_inc_sys",
]
configs -= musl_inherited_configs
configs += [ ":soft_jemalloc" ]
}
static_library("soft_libc_musl_static") {
output_name = "libc"
complete_static_lib = true
configs -= musl_inherited_configs
output_dir = "${target_out_dir}/${_libs_out_dir}"
deps = [
":soft_musl_hook",
":soft_musl_ldso",
":soft_musl_src",
":soft_musl_src_nossp",
":soft_musl_src_optimize",
]
deps += dfx_deps
if (!startup_init_with_param_base) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
}
if (use_jemalloc) {
deps += [ ":soft_musl_jemalloc" ]
}
}
static_library("soft_libm") {
complete_static_lib = true
configs -= musl_inherited_configs
output_name = "libm"
output_dir = "${target_out_dir}/${_libs_out_dir}"
}
static_library("soft_librt") {
complete_static_lib = true
configs -= musl_inherited_configs
output_name = "librt"
output_dir = "${target_out_dir}/${_libs_out_dir}"
}
static_library("soft_libpthread") {
complete_static_lib = true
configs -= musl_inherited_configs
output_name = "libpthread"
output_dir = "${target_out_dir}/${_libs_out_dir}"
}
static_library("soft_libcrypt") {
complete_static_lib = true
configs -= musl_inherited_configs
output_name = "libcrypt"
output_dir = "${target_out_dir}/${_libs_out_dir}"
}
static_library("soft_libutil") {
complete_static_lib = true
configs -= musl_inherited_configs
output_name = "libutil"
output_dir = "${target_out_dir}/${_libs_out_dir}"
}
static_library("soft_libresolv") {
complete_static_lib = true
configs -= musl_inherited_configs
output_name = "libresolv"
output_dir = "${target_out_dir}/${_libs_out_dir}"
}
static_library("soft_libxnet") {
complete_static_lib = true
configs -= musl_inherited_configs
output_name = "libxnet"
output_dir = "${target_out_dir}/${_libs_out_dir}"
}
static_library("soft_libdl") {
complete_static_lib = true
configs -= musl_inherited_configs
output_name = "libdl"
output_dir = "${target_out_dir}/${_libs_out_dir}"
}
shared_library("soft_libc_musl_shared") {
output_dir = "${target_out_dir}/${_libs_out_dir}"
output_name = "libc"
output_extension = "so"
libclang_rt_path = rebase_path(
"${runtime_lib_path}/${musl_target_triple}/${_libs_path_prefix}")
musl_lib_path = rebase_path("${target_out_dir}/${_libs_out_dir}")
ldflags = []
if (!musl_unit_test_flag) {
libc_map_path =
rebase_path("${target_out_dir}/${musl_ported_dir}/libc.map.txt")
ldflags += [ "-Wl,--version-script=${libc_map_path}" ]
}
ldflags += [
"-nostdlib",
"-Wl,-e,_dlstart",
"-L${libclang_rt_path}",
"-lclang_rt.builtins",
"-lunwind",
"-L${musl_lib_path}",
"-ldl",
"-lpthread",
]
configs -= musl_inherited_configs
configs -= [ "//build/config:default_libs" ]
configs += [ ":soft_musl_config" ]
deps = [
":soft_libdl",
":soft_libpthread",
":soft_musl_crt_install_action",
":soft_musl_hook",
":soft_musl_ldso",
":soft_musl_src",
":soft_musl_src_nossp",
":soft_musl_src_optimize",
]
deps += dfx_deps
if (!startup_init_with_param_base) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
}
if (use_jemalloc) {
deps += [ ":soft_musl_jemalloc" ]
}
}
action_foreach("soft_musl_crt_install_action") {
redir = "${root_out_dir}/obj"
script = "${target_out_dir}/${musl_ported_dir}/scripts/install.py"
sources = [
"${redir}/${target_out_dir}/${musl_ported_dir}/crt/${musl_arch}/soft_musl_crt/crti.o",
"${redir}/${target_out_dir}/${musl_ported_dir}/crt/${musl_arch}/soft_musl_crt/crtn.o",
"${redir}/${target_out_dir}/${musl_ported_dir}/crt/soft_musl_crt/Scrt1.o",
"${redir}/${target_out_dir}/${musl_ported_dir}/crt/soft_musl_crt/crt1.o",
"${redir}/${target_out_dir}/${musl_ported_dir}/crt/soft_musl_crt/rcrt1.o",
]
outputs = [ "${root_build_dir}/obj/third_party/musl/${_libs_out_dir}/{{source_file_part}}" ]
ldpath = []
if (is_mac) {
ldpath += [ "${clang_base_path}/bin/ld64.lld" ]
} else if (is_win) {
ldpath += [ "${clang_base_path}/bin/lld-link.exe" ]
} else {
ldpath += [ "${clang_base_path}/bin/ld.lld" ]
}
args = [
"--input",
"{{source}}",
]
args += [ "--output" ] + rebase_path(outputs, root_build_dir)
args += [ "--ldpath" ] + rebase_path(ldpath, root_build_dir)
args += [ "--crtplus" ] + rebase_path(
[ "${redir}/${target_out_dir}/${musl_ported_dir}/crt/soft_musl_crt/crtplus.o" ],
root_build_dir)
deps = [ ":soft_musl_crt" ]
}
copy("soft_create_linker") {
deps = [ ":soft_libc_musl_shared" ]
# _libc_shared_outputs = get_target_outputs(":soft_libc_musl_shared")
_libc_shared_so = "${target_out_dir}/${_libs_out_dir}/libc.so"
sources = [ _libc_shared_so ]
if (is_asan) {
asan = "-asan"
} else {
asan = ""
}
_muls_linker_so = "${root_out_dir}/common/common/libc/${_libs_path_prefix}/ld-musl-${musl_arch}${asan}.so.1"
outputs = [ _muls_linker_so ]
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sunchao4991/third_party_musl.git
git@gitee.com:sunchao4991/third_party_musl.git
sunchao4991
third_party_musl
third_party_musl
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385