Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请提供qemu linux userspace程序 #18

Closed
nihui opened this issue May 30, 2022 · 8 comments
Closed

请提供qemu linux userspace程序 #18

nihui opened this issue May 30, 2022 · 8 comments

Comments

@nihui
Copy link

nihui commented May 30, 2022

上个版本有发布的qemu,怎么这次删掉了?
需要这个qemu在x86服务器上跑ci

@FreeFlyingSheep
Copy link
Contributor

已更新。

@nihui
Copy link
Author

nihui commented Jun 1, 2022

已更新。

用起来不正常,以下是用交叉编译工具链编译 helloworld,用 qemu 跑的过程

下载工具链和qemu

wget https://github.com/loongson/build-tools/releases/download/2022.05.29/loongarch64-clfs-5.0-cross-tools-gcc-glibc.tar.xz
tar -xf loongarch64-clfs-5.0-cross-tools-gcc-glibc.tar.xz
wget https://github.com/loongson/build-tools/releases/download/2022.05.29/qemu-loongarch64
chmod +x qemu-loongarch64

编译cpp helloworld

echo -e "#include <iostream>\nint main() { std::cerr << \"hello loongarch64\" << std::endl; return 0; }" > hello.cpp
./cross-tools/bin/loongarch64-unknown-linux-gnu-g++ hello.cpp -march=loongarch64 -o hello

配置ld prefix,qemu执行

export LD_LIBRARY_PATH=./cross-tools/target/usr/lib64:$LD_LIBRARY_PATH
export QEMU_STRACE=1
./qemu-loongarch64 -L ./cross-tools/target/usr ./hello

报错

./hello: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: Error 38

开启 export QEMU_STRACE=1 后看到输出

113 brk(NULL) = 0x000000400000c000
113 uname(0x400300ed08) = 0
113 faccessat(AT_FDCWD,"/etc/ld.so.preload",R_OK,AT_EACCESS|AT_SYMLINK_NOFOLLOW|0x3035c70) = -1 errno=2 (No such file or directory)
113 openat(AT_FDCWD,"/__w/ncnn/ncnn/cross-tools/target/usr/lib64/tls/libstdc++.so.6",O_RDONLY|O_CLOEXEC) = -1 errno=2 (No such file or directory)
113 Unknown syscall 79
113 openat(AT_FDCWD,"/__w/ncnn/ncnn/cross-tools/target/usr/lib64/libstdc++.so.6",O_RDONLY|O_CLOEXEC) = 3
113 read(3,0x300e420,832) = 832
113 Unknown syscall 79
113 close(3) = 0
./hello: error while loading shared libraries: libstdc++.so.6: cannot stat shared object: Error 38
113 writev(2,0x400300e040,0xa) = 99
113 exit_group(127)

@yetist
Copy link
Contributor

yetist commented Jun 1, 2022

我怎么感觉工具链可能要重新做一下,附件是本地静态编译出来的,用这个qemu能跑。
hello.zip

@nihui
Copy link
Author

nihui commented Jun 4, 2022

https://github.com/loongson/build-tools/releases/tag/2021.12.21 看到旧版本又放上来了

@nihui
Copy link
Author

nihui commented Jun 4, 2022

旧版本工具链,用新的qemu跑,也会报错 cannot stat shared object: Error 38,这标明 qemu 有问题?

@yetist
Copy link
Contributor

yetist commented Jun 4, 2022

动态链接的话,C库可能需要使用最新的内核头文件重新编译一下,编译之前需要打个补丁? loongson/glibc#29

@sunhaiyong1978
Copy link
Collaborator

@nihui
Copy link
Author

nihui commented Jun 6, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants