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

FS#3810 - Build of x86_64 target fails on x86_64 host (libtool erroneously picks /usr/lib64/libc.so) #7002

Closed
openwrt-bot opened this issue May 13, 2021 · 7 comments
Labels
flyspray release/19.07 pull request/issue targeted (also) for OpenWrt 19.07 release toolchain pull request/issue with toolchain related changes

Comments

@openwrt-bot
Copy link

zhubr:

I'm building openwrt 19.08.7 x86_64 target on an x86_64 linux box, and building fails in libpcre, with a libtool complaining that it tried to relink libpcreposix.la, and for that it found /usr/lib64/libc.so with an invalid ELF header. The complaint is true somewhat, because indeed /usr/lib64/libc.so is not an ELF on my system, but obviously it should not even be trying to pick a local system library at the first place.

There is a very old similar bugreport (solved long ago) --
https://dev.archive.openwrt.org/ticket/8399

Note: 32-bit x86 builds complete successfully on this same box.

@openwrt-bot
Copy link
Author

zhubr:

  • meant 19.07.7

@openwrt-bot
Copy link
Author

zhubr:

Uh, apparently the problem is quite an opposite to what I initially supposed. The failure happens in libtool at this step:

(cd .libs && rm -f libpcreposix.so.0.0.6U && mv -f libpcreposix.so.0.0.6 libpcreposix.so.0.0.6U)
mv: error while loading shared libraries: /usr/lib64/libc.so: invalid ELF header

So apparenly the system 'mv' command fails to operate, likely because libtool attempted to prevent finding local system libraries so much that even 'mv' somehow starts failing. Maybe have to look at some env vars...

@openwrt-bot
Copy link
Author

zhubr:

Ok, found it.
My system 'mv' binary uses system libpcre.so and the system does not employ rpath.
Therefore, after changing to pcre/.libs (see above), 'mv' attempts to link against pcre/.libs/libpcre.so instead of regular libpcre.so and fails.
Not yet sure how to properly fix it though.

@openwrt-bot
Copy link
Author

zhubr:

Ok, I've created some fix.
Not sure how good it is but it works for me here. See patch attached.

190-fix-more-libtool.patch

@openwrt-bot
Copy link
Author

bjonglez:

See https://openwrt.org/submitting-patches

Note that changes to 19.07 need a very good reason to get accepted, but you can start by submitting a fix for the master branch.

@aparcar aparcar added release/19.07 pull request/issue targeted (also) for OpenWrt 19.07 release toolchain pull request/issue with toolchain related changes labels Feb 22, 2022
@ynezz
Copy link
Member

ynezz commented May 24, 2022

OpenWrt 19.07 release is EOL, try to reproduce the issue with latest supported release and feel free to ask for issue reopening if the problem is still present, thanks.

@ynezz ynezz closed this as completed May 24, 2022
@rydy
Copy link

rydy commented Nov 16, 2022

OpenWrt 19.07 release is EOL, try to reproduce the issue with latest supported release and feel free to ask for issue reopening if the problem is still present, thanks.

I tried to build openwrt based on Centos7, The following error occurs.

