1 Star 0 Fork 487

yinchuang / third_party_musl_dlopen_impl

forked from OpenHarmony / third_party_musl 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
musl_template.gni 35.42 KB
一键复制 编辑 原始数据 按行查看 历史
lijunru 提交于 2024-03-25 20:25 . patch2
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
import("//base/startup/init/begetd.gni")
import("//build/config/clang/clang.gni")
import("//build/ohos.gni")
import("//third_party/FreeBSD/FreeBSD.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}/${musl_target_multilib}"
if (is_llvm_build) {
dfx_deps = []
} else {
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_musl_libs") {
deps = [
":musl_headers",
":soft_libc_musl_shared",
":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_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}/src/gwp_asan",
"${target_out_dir}/${musl_ported_dir}/src/hook",
"${target_out_dir}/${musl_ported_dir}/src/network",
"${target_out_dir}/${musl_ported_dir}/include",
"${target_out_dir}/${musl_inc_out_dir}",
]
cflags_basic = [
"--target=${musl_target_triple}",
"-Wall",
"-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",
"-ffunction-sections",
"-fdata-sections",
"-Werror=implicit-function-declaration",
"-Werror=implicit-int",
"-Werror=pointer-sign",
"-Werror=pointer-arith",
"-Qunused-arguments",
"-Wno-int-conversion",
]
if (is_llvm_build) {
cflags_auto += [
"-fno-unwind-tables",
"-fno-asynchronous-unwind-tables",
]
} else {
cflags_auto += [
"-funwind-tables",
"-fasynchronous-unwind-tables",
]
}
if (is_asan && use_hwasan) {
cflags_auto += [ "-DENABLE_HWASAN" ]
}
if (!is_asan && musl_arch != "mips") {
cflags_auto += [
"-DHOOK_ENABLE",
"-DOHOS_SOCKET_HOOK_ENABLE",
]
}
if (musl_arch == "mips" && is_legacy) {
cflags_auto += [ "-mnan=legacy" ]
}
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" ]
if (!is_llvm_build) {
defines += [ "FEATURE_ATEXIT_CB_PROTECT" ]
}
if (is_standard_system) {
defines += [
"OHOS_DNS_PROXY_BY_NETSYS=1",
"OHOS_FWMARK_CLIENT_BY_NETSYS=1",
"OHOS_PERMISSION_INTERNET=1",
"OHOS_DISABLE_IPV6=0",
]
}
if (!is_standard_system && defined(enable_musl_log)) {
if (enable_musl_log) {
defines += [ "ENABLE_MUSL_LOG" ]
}
}
if (use_gwp_asan) {
defines += [ "USE_GWP_ASAN" ]
if (!defined(libs)) {
libs = [ rebase_path(libgwp_asan_file) ]
} else {
libs += [ rebase_path(libgwp_asan_file) ]
}
}
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}",
"-Wl,--build-id=md5",
]
if (musl_arch == "mips") {
ldflags -= [ "-Wl,--hash-style=both" ]
}
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 && musl_arch != "mips") {
defines += [
"HOOK_ENABLE",
"OHOS_SOCKET_HOOK_ENABLE",
]
}
ldflags = [ "-nostdlib" ]
libs = []
if (use_gwp_asan) {
defines += [ "USE_GWP_ASAN" ]
libs += [ rebase_path(libgwp_asan_file) ]
}
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",
# 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_llvm_build) {
cflags += [ "-fno-unwind-tables" ]
} else {
cflags += [ "-funwind-tables" ]
}
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" ]
} else if (musl_arch == "mips") {
cflags += [ "-march=mips32r2" ]
} else if (musl_arch == "riscv64") {
cflags += [ "-march=rv64gc" ]
}
include_dirs += [
"//third_party",
"//third_party/musl/src/include/",
"${musl_malloc_plugin}/include/",
"${musl_malloc_plugin}/include/jemalloc/internal",
"${musl_malloc_plugin}/include/jemalloc",
]
}
source_set("soft_musl_crt") {
sources = [
"${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",
]
if (musl_arch == "riscv64") {
sources += [
"${target_out_dir}/${musl_ported_dir}/crt/crti.c",
"${target_out_dir}/${musl_ported_dir}/crt/crtn.c",
]
} else {
sources += [
"${target_out_dir}/${musl_ported_dir}/crt/${musl_arch}/crti.s",
"${target_out_dir}/${musl_ported_dir}/crt/${musl_arch}/crtn.s",
]
}
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",
"src/stdlib/qsort.c",
"src/stdlib/qsort_nr.c",
"src/string/strncpy.c",
]
sources += [
"$FREEBSD_DIR/contrib/tcp_wrappers/strcasecmp.c",
"$FREEBSD_DIR/lib/libc/gen/arc4random.c",
"$FREEBSD_DIR/lib/libc/gen/arc4random_uniform.c",
"$FREEBSD_DIR/lib/libc/stdlib/qsort.c",
"$FREEBSD_DIR/lib/libc/stdlib/strtoimax.c",
"$FREEBSD_DIR/lib/libc/stdlib/strtoul.c",
"$FREEBSD_DIR/lib/libc/stdlib/strtoumax.c",
"third_party/openbsd/gnu/lib/libexecinfo/backtrace.c",
"third_party/openbsd/lib/libc/string/strcasestr.c",
]
if (!is_llvm_build) {
sources += [ "$FREEBSD_DIR/contrib/libexecinfo/unwind.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",
"src/linux/flock.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",
"src/math/frexpl.c",
"src/stat/fstat.c",
"src/linux/flock.c",
]
} else if (musl_arch == "x86_64") {
sources_orig -= [
"src/thread/${musl_arch}/__set_thread_area.s",
"src/linux/flock.c",
]
} else if (musl_arch == "riscv64") {
sources_orig -= [
"src/thread/${musl_arch}/__set_thread_area.s",
"src/math/copysign.c",
"src/math/copysignf.c",
]
}
if (musl_ld128_flag) {
if (musl_arch == "x86_64") {
sources_orig -= [
"src/math/x86_64/exp2l.s",
"src/math/x86_64/expl.s",
"src/math/x86_64/expm1l.s",
"src/math/x86_64/fabsl.s",
"src/math/x86_64/floorl.s",
"src/math/x86_64/log1pl.s",
"src/math/x86_64/log2l.s",
"src/math/x86_64/log10l.s",
"src/math/x86_64/logl.s",
"src/math/x86_64/sqrtl.s",
"src/math/acoshl.c",
"src/math/asinhl.c",
"src/math/coshl.c",
"src/math/sinhl.c",
"src/math/erfl.c",
"src/math/powl.c",
"src/math/lgammal.c",
"src/math/tanhl.c",
]
} else if (musl_arch == "aarch64") {
sources_orig -= [
"src/math/acoshl.c",
"src/math/asinhl.c",
"src/math/coshl.c",
"src/math/sinhl.c",
"src/math/expl.c",
"src/math/expm1l.c",
"src/math/erfl.c",
"src/math/logl.c",
"src/math/log1pl.c",
"src/math/log2l.c",
"src/math/log10l.c",
"src/math/powl.c",
"src/math/lgammal.c",
"src/math/tanhl.c",
]
}
}
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",
]
sources += added_freebsd_files
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") {
sources += [ "$FREEBSD_DIR/lib/msun/src/s_frexpl.c" ]
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",
]
sources += added_freebsd_files
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",
"-fstack-protector-strong",
]
if (!(use_libfuzzer || is_mac || is_asan || use_clang_coverage)) {
cflags += [ "-flto" ]
}
if (use_jemalloc) {
defines += [ "USE_JEMALLOC" ]
if (use_jemalloc_dfx_intf) {
defines += [ "USE_JEMALLOC_DFX_INTF" ]
}
if (use_jemalloc_recycle_func) {
defines += [ "USE_JEMALLOC_RECYCLE_FUNC" ]
}
include_dirs = [ "${musl_malloc_plugin}/include/jemalloc" ]
}
if (!defined(include_dirs)) {
include_dirs = []
}
if (musl_arch == "aarch64") {
include_dirs += [ "//third_party/FreeBSD/lib/libc/aarch64" ]
} else if (musl_arch == "arm") {
include_dirs += [ "//third_party/FreeBSD/lib/libc/arm" ]
}
include_dirs += [ "//third_party/FreeBSD/lib/libc/include" ]
include_dirs += [ "//third_party/FreeBSD/contrib/libexecinfo" ]
include_dirs += [ "//third_party/FreeBSD/crypto/openssh/openbsd-compat" ]
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_strncpy") {
sources = []
sources += [ "third_party/openbsd/lib/libc/string/strncpy.c" ]
configs -= musl_inherited_configs
configs += [ ":soft_musl_config" ]
cflags = [
"-O2",
"-fPIC",
"-fstack-protector-strong",
]
deps = porting_deps
}
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",
]
} else if (musl_arch == "mips") {
sources_orig += [ "src/string/memset.c" ]
} else if (musl_arch == "riscv64") {
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 = [
"./src/hook/linux/malloc_common.c",
"./src/hook/linux/memory_trace.c",
"./src/hook/linux/musl_preinit.c",
"./src/hook/linux/musl_preinit_common.c",
"./src/hook/linux/musl_socket_preinit.c",
"./src/hook/linux/musl_socket_preinit_common.c",
"./src/hook/linux/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" ]
}
if (use_jemalloc_recycle_func) {
defines += [ "USE_JEMALLOC_RECYCLE_FUNC" ]
}
include_dirs = [ "${musl_malloc_plugin}/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 = [ "${musl_malloc_plugin}/src/static.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",
]
if (!startup_init_with_param_base) {
defines = [ "OHOS_ENABLE_PARAMETER" ]
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
}
configs -= musl_inherited_configs
configs += [ ":soft_jemalloc" ]
}
source_set("soft_musl_src_ld128") {
sources = []
if (musl_arch == "x86_64") {
sources += [
"src/math/exp2l.c",
"src/math/fabsl.c",
"src/math/floorl.c",
"src/math/sqrtl.c",
]
}
sources += [
"$FREEBSD_DIR/lib/msun/ld128/e_lgammal_r.c",
"$FREEBSD_DIR/lib/msun/ld128/e_powl.c",
"$FREEBSD_DIR/lib/msun/ld128/k_cosl.c",
"$FREEBSD_DIR/lib/msun/ld128/k_sinl.c",
"$FREEBSD_DIR/lib/msun/ld128/s_erfl.c",
"$FREEBSD_DIR/lib/msun/ld128/s_expl.c",
"$FREEBSD_DIR/lib/msun/ld128/s_logl.c",
"$FREEBSD_DIR/lib/msun/src/e_acoshl.c",
"$FREEBSD_DIR/lib/msun/src/e_coshl.c",
"$FREEBSD_DIR/lib/msun/src/e_lgammal.c",
"$FREEBSD_DIR/lib/msun/src/e_sinhl.c",
"$FREEBSD_DIR/lib/msun/src/s_asinhl.c",
"$FREEBSD_DIR/lib/msun/src/s_tanhl.c",
]
defines = [ "LD128_ENABLE" ]
include_dirs = [
"//third_party/FreeBSD/lib/msun/ld128",
"//third_party/FreeBSD/lib/msun/src",
"//third_party/FreeBSD/lib/libc/include",
"//third_party/FreeBSD/sys",
]
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
}
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_src",
":soft_musl_src_nossp",
":soft_musl_src_optimize",
":soft_musl_src_strncpy",
]
if (!is_llvm_build) {
deps += [ ":soft_musl_ldso" ]
}
deps += dfx_deps
if (!startup_init_with_param_base) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
}
if (use_jemalloc) {
deps += [ ":soft_musl_jemalloc" ]
}
if (musl_ld128_flag) {
deps += [ ":soft_musl_src_ld128" ]
}
}
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"
if (is_legacy) {
libclang_rt_path = rebase_path(
"${runtime_lib_path}/${musl_target_triple}/nanlegacy/${_libs_path_prefix}")
} else {
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",
"-L${musl_lib_path}",
"-ldl",
"-lpthread",
]
if (!is_llvm_build) {
ldflags += [ "-lunwind" ]
}
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",
":soft_musl_src_strncpy",
]
deps += dfx_deps
if (!startup_init_with_param_base) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
}
if (use_jemalloc) {
deps += [ ":soft_musl_jemalloc" ]
}
if (musl_ld128_flag) {
deps += [ ":soft_musl_src_ld128" ]
}
}
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/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",
]
if (musl_arch == "riscv64") {
sources += [
"${redir}/${target_out_dir}/${musl_ported_dir}/crt/soft_musl_crt/crti.o",
"${redir}/${target_out_dir}/${musl_ported_dir}/crt/soft_musl_crt/crtn.o",
]
} else {
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",
]
}
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 ]
}
}
1
https://gitee.com/ychuawei/third_party_musl_dlopen_impl.git
git@gitee.com:ychuawei/third_party_musl_dlopen_impl.git
ychuawei
third_party_musl_dlopen_impl
third_party_musl_dlopen_impl
master

搜索帮助