From 1bc02f1c5f657fbdf1bf134f7b81f3d5ee3b4ea8 Mon Sep 17 00:00:00 2001 From: zhuoli Date: Tue, 10 Aug 2021 09:41:28 +0800 Subject: [PATCH] Add 64bit support for musl Signed-off-by: zhuoli --- BUILD.gn | 1 + musl_src.gni | 3 --- musl_template.gni | 63 ++++++++++++++++++++++++++++---------------- scripts/copy_uapi.sh | 15 +++++++++-- 4 files changed, 55 insertions(+), 27 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 0f9cdccc..4a4eb511 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -153,6 +153,7 @@ action("copy_uapi") { script = "scripts/copy_uapi.sh" args = [ "-i" ] + [ rebase_path("${uapi_dir}") ] args += [ "-o" ] + [ rebase_path("${target_out_dir}/${musl_inc_out_dir}") ] + args += [ "-t" ] + [ "${musl_arch}" ] } copy("musl_copy_inc_bits") { diff --git a/musl_src.gni b/musl_src.gni index a218c023..2db7ff5d 100644 --- a/musl_src.gni +++ b/musl_src.gni @@ -1595,9 +1595,6 @@ if (musl_arch == "arm") { "arch/generic/bits/dirent.h", "arch/generic/bits/errno.h", - "arch/generic/bits/fcntl.h", - "arch/generic/bits/fenv.h", - "arch/generic/bits/hwcap.h", "arch/generic/bits/ioctl_fix.h", "arch/generic/bits/ioctl.h", "arch/generic/bits/io.h", diff --git a/musl_template.gni b/musl_template.gni index 3e02a1ec..28045e78 100644 --- a/musl_template.gni +++ b/musl_template.gni @@ -92,25 +92,27 @@ template("musl_libs") { ] config("${abi_prefix}_musl_abi_config") { - if (target_abi == "soft") { - cflags = [ "-mfloat-abi=soft" ] - } else if (target_abi == "a7_soft") { - cflags = [ - "-mcpu=cortex-a7", - "-mfloat-abi=soft", - ] - } else if (target_abi == "a7_softfp_neon-vfpv4") { - cflags = [ - "-mcpu=cortex-a7", - "-mfloat-abi=softfp", - "-mfpu=neon-vfpv4", - ] - } else if (target_abi == "a7_hard_neon-vfpv4") { - cflags = [ - "-mcpu=cortex-a7", - "-mfloat-abi=hard", - "-mfpu=neon-vfpv4", - ] + if (musl_arch == "arm") { + if (target_abi == "soft") { + cflags = [ "-mfloat-abi=soft" ] + } else if (target_abi == "a7_soft") { + cflags = [ + "-mcpu=cortex-a7", + "-mfloat-abi=soft", + ] + } else if (target_abi == "a7_softfp_neon-vfpv4") { + cflags = [ + "-mcpu=cortex-a7", + "-mfloat-abi=softfp", + "-mfpu=neon-vfpv4", + ] + } else if (target_abi == "a7_hard_neon-vfpv4") { + cflags = [ + "-mcpu=cortex-a7", + "-mfloat-abi=hard", + "-mfpu=neon-vfpv4", + ] + } } } @@ -128,12 +130,17 @@ template("musl_libs") { cflags_basic = [ "--target=${musl_target_triple}", - "-march=armv7-a", "-Wall", "-D_FORTIFY_SOURCE=2", "-Wl,-z,relro,-z,now,-z,noexecstack", ] + if (musl_arch == "arm") { + cflags_basic += [ "-march=armv7-a", ] + } else if (musl_arch == "aarch64") { + cflags_basic += [ "-march=armv8", ] + } + cflags_auto = [ "-D_XOPEN_SOURCE=700", "-g", @@ -220,9 +227,14 @@ template("musl_libs") { "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 (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" ] + } + if ("${target_abi}" == "a7_hard_neon-vfpv4") { defines = [ "__ARM_PCS_VFP" ] } @@ -251,9 +263,14 @@ template("musl_libs") { "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 (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" ] + } + foreach(s, sources_orig) { sources += [ "${target_out_dir}/${musl_ported_dir}/${s}" ] } @@ -385,6 +402,8 @@ template("musl_libs") { ":${abi_prefix}_musl_ldso", ":${abi_prefix}_musl_src", ":${abi_prefix}_musl_src_nossp", + ":${abi_prefix}_libdl", + ":${abi_prefix}_libpthread", ] } diff --git a/scripts/copy_uapi.sh b/scripts/copy_uapi.sh index 32f97c9a..227dee2a 100755 --- a/scripts/copy_uapi.sh +++ b/scripts/copy_uapi.sh @@ -1,5 +1,5 @@ -while getopts "o:i:h" arg +while getopts "o:i:t:h" arg do case "${arg}" in "o") @@ -8,6 +8,9 @@ do "i") SOURCE_DIR=${OPTARG} ;; + "t") + TARGET_ARCH=${OPTARG} + ;; "h") echo "help" ;; @@ -22,6 +25,14 @@ if [ ! -d "${OUT_DIR}" ];then mkdir -p ${OUT_DIR} fi cp -r ${SOURCE_DIR}/* ${OUT_DIR} -rm -rf ${OUT_DIR}/asm-arm +if [ ${TARGET_ARCH} = "arm" ]; then + mv ${OUT_DIR}/asm-arm/asm ${OUT_DIR}/asm + rm -rf ${OUT_DIR}/asm-arm64 + rm -rf ${OUT_DIR}/asm-arm +elif [ ${TARGET_ARCH} = "aarch64" ]; then + mv ${OUT_DIR}/asm-arm64/asm ${OUT_DIR}/asm + rm -rf ${OUT_DIR}/asm-arm64 + rm -rf ${OUT_DIR}/asm-arm +fi -- GitLab