Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
e7ee6452
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
9 个月 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e7ee6452
编写于
7月 09, 2021
作者:
O
openharmony_ci
提交者:
Gitee
7月 09, 2021
浏览文件
操作
浏览文件
下载
差异文件
!56 更新musl编译选项,增加源码配置脚本
Merge pull request !56 from zhuoli72/master
上级
1341ce06
5c4a83ef
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
300 addition
and
14 deletion
+300
-14
BUILD.gn
BUILD.gn
+1
-1
musl_config.gni
musl_config.gni
+1
-0
musl_template.gni
musl_template.gni
+91
-13
scripts/search_source_files.py
scripts/search_source_files.py
+207
-0
未找到文件。
BUILD.gn
浏览文件 @
e7ee6452
...
...
@@ -6,7 +6,7 @@ group("musl_all") {
":soft_libs",
":a7_soft_libs",
":a7_softfp_neon_libs",
#
":a7_hard_neon_libs",
":a7_hard_neon_libs",
]
}
...
...
musl_config.gni
浏览文件 @
e7ee6452
...
...
@@ -27,6 +27,7 @@ declare_args() {
}
declare_args() {
runtime_lib_path = "//prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/10.0.1/lib"
user_custom_libc = true
musl_ported_dir = "intermidiates/${musl_target_os}/musl_src_ported"
musl_inc_out_dir = "usr/include/${musl_target_triple}"
...
...
musl_template.gni
浏览文件 @
e7ee6452
...
...
@@ -93,35 +93,64 @@ template("musl_libs") {
"${target_out_dir}/${musl_inc_out_dir}",
]
cflags = [
cflags
_basic
= [
"--target=${musl_target_triple}",
"-std=c99",
"-nostdinc",
"-ffreestanding",
"-Wa,--noexecstack",
"-march=armv7-a",
"-O2",
"-Wall",
"-fstack-protector-strong",
"-D_FORTIFY_SOURCE=2",
"-Wl,-z,relro,-z,now,-z,noexecstack",
]
cflags_auto = [
"-D_XOPEN_SOURCE=700",
"-Os",
"-pipe",
"-f
no-
omit-frame-pointer",
"-funwind-tables",
"-fasynchronous-unwind-tables",
"-fomit-frame-pointer",
"-f
no-
unwind-tables",
"-f
no-
asynchronous-unwind-tables",
"-ffunction-sections",
"-fdata-sections",
"-Werror=implicit-function-declaration",
"-Werror=implicit-int",
"-Werror=pointer-sign",
"-Werror=pointer-arith",
"-Wno-bitwise-op-parentheses",
"-Wno-shift-op-parentheses",
"-Qunused-arguments",
]
cflags_c99fse = [
"-std=c99",
"-nostdinc",
"-ffreestanding",
"-frounding-math",
"-Wa,--noexecstack",
]
if (musl_arch == "aarch64") {
cflags += [ "-Qunused-arguments" ]
# cflags_nossp = [ "-fno-stack-protector" ]
cflags_all = cflags_basic +
cflags_c99fse +
cflags_auto
cflags = cflags_all
if ("${target_abi}" != "a7_hard_neon-vfpv4") {
defines = [ "BROKEN_VFP_ASM" ]
}
dynamic_list = rebase_path("${target_out_dir}/${musl_ported_dir}/dynamic.list")
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
}
...
...
@@ -159,12 +188,53 @@ template("musl_libs") {
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/thread/${musl_arch}/__set_thread_area.c",
]
if ("${target_abi}" == "a7_hard_neon-vfpv4") {
defines = [ "__ARM_PCS_VFP" ]
}
foreach(s, sources_orig) {
sources += [ "${target_out_dir}/${musl_ported_dir}/${s}" ]
}
cflags += [
"-O3",
"-fPIC",
]
configs -= musl_inherited_configs
configs += [ ":${template_prefix}_musl_config" ]
deps = porting_deps
}
source_set("${template_prefix}_musl_src_nossp") {
cflags = []
sources = []
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/thread/${musl_arch}/__set_thread_area.c",
]
foreach(s, sources_orig) {
sources += [ "${target_out_dir}/${musl_ported_dir}/${s}" ]
}
cflags += [
"-O3",
"-fPIC",
"-fno-stack-protector",
]
...
...
@@ -196,7 +266,10 @@ template("musl_libs") {
complete_static_lib = true
output_dir = "${target_out_dir}/${static_lib_out_dir}"
deps = [ ":${template_prefix}_musl_src" ]
deps = [
":${template_prefix}_musl_src",
":${template_prefix}_musl_src_nossp",
]
}
static_library("${template_prefix}_libm") {
...
...
@@ -235,9 +308,13 @@ template("musl_libs") {
output_name = "libc/${shared_lib_out_dir}/libc"
output_extension = "so"
libclang_rt_path = rebase_path("${runtime_lib_path}/${musl_target_triple}/${shared_lib_out_dir}")
ldflags = [
"-nostdlib",
"-Wl,-e,_dlstart",
"-L${libclang_rt_path}",
"-lclang_rt.builtins",
]
remove_configs = musl_inherited_configs
...
...
@@ -248,6 +325,7 @@ template("musl_libs") {
deps = [
":${template_prefix}_musl_ldso",
":${template_prefix}_musl_src",
":${template_prefix}_musl_src_nossp",
]
}
...
...
scripts/search_source_files.py
0 → 100755
浏览文件 @
e7ee6452
import
os
import
argparse
SRC_DIRS
=
[
"src"
,
"crt"
,
"ldso"
]
def
file_search
(
path
,
target_type
):
base_srcs
=
[]
if
not
os
.
path
.
isdir
(
path
):
return
base_srcs
src_list
=
os
.
listdir
(
path
)
for
src
in
src_list
:
cur_path
=
os
.
path
.
join
(
path
,
src
)
if
os
.
path
.
isdir
(
cur_path
):
# base_srcs += file_search(cur_path, target_type)
continue
elif
target_type
==
"header"
:
if
(
cur_path
.
endswith
(
".h"
)):
base_srcs
.
append
(
cur_path
)
elif
target_type
==
"src"
:
if
(
cur_path
.
endswith
(
".c"
)):
base_srcs
.
append
(
cur_path
)
return
base_srcs
def
arch_file_search
(
path
,
arch
):
arch_srcs
=
[]
target_path
=
path
+
"/"
+
arch
if
os
.
path
.
isdir
(
target_path
):
src_list
=
os
.
listdir
(
target_path
)
for
src
in
src_list
:
cur_path
=
os
.
path
.
join
(
target_path
,
src
)
if
os
.
path
.
isdir
(
cur_path
):
# arch_srcs += file_search(cur_path, target_type)
continue
elif
(
cur_path
.
endswith
(
".c"
)
or
cur_path
.
endswith
(
".s"
)
or
cur_path
.
endswith
(
".S"
)):
arch_srcs
.
append
(
cur_path
)
return
arch_srcs
def
get_base_srcs
(
path
):
base_srcs
=
[]
for
src_dir
in
SRC_DIRS
:
src_path
=
path
+
"/"
+
src_dir
src_list
=
os
.
listdir
(
src_path
)
for
src
in
src_list
:
cur_path
=
os
.
path
.
join
(
src_path
,
src
)
if
os
.
path
.
isdir
(
cur_path
)
and
src_dir
==
"src"
:
base_srcs
+=
file_search
(
cur_path
,
"src"
)
else
:
if
(
cur_path
.
endswith
(
".c"
)):
base_srcs
.
append
(
cur_path
)
base_srcs
.
sort
()
return
base_srcs
def
get_arch_srcs
(
path
,
arch
):
arch_srcs
=
[]
for
src_dir
in
SRC_DIRS
:
if
src_dir
==
"src"
:
src_list
=
os
.
listdir
(
path
+
"/"
+
src_dir
)
for
src
in
src_list
:
cur_path
=
os
.
path
.
join
(
path
+
"/"
+
src_dir
,
src
)
arch_srcs
+=
arch_file_search
(
cur_path
,
arch
)
elif
os
.
path
.
isdir
(
path
+
"/"
+
src_dir
+
"/"
+
arch
):
src_path
=
path
+
"/"
+
src_dir
+
"/"
+
arch
src_list
=
os
.
listdir
(
src_path
)
for
src
in
src_list
:
cur_path
=
os
.
path
.
join
(
src_path
,
src
)
if
os
.
path
.
isdir
(
cur_path
):
continue
else
:
if
(
cur_path
.
endswith
(
".c"
)
or
cur_path
.
endswith
(
".s"
)
or
cur_path
.
endswith
(
".S"
)):
arch_srcs
.
append
(
cur_path
)
arch_srcs
.
sort
()
return
arch_srcs
def
change_subfix
(
name
):
new_name
=
""
if
name
.
endswith
(
".s"
):
new_name
=
name
.
replace
(
".s"
,
".c"
)
elif
name
.
endswith
(
".S"
):
new_name
=
name
.
replace
(
".S"
,
".c"
)
else
:
return
name
return
new_name
def
replace_srcs_with_arch
(
base_srcs
,
arch_srcs
,
arch
):
target_srcs
=
base_srcs
arch_removed
=
[]
for
src
in
arch_srcs
:
fake_name
=
change_subfix
(
src
.
replace
(
"/"
+
arch
,
""
))
if
fake_name
in
target_srcs
:
target_srcs
.
remove
(
fake_name
)
arch_removed
.
append
(
src
)
return
target_srcs
,
arch_removed
def
get_libc_srcs
(
target_srcs
,
relative_path
):
libc_srcs
=
[]
for
src
in
target_srcs
:
clean_path_src
=
src
.
replace
(
relative_path
,
""
)
if
clean_path_src
.
startswith
(
"/src/"
)
or
clean_path_src
.
startswith
(
"/compat/time32/"
):
libc_srcs
.
append
(
src
)
return
libc_srcs
def
get_ldso_srcs
(
target_srcs
,
relative_path
):
ldso_srcs
=
[]
for
src
in
target_srcs
:
clean_path_src
=
src
.
replace
(
relative_path
,
""
)
if
clean_path_src
.
startswith
(
"/ldso/"
):
ldso_srcs
.
append
(
src
)
return
ldso_srcs
def
get_crt_srcs
(
target_srcs
,
relative_path
):
crt_srcs
=
[]
for
src
in
target_srcs
:
clean_path_src
=
src
.
replace
(
relative_path
,
""
)
if
clean_path_src
.
startswith
(
"/crt/"
):
crt_srcs
.
append
(
src
)
return
crt_srcs
def
get_header_dirs
(
path
,
arch
):
header_dirs
=
{
path
+
"/arch/"
+
arch
+
"/bits"
,
path
+
"/arch/generic/bits"
,
path
+
"/include"
}
return
header_dirs
def
get_generated_header
(
path
):
generated_headers
=
[
path
+
"/include/bits/alltypes.h"
,
path
+
"/include/bits/syscall.h"
,
]
def
get_all_header
(
header_dirs
):
all_header
=
[]
for
dir
in
header_dirs
:
file_list
=
os
.
listdir
(
dir
)
for
file
in
file_list
:
cur_path
=
os
.
path
.
join
(
dir
,
file
)
if
os
.
path
.
isdir
(
cur_path
):
all_header
+=
file_search
(
cur_path
,
"header"
)
else
:
if
(
cur_path
.
endswith
(
".h"
)):
all_header
.
append
(
cur_path
)
all_header
.
sort
()
return
all_header
def
rm_dup_header
(
all_header_files
,
arch
):
header_files
=
all_header_files
header_to_rm
=
[]
for
file
in
header_files
:
if
"/arch/generic/bits"
in
file
:
substitute_file
=
file
.
replace
(
"/arch/generic/bits"
,
"/arch/"
+
arch
+
"/bits"
)
if
substitute_file
in
header_files
:
header_to_rm
.
append
(
file
)
return
[
i
for
i
in
header_files
if
i
not
in
header_to_rm
]
def
print_outputs
(
outputs
):
for
out
in
outputs
:
print
(
out
)
for
content
in
outputs
[
out
]:
print
(
" "
+
content
)
def
search_for_files
(
path
,
arch
):
if
arch
==
"arm"
:
SRC_DIRS
.
append
(
"compat/time32"
)
base_srcs
=
get_base_srcs
(
path
)
arch_srcs
=
get_arch_srcs
(
path
,
arch
)
target_srcs
,
arch_removed
=
replace_srcs_with_arch
(
base_srcs
,
arch_srcs
,
arch
)
target_srcs
+=
arch_srcs
libc_srcs
=
get_libc_srcs
(
target_srcs
,
path
)
ldso_srcs
=
get_ldso_srcs
(
target_srcs
,
path
)
crt_srcs
=
get_crt_srcs
(
target_srcs
,
path
)
all_header_files
=
get_all_header
(
get_header_dirs
(
path
,
arch
))
header_files
=
rm_dup_header
(
all_header_files
,
arch
)
outputs
=
{
"arch"
:
arch_srcs
,
"arch_rm"
:
arch_removed
,
"libc"
:
libc_srcs
,
"ldso"
:
ldso_srcs
,
"crt"
:
crt_srcs
,
"header"
:
header_files
,
}
# print_outputs(outputs)
return
libc_srcs
,
ldso_srcs
,
crt_srcs
,
header_files
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
parser
.
add_argument
(
'--path'
,
required
=
True
,
help
=
'The path of musl source files'
)
parser
.
add_argument
(
'--arch'
,
required
=
True
,
help
=
'The targeting architecture'
)
args
=
parser
.
parse_args
()
return
search_for_files
(
args
.
path
,
args
.
arch
)
if
__name__
==
"__main__"
:
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录