[reid@localhost openwrt]$ make package/pcre/compile V=99
make[2]: Entering directory `/home/reid/work_space/openwrt/scripts/config'
make[2]: `conf' is up to date.
make[2]: Leaving directory `/home/reid/work_space/openwrt/scripts/config'
make[1]: Entering directory '/home/reid/work_space/openwrt'
make[2]: Entering directory '/home/reid/work_space/openwrt/package/libs/toolchain'
echo "libc" >> /home/reid/work_space/openwrt/staging_dir/target-x86_64_musl/pkginfo/toolchain.default.install
echo "libgcc" >> /home/reid/work_space/openwrt/staging_dir/target-x86_64_musl/pkginfo/toolchain.default.install
echo "libpthread" >> /home/reid/work_space/openwrt/staging_dir/target-x86_64_musl/pkginfo/toolchain.default.install
echo "librt" >> /home/reid/work_space/openwrt/staging_dir/target-x86_64_musl/pkginfo/toolchain.default.install
make[2]: Leaving directory '/home/reid/work_space/openwrt/package/libs/toolchain'
time: package/libs/toolchain/compile#0.16#0.11#0.25
make[2]: Entering directory '/home/reid/work_space/openwrt/package/libs/pcre'
rm -f /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/.built
touch /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/.built_check
CFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45=pcre-8.45 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/include -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include/fortify -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include " CXXFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45=pcre-8.45 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/include -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include/fortify -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include " LDFLAGS="-L/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/lib -L/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/lib -znow -zrelro " make  -C /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/. AR="x86_64-openwrt-linux-musl-gcc-ar" AS="x86_64-openwrt-linux-musl-gcc -c -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45=pcre-8.45 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" LD=x86_64-openwrt-linux-musl-ld NM="x86_64-openwrt-linux-musl-gcc-nm" CC="x86_64-openwrt-linux-musl-gcc" GCC="x86_64-openwrt-linux-musl-gcc" CXX="x86_64-openwrt-linux-musl-g++" RANLIB="x86_64-openwrt-linux-musl-gcc-ranlib" STRIP=x86_64-openwrt-linux-musl-strip OBJCOPY=x86_64-openwrt-linux-musl-objcopy OBJDUMP=x86_64-openwrt-linux-musl-objdump SIZE=x86_64-openwrt-linux-musl-size CROSS="x86_64-openwrt-linux-musl-" ARCH="x86_64" CFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45=pcre-8.45 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" ;
make[3]: Entering directory '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45'
make  all-am
make[4]: Entering directory '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45'
make[4]: Leaving directory '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45'
make[3]: Leaving directory '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45'
CFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45=pcre-8.45 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/include -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include/fortify -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include " CXXFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45=pcre-8.45 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/include -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include/fortify -I/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include " LDFLAGS="-L/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/lib -L/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/lib -znow -zrelro " make -C /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/. AR="x86_64-openwrt-linux-musl-gcc-ar" AS="x86_64-openwrt-linux-musl-gcc -c -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45=pcre-8.45 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" LD=x86_64-openwrt-linux-musl-ld NM="x86_64-openwrt-linux-musl-gcc-nm" CC="x86_64-openwrt-linux-musl-gcc" GCC="x86_64-openwrt-linux-musl-gcc" CXX="x86_64-openwrt-linux-musl-g++" RANLIB="x86_64-openwrt-linux-musl-gcc-ranlib" STRIP=x86_64-openwrt-linux-musl-strip OBJCOPY=x86_64-openwrt-linux-musl-objcopy OBJDUMP=x86_64-openwrt-linux-musl-objdump SIZE=x86_64-openwrt-linux-musl-size CROSS="x86_64-openwrt-linux-musl-" ARCH="x86_64" CFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45=pcre-8.45 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" DESTDIR="/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install"  install;
make[3]: Entering directory '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45'
make  install-am
make[4]: Entering directory '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45'
make[5]: Entering directory '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45'
 /usr/bin/mkdir -p '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib'
 /bin/sh ./libtool   --mode=install /home/reid/work_space/openwrt/staging_dir/host/bin/install -c   libpcre.la libpcre16.la libpcre32.la libpcreposix.la '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib'
libtool: install: /home/reid/work_space/openwrt/staging_dir/host/bin/install -c .libs/libpcre.so.1.2.13 /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib/libpcre.so.1.2.13
libtool: install: (cd /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib && { ln -s -f libpcre.so.1.2.13 libpcre.so.1 || { rm -f libpcre.so.1 && ln -s libpcre.so.1.2.13 libpcre.so.1; }; })
libtool: install: (cd /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib && { ln -s -f libpcre.so.1.2.13 libpcre.so || { rm -f libpcre.so && ln -s libpcre.so.1.2.13 libpcre.so; }; })
libtool: install: /home/reid/work_space/openwrt/staging_dir/host/bin/install -c .libs/libpcre.lai /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib/libpcre.la
libtool: install: /home/reid/work_space/openwrt/staging_dir/host/bin/install -c .libs/libpcre16.so.0.2.13 /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib/libpcre16.so.0.2.13
libtool: install: (cd /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib && { ln -s -f libpcre16.so.0.2.13 libpcre16.so.0 || { rm -f libpcre16.so.0 && ln -s libpcre16.so.0.2.13 libpcre16.so.0; }; })
libtool: install: (cd /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib && { ln -s -f libpcre16.so.0.2.13 libpcre16.so || { rm -f libpcre16.so && ln -s libpcre16.so.0.2.13 libpcre16.so; }; })
libtool: install: /home/reid/work_space/openwrt/staging_dir/host/bin/install -c .libs/libpcre16.lai /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib/libpcre16.la
libtool: install: /home/reid/work_space/openwrt/staging_dir/host/bin/install -c .libs/libpcre32.so.0.0.13 /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib/libpcre32.so.0.0.13
libtool: install: (cd /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib && { ln -s -f libpcre32.so.0.0.13 libpcre32.so.0 || { rm -f libpcre32.so.0 && ln -s libpcre32.so.0.0.13 libpcre32.so.0; }; })
libtool: install: (cd /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib && { ln -s -f libpcre32.so.0.0.13 libpcre32.so || { rm -f libpcre32.so && ln -s libpcre32.so.0.0.13 libpcre32.so; }; })
libtool: install: /home/reid/work_space/openwrt/staging_dir/host/bin/install -c .libs/libpcre32.lai /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install/usr/lib/libpcre32.la
libtool: warning: relinking 'libpcreposix.la'
libtool: install: (cd /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45; /bin/sh "/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/libtool"  --tag CC --mode=relink x86_64-openwrt-linux-musl-gcc -fvisibility=hidden -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45=pcre-8.45 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -version-info 0:7:0 -L/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/lib -L/home/reid/work_space/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/lib -znow -zrelro -o libpcreposix.la -rpath /usr/lib libpcreposix_la-pcreposix.lo libpcre.la -inst-prefix-dir /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/ipkg-install)
mv: error while loading shared libraries: /lib64/libc.so: invalid ELF header
libtool:   error: error: relink 'libpcreposix.la' with the above command before installing it
make[5]: *** [Makefile:1537: install-libLTLIBRARIES] Error 1
make[5]: Leaving directory '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45'
make[4]: *** [Makefile:3076: install-am] Error 2
make[4]: Leaving directory '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45'
make[3]: *** [Makefile:3069: install] Error 2
make[3]: Leaving directory '/home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45'
make[2]: *** [Makefile:130: /home/reid/work_space/openwrt/build_dir/target-x86_64_musl/pcre-8.45/.built] Error 2
make[2]: Leaving directory '/home/reid/work_space/openwrt/package/libs/pcre'
time: package/libs/pcre/compile#0.51#0.26#0.70
    ERROR: package/libs/pcre failed to build.
make[1]: *** [package/Makefile:116: package/libs/pcre/compile] Error 1
make[1]: Leaving directory '/home/reid/work_space/openwrt'
make: *** [/home/reid/work_space/openwrt/include/toplevel.mk:231: package/pcre/compile] Error 2
[reid@localhost openwrt]$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray release/19.07 pull request/issue targeted (also) for OpenWrt 19.07 release toolchain pull request/issue with toolchain related changes
Projects
None yet
Development

No branches or pull requests

4 participants