linux-test-project / ltp

Linux Test Project (mailing list: https://lists.linux.it/listinfo/ltp)
https://linux-test-project.readthedocs.io/
GNU General Public License v2.0
2.28k stars 999 forks source link

cannot find -ltirpc #987

Closed mathslimin closed 1 year ago

mathslimin commented 1 year ago

debian11 already apt install libtirpc-dev build arm ltp get error

gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -ltirpc collect2: error: ld returned 1 exit status make[5]: [../../../../../include/mk/rules.mk:45: rpc1] Error 1 make[4]: [../../../../include/mk/generic_trunk_target.inc:108: all] Error 2 make[3]: [../../../include/mk/generic_trunk_target.inc:108: all] Error 2 make[2]: [../../include/mk/generic_trunk_target.inc:108: all] Error 2 make[1]: *** [../include/mk/generic_trunk_target.inc:108: all] Error 2

pevik commented 1 year ago

I suppose you do cross compilation on x86_64 and you installed libtirpc-dev on x86_64, which does not help.

Have look at https://github.com/linux-test-project/ltp/blob/master/ci/debian.cross-compile.sh (you can run it: ARCH=aarch64 ci/debian.cross-compile.sh to solve your problem). Needed things:

dpkg --add-architecture aarch64
apt update
libtirpc-dev:aarch64

See also note about PKG_CONFIG_SYSROOT_DIR https://github.com/linux-test-project/ltp/blob/master/INSTALL#L154

mathslimin commented 1 year ago

fix it simplely by add --without-tirpc to configure

./configure cross_compile=$CROSS_COMPILE_NAME --host=$HOST_TARGET --target=$HOST_TARGET --prefix=$BIN_LOCATE_DIR/${testsuite} --with-realtime-testsuite --without-tirpc
pevik commented 1 year ago

Sure, but that's just a workaround. If you wanted to test RPC or TI-RPC, you would need what I suggested.

binhth1307 commented 1 year ago

Hello @pevik ,

I am doing the cross compiling ltp:arm64 on debian 11 with amd64, and on debian 12 with amd64.

On debian 11 with amd64, I only install libtirpc-dev:amd64.

$ dpkg -l | grep libtirpc
ii  libtirpc-common                      1.3.1-1+deb11u1                all          transport-independent RPC library - common files                                                                                                                               
ii  libtirpc-dev:amd64                   1.3.1-1+deb11u1                amd64        transport-independent RPC library - development files                                                                                                                          
ii  libtirpc3:amd64                      1.3.1-1+deb11u1                amd64        transport-independent RPC library

On debian 12 with amd64, I only install libtirpc-dev:amd64, too.

$ dpkg -l | grep libtirpc
ii  libtirpc-common                      1.3.3+ds-1                     all          transport-independent RPC library - common files
ii  libtirpc-dev:amd64                   1.3.3+ds-1                     amd64        transport-independent RPC library - development files
ii  libtirpc3:amd64                      1.3.3+ds-1                     amd64        transport-independent RPC library

On both the debian 11, the debian 12, I perform the cross compiling by same command On debian 11 with amd64, I don't have any issue. But on debian 12 with amd64, I have issue as this issue.

rpc1.c: In function 'main':
rpc1.c:96:56: warning: argument to 'sizeof' in 'memcpy' call is the same expression as the source; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]                                                                                         
   96 |         memcpy(&server_sin.sin_addr, hp->h_addr, sizeof(hp->h_addr));
      |                                                        ^
/usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld: cannot find -ltirpc: No such file or directory
collect2: error: ld returned 1 exit status
make[5]: *** [../../../../../include/mk/rules.mk:45: rpc1] Error 1
make[4]: *** [../../../../include/mk/generic_trunk_target.inc:108: all] Error 2
make[3]: *** [../../../include/mk/generic_trunk_target.inc:108: all] Error 2
make[2]: *** [../../include/mk/generic_trunk_target.inc:108: all] Error 2
make[1]: *** [../include/mk/generic_trunk_target.inc:108: all] Error 2
make[1]: Leaving directory '/WORK/testcases'
make: *** [Makefile:94: testcases-all] Error 2

On debian 12 with amd64, I add installing libtirpc:arm64 will fix this issue.

I don't know the root cause about above issue.

Question: Could you share the root cause?

Thanks, Binh.

metan-ucw commented 1 year ago

@binhth1307 Cross-compiling is really tricky, in this case it depends on how exactly you execute the ./configure script. How exactly have you executed the ./configure script and was it exactly the same in both cases?

binhth1307 commented 1 year ago

Thank @metan-ucw , I have executed in both cases as below:

./configure --disable-option-checking --prefix=`pwd`/output  --with-open-posix-testsuite --with-realtime-testsuite --without-perl --without-python --target=aarch64-linux-gnu --host=aarch64-linux-gnu --build=x86_64-unknown-linux-gnu build_alias=x86_64-unknown-linux-gnu host_alias=aarch64-linux-gnu target_alias=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc 'CPP=aarch64-linux-gnu-gcc -E' --with-open-posix-testdir=testcases/open_posix_testsuite --cache-file=/dev/null --srcdir=.
pevik commented 1 year ago

Actually, nowadays we depend on PKG_CONFIG_LIBDIR (I'm not sure if LTP ever worked with --build, --host and --target triplet), see https://github.com/linux-test-project/ltp/blob/master/INSTALL#L154-L178

For aarch64 on Debian it'd be PKG_CONFIG_LIBDIR=/usr/lib/aarch64-linux-gnu/pkgconfig, for armel PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabi/pkgconfig, for armhf PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig.