diff --git a/bundle.json b/bundle.json index f940ed2ba3542122cafdb9745c2089d9a3673a86..ba3368a9bf20c338a2544bfb9e957ff16337d76c 100644 --- a/bundle.json +++ b/bundle.json @@ -47,7 +47,8 @@ "bounds_checking_function", "FreeBSD", "cJSON", - "optimized_routines" + "optimized_routines", + "jemalloc" ], "third_party": [] }, diff --git a/musl_template.gni b/musl_template.gni index 1d5d66cf63777443640471ac3f60a5fc2be19ac0..00d3e2234bdcf3787b26b83973bf2cc3acb80831 100644 --- a/musl_template.gni +++ b/musl_template.gni @@ -113,9 +113,10 @@ template("static_and_shared_libs_template") { "//third_party/musl:musl_copy_inc_root", "//third_party/musl:musl_copy_inc_sys", ] + external_deps = [] if (use_musl && !is_llvm_build) { defines = [ "OHOS_ENABLE_PARAMETER" ] - external_deps = param_base_external_deps + external_deps += param_base_external_deps } if (musl_unit_test_flag) { @@ -129,7 +130,6 @@ template("static_and_shared_libs_template") { if (musl_use_jemalloc_recycle_func) { defines += [ "USE_JEMALLOC_RECYCLE_FUNC" ] } - include_dirs = [ "${musl_malloc_plugin}/include/jemalloc" ] } configs -= musl_inherited_configs @@ -403,7 +403,6 @@ template("static_and_shared_libs_template") { if (musl_use_jemalloc_recycle_func) { defines += [ "USE_JEMALLOC_RECYCLE_FUNC" ] } - include_dirs = [ "${musl_malloc_plugin}/include/jemalloc" ] } if (musl_use_mutex_wait_opt) { @@ -586,108 +585,6 @@ template("musl_libs") { deps = [ ":soft_musl_crt_install_action" ] } - 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", - "-Wno-compare-distinct-pointer-types", - "-Wno-excess-initializers", - "-Wno-extra-tokens", - "-Wno-format", - "-Wno-implicit-function-declaration", - "-Wno-incompatible-pointer-types", - "-Wno-macro-redefined", - "-Wno-many-braces-around-scalar-init", - "-Wno-missing-braces", - "-Wno-unknown-pragmas", - "-Wno-unused-label", - "-Wno-unused-variable", - "-Wno-shorten-64-to-32", - "-Wno-sign-compare", - "-Wno-string-conversion", - - "-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 (use_hwasan) { - cflags += [ - "-mllvm", - "-hwasan-instrument-check-enabled=true", - ] - } - - 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/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", @@ -890,38 +787,6 @@ template("musl_libs") { deps = porting_deps } - source_set("soft_musl_jemalloc") { - sources = [ "${musl_malloc_plugin}/src/static.c" ] - - defines = [] - - 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 (use_musl && !is_llvm_build) { - defines += [ "OHOS_ENABLE_PARAMETER" ] - external_deps = [ "init:parameterbase" ] - } - - if (musl_guard_jemalloc_tsd || is_asan || use_hwasan) { - defines += [ "GUARD_JEMALLOC_TSD" ] - } - - configs -= musl_inherited_configs - - configs += [ - ":soft_jemalloc", - ":stack_config_musl", - ] - } - source_set("soft_musl_src_ld128") { sources = [] if (musl_arch == "x86_64") { @@ -989,7 +854,7 @@ template("musl_libs") { external_deps += [ "optimized_routines:optimize_math" ] } if (musl_use_jemalloc) { - deps += [ ":soft_musl_jemalloc" ] + external_deps += [ "jemalloc:jemalloc" ] } if (musl_ld128_flag) { @@ -1133,7 +998,7 @@ template("musl_libs") { } if (musl_use_jemalloc) { - deps += [ ":soft_musl_jemalloc" ] + external_deps += [ "jemalloc:jemalloc" ] } if (musl_ld128_flag) {