Extended %check so it actually runs 'hello world' binaries

This commit is contained in:
Alexey Sheplyakov 2021-06-09 17:09:54 +00:00
parent 77ba6bf982
commit 519dd0f982

View File

@ -1,6 +1,7 @@
%define target aarch64-linux-gnu
%define target_kernel arm64
%define target_qemu_arch aarch64
%define gcc_branch 8
Name: cross-gcc%gcc_branch-%target
@ -28,6 +29,7 @@ BuildRequires: gcc-source = %version-%orig_gcc_release
BuildRequires: binutils-source = %binutils_evr
BuildRequires: glibc-source = %glibc_evr
BuildRequires: kernel-source-%kernel_version
BuildRequires: qemu-user-static-%target_qemu_arch
%define _libexecdir /usr/libexec
@ -228,9 +230,19 @@ int main(int argc, char** argv) {
}
EOF
gcc_runtime_libdir=`dirname $(%buildroot%prefix/bin/%target-gcc --print-libgcc-file-name)`
%buildroot%prefix/bin/%target-gcc -o hello_c hello.c || exit 2
%buildroot%prefix/bin/%target-g++ -o hello_cpp hello.cpp || exit 3
# Note: LD_LIBRARY_PATH is for **target** ld.so.
# Use qemu-user-static so qemu-user is not affected by LD_LIBRARY_PATH
env LD_LIBRARY_PATH=%buildroot%sysroot/lib64:${gcc_runtime_libdir} \
qemu-%target_qemu_arch-static -L %buildroot%sysroot ./hello_c || exit 5
env LD_LIBRARY_PATH=%buildroot%sysroot/lib64:${gcc_runtime_libdir} \
qemu-%target_qemu_arch-static -L %buildroot%sysroot ./hello_cpp || exit 7
%files
%_bindir/*
%prefix/lib/gcc/%target/%gcc_branch/*