Yangtai,
你好,我们在移植oh到RISCV64
startfive的开发板,下载对应的仓库代码:https://gitee.com/iscas-taiyang ,
指定manifest.xml 为visionfive.xml,更新完成后,按照readme文档,编译会遇到找不到C++标准库问题:
[19/24598] CXX
obj/ark/js_runtime/ecmascript/compiler/mock/libark_mock_stub_set/mock_stub_m.o
FAILED: obj/ark/js_runtime/ecmascript/compiler/mock/libark_mock_stub_set/mock_stub_m.o
/usr/bin/ccache ../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/bin/clang++ -MMD -MF
obj/ark/js_runtime/ecmascript/compiler/mock/libark_mock_stub_set/mock_stub_m.o.d
-DV8_DEPRECATION_WARNINGS -D_GNU_SOURCE -DHAVE_SYS_UIO_H -D__MUSL__
-D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG -D_LIBCPP_NO_NATIVE_SEMAPHORES
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DCOMPONENT_BUILD
-D__GNU_SOURCE=1 -DCHROMIUM_CXX_TWEAK_INLINES -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC
-D__BUILD_LINUX_WITH_CLANG -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0
-DPANDA_ENABLE_LTO -DPANDA_USE_MUSL -DIS_PUBLIC_VERSION -DPANDA_TARGET_UNIX
-DPANDA_USE_FUTEX -DNDEBUG -DPANDA_TARGET_64 -DPANDA_TARGET_RV64
-DPANDA_USE_32_BIT_POINTER -DECMASCRIPT_SUPPORT_CPUPROFILER -DECMASCRIPT_SUPPORT_SNAPSHOT
-DECMASCRIPT_SUPPORT_DEBUGGER -Iobj/third_party/musl/usr/include/riscv64-linux-ohos
-Ioverride/third_party -I../.. -Igen -I../../ark/js_runtime -I../../ark/runtime_core
-I../../ark/runtime_core/libpandabase -Igen/ark/runtime_core/libpandabase
-I../../ark/runtime_core/libpandafile -I../../ark/runtime_core/libziparchive
-Igen/ark/runtime_core/libpandafile -Igen/ark/runtime_core/libpandafile/include
-I../../third_party/zlib -I../../third_party/zlib/contrib/minizip
-I../../third_party/icu/icu4c/source/common -I../../third_party/icu/icu4c/source/i18n
-I../../third_party/icu/icu4c/source -I../../third_party/bounds_checking_function/include
-fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector-strong
-Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables
-fPIC -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang
-instcombine-lower-dbg-declare=0 -no-canonical-prefixes -ffunction-sections
-fno-short-enums --target=riscv64-linux-ohos -mno-relax -march=rv64imafdc -mabi=lp64d
-mno-relax -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety
-Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing
-Wno-unneeded-internal-declaration -Wno-error=c99-designator
-Wno-error=anon-enum-enum-conversion -Wno-error=implicit-fallthrough
-Wno-error=sizeof-array-div -Wno-error=reorder-init-list -Wno-error=range-loop-construct
-Wno-error=deprecated-copy -Wno-error=implicit-int-float-conversion
-Wno-error=inconsistent-dllimport -Wno-error=unknown-warning-option
-Wno-error=abstract-final-class -Wno-error=sign-compare -Wno-error=int-in-bool-context
-Wno-error=xor-used-as-pow -Wno-error=return-stack-address -Wno-error=dangling-gsl
-Wno-undefined-var-template -Wno-nonportable-include-path -Wno-user-defined-warnings
-Wno-unused-lambda-capture -Wno-null-pointer-arithmetic -Wno-enum-compare-switch
-Wno-gnu-folding-constant -Wno-error=non-c-typedef-for-linkage -Wno-extern-c-compat -O2
-fno-ident -fdata-sections -ffunction-sections -fno-omit-frame-pointer -g2 -ggnu-pubnames
-fno-common -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -std=c++17
-fno-exceptions -fno-rtti --sysroot=obj/third_party/musl -fvisibility-inlines-hidden -Wall
-Wshadow -Werror -Wextra -pedantic -Wno-invalid-offsetof -Wno-gnu-statement-expression
-pipe -Wdate-time -Wformat=2 -flto -c
../../ark/js_runtime/ecmascript/compiler/mock/mock_stub_m.cpp -o
obj/ark/js_runtime/ecmascript/compiler/mock/libark_mock_stub_set/mock_stub_m.o
../../ark/js_runtime/ecmascript/compiler/mock/mock_stub_m.cpp:15:10: fatal error:
'cstdint' file not found
#include <cstdint>
^~~~~~~~~
修改//build/config/ohos/BUILD.gn文件,在include_dirs中添加“"${clang_base_path}/include/c++/v1"”,又会出现重复定义错误:
[11/24593] CXX obj/base/hiviewdfx/hiview/base/logger/hi_logger.o
FAILED: obj/base/hiviewdfx/hiview/base/logger/hi_logger.o
/usr/bin/ccache ../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/bin/clang++ -MMD -MF
obj/base/hiviewdfx/hiview/base/logger/hi_logger.o.d -DV8_DEPRECATION_WARNINGS
-D_GNU_SOURCE -DHAVE_SYS_UIO_H -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC
-D__BUILD_LINUX_WITH_CLANG -D_LIBCPP_NO_NATIVE_SEMAPHORES -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DCOMPONENT_BUILD -D__GNU_SOURCE=1
-DCHROMIUM_CXX_TWEAK_INLINES -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG
-DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0
-Iobj/third_party/musl/usr/include/riscv64-linux-ohos
-I../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/include/c++/v1 -Ioverride/third_party
-I../.. -Igen -I../../base/hiviewdfx/hilog/interfaces/native/innerkits/include
-I../../third_party/bounds_checking_function/include -I../../utils/native/base/include
-I../../base/hiviewdfx/hiview/base/include
-I../../base/hiviewdfx/hiview/base/utility/include
-I../../base/hiviewdfx/hiview/base/event_pool
-I../../base/hiviewdfx/hiview/base/event_store/include
-I../../base/hiviewdfx/hiview/include
-I../../base/hiviewdfx/hiview/adapter/utility/include
-I../../base/hiviewdfx/hiview/base/logstore/include
-I../../base/hiviewdfx/hiview/adapter/dbstore/include -fno-strict-aliasing
--param=ssp-buffer-size=4 -fstack-protector-strong -Wno-builtin-macro-redefined
-D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -fcolor-diagnostics
-fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0
-no-canonical-prefixes -ffunction-sections -fno-short-enums --target=riscv64-linux-ohos
-mno-relax -march=rv64imafdc -mabi=lp64d -mno-relax -Wall -Werror -Wextra
-Wimplicit-fallthrough -Wthread-safety -Wno-missing-field-initializers
-Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration
-Wno-error=c99-designator -Wno-error=anon-enum-enum-conversion
-Wno-error=implicit-fallthrough -Wno-error=sizeof-array-div -Wno-error=reorder-init-list
-Wno-error=range-loop-construct -Wno-error=deprecated-copy
-Wno-error=implicit-int-float-conversion -Wno-error=inconsistent-dllimport
-Wno-error=unknown-warning-option -Wno-error=abstract-final-class -Wno-error=sign-compare
-Wno-error=int-in-bool-context -Wno-error=xor-used-as-pow -Wno-error=return-stack-address
-Wno-error=dangling-gsl -Wno-undefined-var-template -Wno-nonportable-include-path
-Wno-user-defined-warnings -Wno-unused-lambda-capture -Wno-null-pointer-arithmetic
-Wno-enum-compare-switch -Wno-gnu-folding-constant -Wno-error=non-c-typedef-for-linkage
-Wno-extern-c-compat -O2 -fno-ident -fdata-sections -ffunction-sections
-fno-omit-frame-pointer -g2 -ggnu-pubnames -fno-common -Wheader-hygiene
-Wstring-conversion -Wtautological-overlap-compare -std=c++17 -fno-exceptions -fno-rtti
--sysroot=obj/third_party/musl -fvisibility-inlines-hidden -D__HIVIEW_OHOS__
-D__OHOS_STANDARD_SYSTEM__ -c ../../base/hiviewdfx/hiview/base/hi_logger.cpp -o
obj/base/hiviewdfx/hiview/base/logger/hi_logger.o
In file included from ../../base/hiviewdfx/hiview/base/hi_logger.cpp:16:
In file included from ../../base/hiviewdfx/hiview/base/include/hi_logger.h:19:
In file included from ../../base/hiviewdfx/hiview/base/include/i_logger.h:18:
In file included from
../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/include/c++/v1/string:511:
In file included from
../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/include/c++/v1/string_view:179:
In file included from
../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/include/c++/v1/__string:57:
In file included from
../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/include/c++/v1/algorithm:651:
In file included from
../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/include/c++/v1/cstring:60:
obj/third_party/musl/usr/include/riscv64-linux-ohos/string.h:11:9: error: 'NULL'
macro redefined [-Werror,-Wmacro-redefined]
#define NULL 0L
^
../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/lib/clang/12.0.1/include/stddef.h:84:13:
note: previous definition is here
# define NULL __null
^
修改//build/config/ohos/BUILD.gn文件,在include_dirs中去掉"${musl_sysroot}/usr/include/${abi_target}",又会出现链接错误:
[1067/9471] LINK hiviewdfx/hilog_service/hilogd
FAILED: hiviewdfx/hilog_service/hilogd exe.unstripped/hiviewdfx/hilog_service/hilogd
/usr/bin/env "../../build/toolchain/gcc_link_wrapper.py"
--output="hiviewdfx/hilog_service/hilogd"
--strip="../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/bin/llvm-strip"
--unstripped-file="./exe.unstripped/hiviewdfx/hilog_service/hilogd" --
../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/bin/clang++ -Wl,--fatal-warnings
-Wl,--build-id=md5 -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs
-Wl,--as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -Wl,--no-undefined
-Wl,--exclude-libs=libunwind_llvm.a -Wl,--exclude-libs=libc++_static.a
-Wl,--exclude-libs=libvpx_assembly_arm.a --target=riscv64-linux-ohos -Wl,--hash-style=gnu
-Werror -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -Wl,--gdb-index
--sysroot=obj/third_party/musl -nostdlib -Lobj/third_party/musl/usr/lib/riscv64-linux-ohos
-L../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/lib/riscv64-linux-ohos/c++
-L../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/lib/clang/12.0.1/lib/riscv64-linux-ohos
-Wl,--warn-shared-textrel -Bdynamic -Wl,-z,nocopyreloc -pie -o
"./exe.unstripped/hiviewdfx/hilog_service/hilogd"
obj/third_party/musl/usr/lib/riscv64-linux-ohos/Scrt1.o
obj/third_party/musl/usr/lib/riscv64-linux-ohos/crti.o -Wl,--start-group
@"hiviewdfx/hilog_service/hilogd.rsp" -lunwind
../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/lib/clang/12.0.1/lib/riscv64-linux-ohos/libclang_rt.builtins.a
-lc -lc++
../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/lib/riscv64-linux-ohos/c++/libc++abi.a
-ldl -lm -Wl,--end-group obj/third_party/musl/usr/lib/riscv64-linux-ohos/crtn.o
ld.lld: error: undefined symbol: __cxa_thread_atexit_impl
>> referenced by cxa_thread_atexit.cpp
>> cxa_thread_atexit.cpp.o:(__cxa_thread_atexit) in archive
../../prebuilts/clang/ohos/linux-x86_64/llvm-riscv/lib/riscv64-linux-ohos/c++/libc++abi.a
clang-12: error: linker command failed with exit code 1 (use -v to see
invocation)
我的repo操作步骤:
1. repo init -u
https://gitee.com/iscas-taiyang/manifest.git -b OpenHarmony-3.2-Beta2
-m chipsets/visionfive.xml --repo-branch=stable
--repo-url=http://mirrors.tuna.tsinghua.edu.cn/git/git-repo
1. repo sync -c
1. repo forall -c 'git lfs pull'
备注:我的开发环境为Ubuntu 22.04, 已经配置好hb编译环境,工具链llvm使用 llvm-riscv工具链llvm-riscv-1124.tar.gz(临时使用)
请教下,贵司是否遇到过这个问题,希望沟通交流下,多谢!
Regards,
Deon