diff --git a/.gitignore b/.gitignore index 73f85073bbd3a165a45c240c6b4db017eab0b0b0..107dfa287dc905175b5d5fdf71d4774b4924a126 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ apidoc +usr +lib +build/linux_header_install_for_* +build/musl_copy_for_* diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ebbe3f2d55913bd1f71bf9622d50292b0f4c69d2 --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config("sysroot_flags") { + cflags = [ "--sysroot="+rebase_path(".") ] +} + +group("sysroot") { + deps = [ "build" ] + public_configs = [ ":sysroot_flags" ] +} diff --git a/README b/README deleted file mode 100644 index 460468f1c142fb21a683553bdf24b41d697b76eb..0000000000000000000000000000000000000000 --- a/README +++ /dev/null @@ -1,21 +0,0 @@ - SYSROOT - - DESCRIPTION - ----------- - - Sysroot is a directory which is considered to be the root directory for - the purpose of locating headers and libraries. - - Most of the headers in usr path were generated from MUSL by compilation, you can see - the license information of MUSL in COPYRIGHT file. - - The build path contains compilation scripts, you can see the license information - in LICENSE file. - - usr/include/arm-liteos/fb.h was generated from NUTTX headers, to provide - necessary information from kernel to userspace. - - usr/include/arm-liteos/linux, usr/include/arm-liteos/asm, - usr/include/arm-liteos/asm-generic, ohos/uapi were generated from the Linux kernel - headers by update_headers.py, to provide necessary information from - kernel to userspace. diff --git a/README.md b/README.md index 3b257a25a4ab3da22ab940728dba8b58ef9f8d6c..3f85e3489eb214f5e885bd32b4996f712daa8146 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ ``` /prebuilts/lite/sysroot ├── build # Toolchain building (including build scripts) -├── thirdparty # Temporary third-party header files required for toolchain building ├── usr # C library and header files exposed externally │ ├── include # Header files exposed externally │ │ └── arm-liteos # Chip architecture for the toolchain @@ -30,7 +29,7 @@ ## Compilation and Building -When bugs in the musl library are fixed or the version is updated, you need to compile and build a new libc library by executing **thirdparty\_headers.sh** and **build\_musl\_clang.sh** scripts in the **build** directory, respectively. The new libc library will be stored in the **/prebuilts/lite/sysroot/build/usr** directory. Then, you need to replace the header files and libc library in the **/prebuilts/lite/sysroot/usr** directory. +When bugs in the musl library are fixed or the version is updated, you need to compile and build a new libc library by executing `make` in the **build** directory, respectively. The new libc library will be stored in the **/prebuilts/lite/sysroot/usr** directory. ## Usage @@ -38,7 +37,7 @@ When bugs in the musl library are fixed or the version is updated, you need to c - The following is a sample script for compiling the **helloworld.c** program: ``` -clang -o helloworld helloworld.c -target arm-liteos -L ~/llvm/lib/clang/9.0.0/lib/arm-liteos/a7_softfp_neon-vfpv4 --sysroot=/usr/xxx/OS/prebuilts/lite/sysroot/ +clang -o helloworld helloworld.c -target arm-liteos --sysroot=/my_ohos_root_path/prebuilts/lite/sysroot/ ``` The compiler directory is **\~/llvm**. diff --git a/README_zh.md b/README_zh.md index 8a34e1e4561608dd2ab72b662791989bd1b567a0..f4d928bc92649da7ab7b2dc311ad5c8244baba91 100644 --- a/README_zh.md +++ b/README_zh.md @@ -16,7 +16,6 @@ sysroot是一个用作clang编译器查找标准库和头文件的根目录, ``` /prebuilts/lite/sysroot ├── build # 工具链构建目录,包括构建脚本 -├── thirdparty # 临时生成的工具链构建所需的三方头文件 ├── usr # 对外C库及头文件 │ ├── include # 对外头文件存放目录 │ │ └── arm-liteos # 工具链对应的芯片架构 @@ -30,7 +29,7 @@ sysroot是一个用作clang编译器查找标准库和头文件的根目录, ## 编译构建 -musl库bug修复或者新版本更新时,需要重新编译构建新的libc库。分别执行build目录下的thirdparty\_headers.sh和build\_musl\_clang.sh脚本即可编译构建出新的libc库,存放于/prebuilts/lite/sysroot/build/usr目录下,然后替换/prebuilts/lite/sysroot/usr目录下对应的头文件及libc库即可。 +musl库bug修复或者新版本更新时,需要重新编译构建新的libc库。在build目录下执行`make`即可编译构建出新的libc库,存放于/prebuilts/lite/sysroot/usr目录下。 ## 使用说明 @@ -38,7 +37,7 @@ musl库bug修复或者新版本更新时,需要重新编译构建新的libc库 - 编译用户程序helloworld.c示例如下: ``` -clang -o helloworld helloworld.c -target arm-liteos -L ~/llvm/lib/clang/9.0.0/lib/arm-liteos/a7_softfp_neon-vfpv4 --sysroot=/usr/xxx/OS/prebuilts/lite/sysroot/ +clang -o helloworld helloworld.c -target arm-liteos --sysroot=/my_ohos_root_path/prebuilts/lite/sysroot/ ``` 其中,编译器目录为\~/llvm。 diff --git a/build/BUILD.gn b/build/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..109f9343dfafd5c988dde5de5b9a9b3f3bb3675e --- /dev/null +++ b/build/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import("//build/lite/config/component/lite_component.gni") + +build_ext_component("build") { + exec_path = rebase_path(target_out_dir) + root_path = rebase_path("//.", exec_path) + makefile_path = rebase_path("Makefile", exec_path) + command = "make TOPDIR=$root_path -f $makefile_path" +} diff --git a/build/Makefile b/build/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..5632851dd2290459dfd959b2f084217de3585616 --- /dev/null +++ b/build/Makefile @@ -0,0 +1,178 @@ +# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +ARCH = arm +TARGET = $(ARCH)-liteos +CROSS_COMPILE = llvm- +CC = clang --target=$(TARGET) $(ARCH_CFLAGS) +MULTILIB = $(patsubst $(shell $(CC) -print-file-name=)%/,%,$(dir $(shell $(CC) -print-libgcc-file-name))) +MUSLBUILDDIR = build_$(ARCH)$(subst $(eval) ,,$(patsubst -%,_%,$(sort $(ARCH_CFLAGS)))) +HIDE = @ + +TOPDIR = $(shell pwd)/../../../.. +MUSLDIR = $(TOPDIR)/third_party/musl +LINUXKERNELDIR = $(TOPDIR)/third_party/Linux_Kernel +OPTRTDIR = $(TOPDIR)/third_party/optimized-routines +NUTTXDIR = $(TOPDIR)/third_party/NuttX +SYSROOTDIR = $(TOPDIR)/prebuilts/lite/sysroot +LINUXDIR = $(TOPDIR)/kernel/linux-4.19 + +TARGETS = liteos_a_user +TARGETS += $(if $(wildcard $(LINUXDIR)),linux_user,) + +define LINUX_TYPES_H +/* Auto generated file at $(shell date), do NOT edit! */ +#ifndef _LINUX_TYPES_H +#define _LINUX_TYPES_H +#include +typedef uint32_t __u32, __le32; +#endif +endef +export LINUX_TYPES_H + +ifeq ($(ARCH),arm) +ARCH_CFLAGS = -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 +else +$(warning *** warning: ARCH $(ARCH) has not been tested yet, use with cautions!) +ARCH_CFLAGS = +endif + +CFLAGS = -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -Wl,--build-id=sha1 + +.PHONY: $(TARGETS:%=musl_copy_for_%) +.PHONY: $(TARGETS:%=musl_patch_for_%) +.PHONY: $(TARGETS:%=musl_install_for_%) +.PHONY: $(TARGETS:%=linux_header_install_for_%) +.PHONY: $(TARGETS:%=nuttx_header_install_for_%) +.PHONY: $(TARGETS:%=optimized_routines_install_for_%) +.PHONY: all clean distclean + +all: $(TARGETS:%=musl_install_for_%) $(if $(filter liteos_a_user,$(TARGETS)),musl_install_for_liteos_a_user_debug,) + +$(TARGETS:%=musl_copy_for_%): + $(HIDE) mkdir -p $@ + $(HIDE) cp -rfu $(MUSLDIR)/[^p]* $@ + +optimized_routines_install_for_liteos_a_user: musl_copy_for_liteos_a_user +ifneq ($(ARCH),) + $(HIDE) cp -rfp $(OPTRTDIR)/string/$(ARCH)/* $ $ $/dev/null && \ + sed 's, -m 644 , -m 444 ,g' Makefile | make -f- -sj install-headers install-libs DESTDIR=$(SYSROOTDIR) + +musl_install_for_linux_user: TARGET = $(ARCH)-linux-ohosmusl +musl_install_for_linux_user: MULTILIB = lib/$(TARGET) +musl_install_for_linux_user: CC += -fuse-ld=lld --rtlib=compiler-rt +musl_install_for_linux_user: musl_patch_for_linux_user + $(HIDE) cd musl_copy_for_linux_user && mkdir -p $(MUSLBUILDDIR) && cd $(MUSLBUILDDIR) && \ + ../configure --prefix=/usr --target=$(TARGET) --includedir=/usr/include/$(TARGET) --libdir=/usr/$(MULTILIB) \ + CC="$(CC)" CROSS_COMPILE=$(CROSS_COMPILE) CFLAGS="$(CFLAGS)" >/dev/null && \ + sed 's, -m 644 , -m 444 ,g' Makefile | make -f- -sj install-headers install-libs DESTDIR=$(SYSROOTDIR) + +musl_install_for_liteos_a_user_debug: CFLAGS += -funwind-tables -fasynchronous-unwind-tables -rdynamic -I $(shell $(CC) -print-file-name=)include +musl_install_for_liteos_a_user_debug: musl_install_for_liteos_a_user + $(HIDE) mkdir -p musl_copy_for_liteos_a_user_debug && \ + cp -rfp musl_copy_for_liteos_a_user/* musl_copy_for_liteos_a_user_debug && \ + cp -rfp $(MUSLDIR)/porting/liteos_a/user_debug/* musl_copy_for_liteos_a_user_debug + $(HIDE) cd musl_copy_for_liteos_a_user_debug && mkdir -p $(MUSLBUILDDIR) && cd $(MUSLBUILDDIR) && \ + ../configure --prefix=/usr --target=$(TARGET) --includedir=/usr/include/$(TARGET) --libdir=/usr/$(MULTILIB)/debug \ + LDFLAGS="-L $(dir $(shell $(CC) -print-libgcc-file-name)) -lunwind -L lib -ldl" \ + CC="$(CC)" CROSS_COMPILE=$(CROSS_COMPILE) CFLAGS="$(CFLAGS)" >/dev/null && \ + sed 's, -m 644 , -m 444 ,g' Makefile | make -f- -sj install-headers install-libs DESTDIR=$(SYSROOTDIR) ALL_INCLUDES=include/debug.h + +ifeq ($(ARCH),arm) + +ARCH_CFLAGS1 = -mfloat-abi=soft -march=armv7-a +ARCH_CFLAGS2 = -mfloat-abi=soft -mcpu=cortex-a7 +ARCH_CFLAGS3 = -mfloat-abi=hard -mcpu=cortex-a7 -mfpu=neon-vfpv4 +ARCH_CFLAGS4 = -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 + +define multilib_template = +.PHONY: musl_install_for_liteos_a_user$(1) musl_install_for_liteos_a_user_debug$(1) +all: $$(if $$(filter liteos_a_user,$$(TARGETS)),musl_install_for_liteos_a_user$(1) musl_install_for_liteos_a_user_debug$(1),) +musl_install_for_liteos_a_user$(1): ARCH_CFLAGS = $$($(2)) +musl_install_for_liteos_a_user$(1): musl_install_for_liteos_a_user + $$(HIDE) cd musl_copy_for_liteos_a_user && mkdir -p $$(MUSLBUILDDIR) && cd $$(MUSLBUILDDIR) && \ + ../configure --prefix=/usr --target=$$(TARGET) --libdir=/usr/$$(MULTILIB) \ + CC="$$(CC)" CROSS_COMPILE=$$(CROSS_COMPILE) CFLAGS="$$(CFLAGS)" >/dev/null && \ + sed 's, -m 644 , -m 444 ,g' Makefile | make -f- -sj install-libs DESTDIR=$$(SYSROOTDIR) +musl_install_for_liteos_a_user_debug$(1): ARCH_CFLAGS = $$($(2)) +musl_install_for_liteos_a_user_debug$(1): CFLAGS += -funwind-tables -fasynchronous-unwind-tables -rdynamic -I $$(shell $$(CC) -print-file-name=)include +musl_install_for_liteos_a_user_debug$(1): musl_install_for_liteos_a_user_debug + $$(HIDE) cd musl_copy_for_liteos_a_user_debug && mkdir -p $$(MUSLBUILDDIR) && cd $$(MUSLBUILDDIR) && \ + ../configure --prefix=/usr --target=$$(TARGET) --libdir=/usr/$$(MULTILIB)/debug \ + LDFLAGS="-L $$(dir $$(shell $$(CC) -print-libgcc-file-name)) -lunwind -L lib -ldl" \ + CC="$$(CC)" CROSS_COMPILE=$$(CROSS_COMPILE) CFLAGS="$$(CFLAGS)" >/dev/null && \ + sed 's, -m 644 , -m 444 ,g' Makefile | make -f- -sj install-libs DESTDIR=$$(SYSROOTDIR) +endef + +$(foreach flags,1 2 3 4,$(eval $(call multilib_template,$(flags),ARCH_CFLAGS$(flags)))) + +endif + +clean: + $(HIDE) rm -rf musl_copy_for_* linux_header_install_for_* + +distclean: clean + $(HIDE) rm -rf $(SYSROOTDIR)/lib $(SYSROOTDIR)/usr diff --git a/build/linux/linux_kernel_header_install.sh b/build/linux/linux_kernel_header_install.sh deleted file mode 100755 index dcf96ce509a1a5b077e23ab2110fc2419e8505ff..0000000000000000000000000000000000000000 --- a/build/linux/linux_kernel_header_install.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -#Copyright (c) 2020-2021 Huawei Device Co., Ltd. -#Licensed under the Apache License, Version 2.0 (the "License"); -#you may not use this file except in compliance with the License. -#You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -#Unless required by applicable law or agreed to in writing, software -#distributed under the License is distributed on an "AS IS" BASIS, -#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -#See the License for the specific language governing permissions and -#limitations under the License. - -# This script is used to prepare header files for musl's libc.so. - -set -e -ARM_TYPE=arm -PRJ_ROOT="$PWD/../../../../../" -KERNEL_ROOT="$PRJ_ROOT/kernel/linux-4.19" -ARM_HDR="$KERNEL_ROOT/hdr_install/${ARM_TYPE}_header" -OUT_HDR="$PRJ_ROOT/prebuilts/lite/sysroot/thirdparty/linux_headers_install" -export Z_BUILD_TOP="$PRJ_ROOT" - -if [ -d "$ARM_HDR" ];then -rm -r $ARM_HDR -fi - -if [ -d "$OUT_HDR" ];then -rm -r $OUT_HDR -fi - -mkdir -p $ARM_HDR -mkdir -p $OUT_HDR - -pushd $KERNEL_ROOT -make headers_install ARCH=${ARM_TYPE} INSTALL_HDR_PATH=$ARM_HDR -popd - -function copy_if_exists () { - local check_dir=$1 - local src_dir=$2 - local tgt_dir=$3 - mkdir -p ${tgt_dir} - for file in $(ls -d ${src_dir}/* 2> /dev/null); do - if [[ -f "${file}" ]] && [[ "${file}" =~ .h$ ]]; then - header=$(basename ${file}) - if [[ -f "${check_dir}/${header}" ]]; then - cp ${file} ${tgt_dir} - fi - fi - done -} - -cp -r ${KERNEL_ROOT}/include/uapi ${OUT_HDR} -cp -r ${KERNEL_ROOT}/include/generated/uapi ${OUT_HDR} -cp -r ${ARM_HDR}/include/asm ${OUT_HDR}/uapi -cp -r ${KERNEL_ROOT}/arch/${ARM_TYPE}/include/uapi ${OUT_HDR}/uapi/asm-${ARM_TYPE} -cp -r ${KERNEL_ROOT}/arch/${ARM_TYPE}/include/generated/uapi ${OUT_HDR}/uapi/asm-${ARM_TYPE} -copy_if_exists "${KERNEL_ROOT}/include/uapi/asm-generic" \ - "${KERNEL_ROOT}/arch/${ARM_TYPE}/include/generated/asm" \ - "${OUT_HDR}/uapi/asm-${ARM_TYPE}/asm" -cp ${KERNEL_ROOT}/include/linux/compiler_types.h ${OUT_HDR}/uapi/linux diff --git a/build/linux/linux_kernel_thirdparty_headers.sh b/build/linux/linux_kernel_thirdparty_headers.sh deleted file mode 100755 index 5f5cd7ddfcd12bcb3d598eb12e4fc42ec1b8b919..0000000000000000000000000000000000000000 --- a/build/linux/linux_kernel_thirdparty_headers.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -#Copyright (c) 2020-2021 Huawei Device Co., Ltd. -#Licensed under the Apache License, Version 2.0 (the "License"); -#you may not use this file except in compliance with the License. -#You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -#Unless required by applicable law or agreed to in writing, software -#distributed under the License is distributed on an "AS IS" BASIS, -#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -#See the License for the specific language governing permissions and -#limitations under the License. - -# This script is used to prepare header files for musl's libc.so. - -set -e -ARM_TYPE=arm -PRJ_ROOT="${PWD}/../../../../" -LINUX_HDR="${PRJ_ROOT}/prebuilts/lite/sysroot/thirdparty/linux_headers_install" -TMP_DIR_ORI="${PRJ_ROOT}/prebuilts/lite/sysroot/ohos_tmp_ori" -TMP_DIR="${PRJ_ROOT}/prebuilts/lite/sysroot/ohos_tmp" -if [ $# -eq 1 ]; then - MUSL_DIR="$1/include" -else - MUSL_DIR="${PWD}/musl/include" -fi -export Z_BUILD_TOP="${PRJ_ROOT}" - -if [ ! -d "${LINUX_HDR}/uapi/asm-${ARM_TYPE}" ] || [ ! -d "${LINUX_HDR}/uapi/asm-generic" ] || [ ! -d "${LINUX_HDR}/uapi/linux" ];then - echo "please install headers first!!!" - echo "see guide at ${SYSROOT}/../../thirdparty/README" - exit 1 -fi - -mkdir -p ${TMP_DIR_ORI} -mkdir -p ${TMP_DIR} - -cp -rf ${LINUX_HDR}/* ${TMP_DIR_ORI} -echo "#ifndef _UAPI_LINUX_COMPILER_H" >> ${TMP_DIR_ORI}/uapi/linux/compiler.h -echo "#define _UAPI_LINUX_COMPILER_H" >> ${TMP_DIR_ORI}/uapi/linux/compiler.h -echo "#define __user" >> ${TMP_DIR_ORI}/uapi/linux/compiler.h -echo "#endif" >> ${TMP_DIR_ORI}/uapi/linux/compiler.h - -pushd ${PRJ_ROOT} - python prebuilts/lite/sysroot/build/update_headers.py 2>/dev/null -popd - -if [ ! -d ${MUSL_DIR} ]; then - mkdir -p ${MUSL_DIR} -fi - -cp -rf ${TMP_DIR}/uapi/* ${MUSL_DIR}/ -rm -rf ${TMP_DIR_ORI} -rm -rf ${TMP_DIR} diff --git a/build/liteos/Makefile b/build/liteos/Makefile deleted file mode 100755 index 55ffd35b54a8ca1d47d5d090e58be5a5f1d33354..0000000000000000000000000000000000000000 --- a/build/liteos/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -include $(musldir)/config.mak - -HIDE := @ - -optdir = ./optimized-routines - -MUSL_ALL_OBJS = $(sort $(wildcard $(musldir)/obj/src/*/*.lo) $(wildcard $(musldir)/obj/src/*/$(ARCH)/*.lo) $(wildcard $(musldir)/obj/ldso/*.lo) $(wildcard $(musldir)/obj/compat/time32/*.lo)) -MUSL_LIBC_OBJS = $(filter $(musldir)/obj/src/%,$(MUSL_ALL_OBJS)) $(filter $(musldir)/obj/compat/%,$(MUSL_ALL_OBJS)) - -REPLACED_FUNC = memchr memcpy memcpy_le strcmp strcpy strlen -REPLACED_OBJS = $(addprefix $(musldir)/obj/src/string/,$(addsuffix .lo,$(REPLACED_FUNC))) -REPLACED_OBJS += $(addprefix $(musldir)/obj/src/string/$(ARCH)/,$(addsuffix .lo,$(REPLACED_FUNC))) -MUSL_LIBC_OBJS := $(filter-out $(REPLACED_OBJS),$(MUSL_LIBC_OBJS)) -MUSL_LDSO_OBJS = $(filter $(musldir)/obj/ldso/%,$(MUSL_ALL_OBJS:%.o=%.lo)) - -OPT_ALL_OBJS = $(sort $(wildcard $(optdir)/build/string/arm/*.o)) -OPT_AOBJS = $(OPT_ALL_OBJS) -OPT_OBJS = $(filter $(optdir)/build/string/arm/%,$(OPT_ALL_OBJS:%.o=%.os)) - -LDFLAGS_ALL = -Wl,--sort-section,alignment -Wl,--sort-common -Wl,--gc-sections -Wl,--hash-style=both -Wl,--no-undefined -Wl,--exclude-libs=ALL -Wl,--dynamic-list=$(musldir)/dynamic.list -LDFLAGS_ALL += $(LDFLAGS) - -ifeq ("$(CROSS_COMPILE)", "llvm-") - TARGET_LIBC_A = libc_opt_clang.a - TARGET_LIBC_SO = libc_opt_clang.so -else - TARGET_LIBC_A = libc_opt.a - TARGET_LIBC_SO = libc_opt.so -endif - -ifeq ("$(ARCH)","") - -all: - @echo "Please run linux_header_install.sh thirdparty_headers.sh build_musl(_clang).sh before running make." - @exit 1 - -else - -ifeq ("$(ARCH)","arm") -# making a new libc.a libc.so -all: $(TARGET_LIBC_A) $(TARGET_LIBC_SO) - @echo "success!" - -$(TARGET_LIBC_A): - $(HIDE) $(AR) rc $@ $(MUSL_LIBC_OBJS) $(OPT_AOBJS) - $(HIDE) $(RANLIB) $@ - -$(TARGET_LIBC_SO): - $(HIDE) $(CC) $(LDFLAGS_ALL) -L ${musldir}/lib/ -ldl -lpthread -nostdlib -shared -Wl,-e,_dlstart -o $@ $(MUSL_LIBC_OBJS) $(OPT_OBJS) $(MUSL_LDSO_OBJS) $(LIBCC) - -clean: -ifeq ($(TARGET_LIBC_A), $(wildcard $(TARGET_LIBC_A))) - rm $(TARGET_LIBC_A) -endif -ifeq ($(TARGET_LIBC_SO), $(wildcard $(TARGET_LIBC_SO))) - rm $(TARGET_LIBC_SO) -endif -endif -endif diff --git a/build/liteos/README.md b/build/liteos/README.md deleted file mode 100755 index 8f81d47af688f8c2c35af3595a25590a60dedfe7..0000000000000000000000000000000000000000 --- a/build/liteos/README.md +++ /dev/null @@ -1,14 +0,0 @@ -To build toolchains, we follow the steps. - -1.linux headers install -``` -./linux_header_install.sh -``` -2.build musl -``` -./build_musl_clang.sh -``` -3.copy usr directory -``` -cp -rf usr/lib usr/include ../../usr/ -``` diff --git a/build/liteos/build_musl_clang.sh b/build/liteos/build_musl_clang.sh deleted file mode 100755 index eb0e9c186223203668ec93a956f87e39f51a0c1c..0000000000000000000000000000000000000000 --- a/build/liteos/build_musl_clang.sh +++ /dev/null @@ -1,239 +0,0 @@ -#!/bin/bash - -#Copyright (c) 2020-2021 Huawei Device Co., Ltd. -#Licensed under the Apache License, Version 2.0 (the "License"); -#you may not use this file except in compliance with the License. -#You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -#Unless required by applicable law or agreed to in writing, software -#distributed under the License is distributed on an "AS IS" BASIS, -#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -#See the License for the specific language governing permissions and -#limitations under the License. - -set -e -readonly PRJ_ROOT="$PWD/../../../../../" -readonly MUSL_DIR="${PWD}/musl" -readonly MUSL_CUR_DIR="./musl" -readonly MUSL_DEBUG_DIR="${PWD}/musl_debug" -readonly MUSL_DEBUG_CUR_DIR="./musl_debug" -readonly MUSL_PATCH="${PWD}/musl-debug.patch" -readonly SYSROOT_DEBUG="${PWD}/usr_debug" -readonly MUSL_SOURCE="${PRJ_ROOT}/third_party/musl/*" -readonly OPTIMIZE_DIR="${PWD}/optimized-routines" -readonly OPTIMIZE_SOURCE="${PRJ_ROOT}/third_party/optimized-routines/*" -readonly LITEOSTOPDIR="${PRJ_ROOT}/kernel/liteos_a" -readonly SYSROOT="${PWD}/usr" - -BUILD=`gcc -dumpmachine` -HOST=`gcc -dumpmachine` -TARGET=arm-liteos -CROSS_COMPILE=llvm- -CFLAGS_FOR_TARGET="--target=${TARGET} -mfloat-abi=soft -march=armv7-a -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack" -CFLAGS_FOR_TARGET1="--target=${TARGET} -mfloat-abi=soft -mcpu=cortex-a7 -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack" -CFLAGS_FOR_TARGET2="--target=${TARGET} -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack" -CFLAGS_FOR_TARGET3="--target=${TARGET} -mfloat-abi=hard -mcpu=cortex-a7 -mfpu=neon-vfpv4 -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack" - -TARGET_LIBC_A="${PWD}/libc_opt_clang.a" -TARGET_LIBC_SO="${PWD}/libc_opt_clang.so" - -PARALLEL=`grep ^processor /proc/cpuinfo|wc -l` -LITEOS_COMPILER_PATH=`${LITEOSTOPDIR}/tools/build/mk/get_llvm_compiler_path.sh ${CROSS_COMPILE} ${LITEOSTOPDIR}` -LDFLAG="-L${LITEOS_COMPILER_PATH}/lib/clang/9.0.0/lib/${TARGET} -L${LITEOS_COMPILER_PATH}/lib/${TARGET}/c++ --rtlib=compiler-rt -lclang_rt.builtins -lunwind -fuse-ld=lld -Wl,--build-id=sha1" - -export PATH="${LITEOS_COMPILER_PATH}/bin:${PATH}" - -# prepare to build musl -if [ -d "${MUSL_DIR}" ]; then - rm -r ${MUSL_DIR} -fi -mkdir -p ${MUSL_DIR} - -if [ -d "${SYSROOT}" ]; then - rm -r ${SYSROOT} -fi -mkdir -p ${SYSROOT} - -cp -r ${MUSL_SOURCE} ${MUSL_DIR} - -# prepare to build optimized-routines for improve musl performance -if [ -d "${OPTIMIZE_DIR}" ]; then - rm -r ${OPTIMIZE_DIR} -fi -mkdir -p ${OPTIMIZE_DIR} -cp -r ${OPTIMIZE_SOURCE} ${OPTIMIZE_DIR} - -# build optimized-routines -function build_opt() -{ - pushd ${OPTIMIZE_DIR} - # generate the config.mk file required for compiling the optimized-routines lib. - exec 3>&1 1>config.mk - cat << EOF -# This version of config.mk was generated by: -# build_musl.sh -# The default configuration(CFLAGS) is from optimized-routines. -# Any changes made here will be lost if build_musl.sh re-run - -# Target architecture: aarch64, arm or x86_64 -ARCH = arm - -# Subprojects to build -SUBS = string - -# Use for cross compilation with gcc/clang. -CROSS_COMPILE = ${CROSS_COMPILE} - -# Compiler for the target -CC = ${LITEOS_COMPILER_PATH}/bin/clang -CFLAGS = -std=c99 -pipe -O3 --target=arm-liteos -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=softfp -nostdinc -CFLAGS += -I/${SYSROOT}/../../../usr/include/${TARGET} -CFLAGS += -Wall -Wno-missing-braces - -# Enable debug info. -#HOST_CFLAGS += -g -#CFLAGS += -g - -# Use with clang. -CFLAGS += -ffp-contract=fast -LDFLAGS = -L${LITEOS_COMPILER_PATH}/lib/clang/9.0.0/lib/${TARGET}/a7_softfp_neon-vfpv4 -L${SYSROOT}/../../../usr/lib/${TARGET}/a7_softfp_neon-vfpv4 -lclang_rt.builtins -fuse-ld=lld -nostartfiles - -EOF - exec 1>&3 3>&- - make -j - popd -} - -# generate the final libc.so file. -function install_opt_libc() -{ - if [ -e "${TARGET_LIBC_A}" ]; then - rm ${TARGET_LIBC_A} - fi - if [ -e "${TARGET_LIBC_SO}" ]; then - rm ${TARGET_LIBC_SO} - fi - - # make libc_opt.a libc_opt.so by makefile - make musldir=$2 -j - - # copy libc_opt.so libc_opt.a to a specified directory to replace the original libc.so libc.a file. - if [ -e "${TARGET_LIBC_A}" ] && [ -e "${TARGET_LIBC_SO}" ] ; then - rm $1/lib/libc.a $1/lib/libc.so - cp ${TARGET_LIBC_A} $1/lib/libc.a - cp ${TARGET_LIBC_SO} $1/lib/libc.so - else - printf "build libc_opt error!" - exit 1; - fi -} - -function install_debug_musl() -{ - mkdir -p ${SYSROOT}/include/${TARGET}/debug - mkdir -p ${SYSROOT}/lib/${TARGET}/debug - mkdir -p ${SYSROOT}/lib/${TARGET}/a7_soft/debug - mkdir -p ${SYSROOT}/lib/${TARGET}/a7_softfp_neon-vfpv4/debug - mkdir -p ${SYSROOT}/lib/${TARGET}/a7_hard_neon-vfpv4/debug - cp -f ${SYSROOT_DEBUG}/include/${TARGET}/debug.h ${SYSROOT}/include/${TARGET}/debug - cp -f ${SYSROOT_DEBUG}/lib/${TARGET}/libc.* ${SYSROOT}/lib/${TARGET}/debug - cp -f ${SYSROOT_DEBUG}/lib/${TARGET}/a7_soft/libc.* ${SYSROOT}/lib/${TARGET}/a7_soft/debug - cp -f ${SYSROOT_DEBUG}/lib/${TARGET}/a7_softfp_neon-vfpv4/libc.* ${SYSROOT}/lib/${TARGET}/a7_softfp_neon-vfpv4/debug - cp -f ${SYSROOT_DEBUG}/lib/${TARGET}/a7_hard_neon-vfpv4/libc.* ${SYSROOT}/lib/${TARGET}/a7_hard_neon-vfpv4/debug -} - -# build musl -function build_musl() -{ - pushd $5 - if [ "$5" = "${MUSL_DEBUG_DIR}" ]; then - patch -p1 < ${MUSL_PATCH} - fi - - HEADERDIR="$6/include/${TARGET}" - LIBDIR="$6/lib/${TARGET}" - BINDIR="$6/bin/${TARGET}" - SYSDIR="$6/sys/${TARGET}" - mkdir -p ${LIBDIR} ${BINDIR} ${SYSDIR} ${HEADERDIR} - CC="${LITEOS_COMPILER_PATH}/bin/clang $1" CROSS_COMPILE="${CROSS_COMPILE}" LDFLAGS="${LDFLAG}" ./configure --prefix=$6 --libdir=${LIBDIR} --bindir=${BINDIR} --syslibdir=${SYSDIR} --includedir=$HEADERDIR --build=$BUILD --host=$TARGET - make -j ${PARALLEL} - popd - build_opt - install_opt_libc "$5" "$7" - pushd $5 - make install - make clean - - HEADERDIR="$6/include/${TARGET}" - LIBDIR="$6/lib/${TARGET}/a7_soft" - BINDIR="$6/bin/${TARGET}/a7_soft" - SYSDIR="$6/sys/a7_soft" - mkdir -p ${LIBDIR} ${BINDIR} ${SYSDIR} ${HEADERDIR} - CC="${LITEOS_COMPILER_PATH}/bin/clang $2" CROSS_COMPILE="${CROSS_COMPILE}" LDFLAGS="${LDFLAG}" ./configure --prefix=$6 --libdir=${LIBDIR} --bindir=${BINDIR} --syslibdir=${SYSDIR} --includedir=${HEADERDIR} --build=${BUILD} --host=${TARGET} - make -j ${PARALLEL} - popd - build_opt - install_opt_libc "$5" "$7" - pushd $5 - make install - make clean - - HEADERDIR="$6/include/${TARGET}" - LIBDIR="$6/lib/${TARGET}/a7_softfp_neon-vfpv4" - BINDIR="$6/bin/${TARGET}/a7_softfp_neon-vfpv4" - SYSDIR="$6/sys/${TARGET}/a7_softfp_neon-vfpv4" - mkdir -p ${LIBDIR} ${BINDIR} ${SYSDIR} ${HEADERDIR} - CC="${LITEOS_COMPILER_PATH}/bin/clang $3" CROSS_COMPILE="${CROSS_COMPILE}" LDFLAGS="${LDFLAG}" ./configure --prefix=$6 --libdir=${LIBDIR} --bindir=${BINDIR} --syslibdir=${SYSDIR} --includedir=${HEADERDIR} --build=${BUILD} --host=${TARGET} - make -j ${PARALLEL} - popd - build_opt - install_opt_libc "$5" "$7" - pushd $5 - make install - make clean - - HEADERDIR="$6/include/${TARGET}" - LIBDIR="$6/lib/${TARGET}/a7_hard_neon-vfpv4" - BINDIR="$6/bin/${TARGET}/a7_hard_neon-vfpv4" - SYSDIR="$6/sys/${TARGET}/a7_hard_neon-vfpv4" - mkdir -p ${LIBDIR} ${BINDIR} ${SYSDIR} ${HEADERDIR} - CC="${LITEOS_COMPILER_PATH}/bin/clang $4" CROSS_COMPILE="${CROSS_COMPILE}" LDFLAGS="${LDFLAG}" ./configure --prefix=$6 --libdir=${LIBDIR} --bindir=${BINDIR} --syslibdir=${SYSDIR} --includedir=${HEADERDIR} --build=${BUILD} --host=${TARGET} - make -j ${PARALLEL} - popd - build_opt - install_opt_libc "$5" "$7" - pushd $5 - make install - popd -} - -# prepare linux compat headers for musl -sh thirdparty_headers.sh ${MUSL_DIR} -# build musl -build_musl "${CFLAGS_FOR_TARGET}" "${CFLAGS_FOR_TARGET1}" "${CFLAGS_FOR_TARGET2}" "${CFLAGS_FOR_TARGET3}" "${MUSL_DIR}" "${SYSROOT}" "${MUSL_CUR_DIR}" - -# prepare for musl debug -CFLAGS_DEBUG_FOR_TARGET=${CFLAGS_FOR_TARGET}" -funwind-tables -rdynamic" -CFLAGS_DEBUG_FOR_TARGET1=${CFLAGS_FOR_TARGET1}" -funwind-tables -rdynamic" -CFLAGS_DEBUG_FOR_TARGET2=${CFLAGS_FOR_TARGET2}" -funwind-tables -rdynamic" -CFLAGS_DEBUG_FOR_TARGET3=${CFLAGS_FOR_TARGET3}" -funwind-tables -rdynamic" -UNWIND_H="${LITEOS_COMPILER_PATH}/lib/clang/9.0.0/include/unwind*" -if [ -d "${MUSL_DEBUG_DIR}" ]; then - rm -r ${MUSL_DEBUG_DIR} -fi -if [ -d "${SYSROOT_DEBUG}" ]; then - rm -r ${SYSROOT_DEBUG} -fi -mkdir -p ${MUSL_DEBUG_DIR} -mkdir -p ${SYSROOT_DEBUG} -cp -r ${MUSL_SOURCE} ${MUSL_DEBUG_DIR} -cp -f ${UNWIND_H} ${MUSL_DEBUG_DIR}/include -# prepare linux compat headers for musl debug -sh thirdparty_headers.sh ${MUSL_DEBUG_DIR} -# build musl debug -build_musl "${CFLAGS_DEBUG_FOR_TARGET}" "${CFLAGS_DEBUG_FOR_TARGET1}" "${CFLAGS_DEBUG_FOR_TARGET2}" "${CFLAGS_DEBUG_FOR_TARGET3}" "${MUSL_DEBUG_DIR}" "${SYSROOT_DEBUG}" "${MUSL_DEBUG_CUR_DIR}" -# generate final musl debug shared library -install_debug_musl - diff --git a/build/liteos/linux_header_install.sh b/build/liteos/linux_header_install.sh deleted file mode 100755 index 7b319a7c805fb5657ae0206d6bc15df731a4c4db..0000000000000000000000000000000000000000 --- a/build/liteos/linux_header_install.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -#Copyright (c) 2020-2021 Huawei Device Co., Ltd. -#Licensed under the Apache License, Version 2.0 (the "License"); -#you may not use this file except in compliance with the License. -#You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -#Unless required by applicable law or agreed to in writing, software -#distributed under the License is distributed on an "AS IS" BASIS, -#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -#See the License for the specific language governing permissions and -#limitations under the License. - -# This script is used to prepare header files for musl's libc.so. - -set -e - -PRJ_ROOT="$PWD/../../../../../" -KERNEL_ROOT="$PRJ_ROOT/third_party/Linux_Kernel" -ARM_HDR="$PRJ_ROOT/third_party/Linux_Kernel/hdr_install/arm_header" -OUT_HDR="$PRJ_ROOT/prebuilts/lite/sysroot/thirdparty/linux_headers_install" -export Z_BUILD_TOP="$PRJ_ROOT" - -if [ -d "$ARM_HDR" ];then -rm -r $ARM_HDR -fi - -if [ -d "$OUT_HDR" ];then -rm -r $OUT_HDR -fi - -mkdir -p $ARM_HDR -mkdir -p $OUT_HDR - -pushd $KERNEL_ROOT -make headers_install ARCH=arm INSTALL_HDR_PATH=$ARM_HDR -popd - -cp -r $KERNEL_ROOT/include/uapi/* $OUT_HDR -cp -r $ARM_HDR/include/asm $OUT_HDR diff --git a/build/liteos/mem_info_parse b/build/liteos/mem_info_parse deleted file mode 100755 index 35da158d191b737e9d86f0b2d76519890283c975..0000000000000000000000000000000000000000 --- a/build/liteos/mem_info_parse +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash - -#Copyright (c) 2020-2021 Huawei Device Co., Ltd. -#Licensed under the Apache License, Version 2.0 (the "License"); -#you may not use this file except in compliance with the License. -#You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -#Unless required by applicable law or agreed to in writing, software -#distributed under the License is distributed on an "AS IS" BASIS, -#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -#See the License for the specific language governing permissions and -#limitations under the License. - -LOAD_BASE="0x2000000" -LLVM_ADDR2LINE=llvm-addr2line -GCC_ADDR2LINE=addr2line - -get_line() -{ - SYM_ADDR=$(echo $1 | awk '{print $2}') - ELF_OFFSET=`echo ${SYM_ADDR} | cut -d '[' -f2 | cut -d ']' -f1` - FILE_LINE=`${ADDR2LINE} -f -e $2 ${ELF_OFFSET} | awk 'NR==2'` - if [[ "${FILE_LINE}" == *"?"* ]]; then - typeset ELF_OFFSET=$((ELF_OFFSET+LOAD_BASE)) - ELF_OFFSET=$(echo "obase=16;${ELF_OFFSET}" | bc) - FILE_LINE=`${ADDR2LINE} -f -e $2 ${ELF_OFFSET} | awk 'NR==2'` - fi - echo ${FILE_LINE} -} - -parse_line() -{ - FILE_PATH=$(echo $1 | awk '{print $4}') - ELF_FILE=${FILE_PATH##*/} - ELF_FILE=${ELF_FILE//[$'\t\r\n']} - FLAG=false - for i in $2; do - if [ "${ELF_FILE}" = "$i" ]; then - if [ ! -f "$i" ]; then - echo "Error: no such file: $i" - exit 1 - fi - FILE_LINE=`get_line "$1" $i` - if [[ "${FILE_LINE}" == *"?"* ]] || [ -z "${FILE_LINE}" ]; then - echo " * Error: you need ensure whether file: "$i" was compiled with -g or not! *" - exit 1 - fi - LINE=`echo $1 | tr -d '\r'` - LINE=$(echo ${LINE} | awk '{print $1,$2}') - echo " "${LINE}" at "${FILE_LINE} - FLAG=true - break - fi - done - if [[ "${FLAG}" == "false" ]]; then - echo " "$1 - fi -} - -if [ $# -le 1 ]; then - echo "Usage: ./out2line.sh text.txt elf1 elf2 ..." - exit 1 -fi - -read -n5 -p "Compiler is [gcc/llvm]: " ANSWER -case ${ANSWER} in -(gcc | GCC) - which ${GCC_ADDR2LINE} >/dev/null 2>&1 - if [ $? -eq 0 ]; then - ADDR2LINE=${GCC_ADDR2LINE} - else - echo "${GCC_ADDR2LINE} command not found!" - exit 1 - fi;; -(llvm | LLVM) - which ${LLVM_ADDR2LINE} >/dev/null 2>&1 - if [ $? -eq 0 ]; then - ADDR2LINE=${LLVM_ADDR2LINE} - else - echo "${LLVM_ADDR2LINE} command not found! Trying to use ${GCC_ADDR2LINE}!" - which ${GCC_ADDR2LINE} >/dev/null 2>&1 - if [ $? -eq 0 ]; then - ADDR2LINE=${GCC_ADDR2LINE} - else - echo "${GCC_ADDR2LINE} command not found!" - exit 1 - fi - fi;; -(*) - echo "Error choise!" - exit 1 -esac -echo -e "Now using ${ADDR2LINE} ...\n" - -PARAM_LIST="${*:2}" -cat $1 | while read line; do - HEAD_STRING=$(echo ${line} | awk '{print $1}') - if [[ "${HEAD_STRING}" == *"#"* ]]; then - parse_line "${line}" "${PARAM_LIST}" - else - if [[ "${HEAD_STRING}" == *"["* ]]; then - echo " "${line} - else - echo ${line} - fi - fi -done - diff --git a/build/liteos/musl-debug.patch b/build/liteos/musl-debug.patch deleted file mode 100755 index 45bfab52f55f4299c5a95bd6b1977eda1f707570..0000000000000000000000000000000000000000 --- a/build/liteos/musl-debug.patch +++ /dev/null @@ -1,1639 +0,0 @@ -diff --git a/Makefile b/Makefile -index 9f058ca2..70064d1b 100755 ---- a/Makefile -+++ b/Makefile -@@ -160,7 +160,7 @@ obj/%.lo: $(srcdir)/%.c $(GENH) $(IMPH) - $(HIDE)$(CC_CMD) - - lib/libc.so: $(LOBJS) $(LDSO_OBJS) -- $(HIDE)$(CC) $(CFLAGS_ALL) $(LDFLAGS_ALL) -nostdlib -shared \ -+ $(HIDE)$(CC) $(CFLAGS_ALL) $(LDFLAGS_ALL) -L lib/ -ldl -lpthread -nostdlib -shared \ - -Wl,-e,_dlstart -o $@ $(LOBJS) $(LDSO_OBJS) $(LIBCC) - - lib/libc.a: $(AOBJS) -diff --git a/configure b/configure -index a2728969..b45d8e88 100755 ---- a/configure -+++ b/configure -@@ -467,8 +467,8 @@ fi - # unstrippable. These options force them back to debug sections (and - # cause them not to get generated at all if debugging is off). - # --tryflag CFLAGS_AUTO -fno-unwind-tables --tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables -+# tryflag CFLAGS_AUTO -fno-unwind-tables -+# tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables - - # - # Attempt to put each function and each data object in its own -diff --git a/include/debug.h b/include/debug.h -new file mode 100644 -index 00000000..674ccaa9 ---- /dev/null -+++ b/include/debug.h -@@ -0,0 +1,88 @@ -+#ifndef _DEBUG_H -+#define _DEBUG_H -+ -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+/** -+ * @brief Initialization of the memory debug function, including the output method of memory debug information -+ * and signal registration. You can use command line parameters, "--mwatch" or "--mrecord ", to -+ * call mem_check_init(char *) when executing your program. -+ * -+ * @param f_path The full path of the file to be created where the memory debug information will be written. -+ * If the param is NULL or the file creation fails, the memory debug information will be output via serial -+ * port. -+ * -+ * @return void. -+ */ -+void mem_check_init(char *f_path); -+ -+/** -+ * @brief View thread-level heap memory usage information, signal registration index is 35, you can use "kill -35 pid" -+ * to call watch_mem() when your program is running. The output way of memory debug information is determined by how -+ * the mem_check_init(char *) interface is called. -+ * -+ * @param void. -+ * -+ * @return void. -+ */ -+void watch_mem(void); -+ -+/** -+ * @brief Check whether the heap memory leak is exist or not, signal registration index is 36, you can use "kill -36 -+ * pid" to call check_leak() when your program is running. The output way of memory debug information is determined by -+ * how the mem_check_init(char *) interface is called. -+ * -+ * @param void. -+ * -+ * @return void. -+ */ -+void check_leak(void); -+ -+/** -+ * @brief Check whether the heap memory is integrited or not, signal registration index is 37, you can use "kill -37 -+ * pid" to call check_heap_integrity() when your program is running. The output way of memory debug information is -+ * determined by how the mem_check_init(char *) interface is called. -+ * -+ * @param void. -+ * -+ * @return void. -+ */ -+void check_heap_integrity(void); -+ -+/** -+ * @brief Store the address of the call stack information, the max number is param size. -+ * -+ * @param buffer The array to store address of the call stack information. -+ * @param size The size of buffer. -+ * -+ * @return The exact number of the address. -+ */ -+int backtrace(void **buffer, int size); -+ -+/** -+ * @brief Find the symbol information corresponding to the address stored in the buffer for dynamic linking. -+ * -+ * @param buffer The array stored address of the exact number. -+ * @param size The exact number of the address stored in the buffer. -+ * -+ * @return The pointer to the memory allocated from heap holds the symbol information corresponding to the address -+ * stored in the buffer. You should free the memory the pointer points to after calling backtrace_symbols(). -+ */ -+char **backtrace_symbols(void *const *buffer, int size); -+ -+/** -+ * @brief Print the call stack information of the function calling print_trace(). -+ * -+ * @param void. -+ * -+ * @return void. -+ */ -+void print_trace(void); -+ -+#ifdef __cplusplus -+} -+#endif -+ -+#endif -diff --git a/ldso/dynlink.c b/ldso/dynlink.c -index 40e05220..e311c674 100644 ---- a/ldso/dynlink.c -+++ b/ldso/dynlink.c -@@ -1756,7 +1756,7 @@ void __dls3(size_t *sp, size_t *auxv) - } - if (DL_FDPIC) app.loadmap = app_loadmap; - if (app.tls.size) app.tls.image = laddr(&app, tls_image); -- if (interp_off) ldso.name = laddr(&app, interp_off); -+ if (interp_off) ldso.name = "/lib/libc.so"; - #if 0 - if ((aux[0] & (1UL<