openwrt / packages

Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md
GNU General Public License v2.0
4.01k stars 3.49k forks source link

htop missing backtrace capability in musl #11863

Closed nrobert13 closed 4 years ago

nrobert13 commented 4 years ago

Maintainer: @champtar Environment: mvebu Linksys WRT1900ACS v19.07.2 with musl

Description: Building htop for fails with the following error. This is due to the fact that musl doesn't implement the backtrace capability opposed to glibc.

arm-openwrt-linux-muslgnueabi-gcc -pedantic -Wall -Wextra -std=c99 -D_XOPEN_SOURCE_EXTENDED -DSYSCONFDIR=\"/etc\" -I"./linux" -rdynamic -D_GNU_SOURCE -D_DEFAULT_SOURCE -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=hard -iremap/home/nrobert/opt/openwrt/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/htop-2.2.0:htop-2.2.0 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro    -L/home/nrobert/opt/openwrt/staging_dir/target-arm_cortex-a9+vfpv3_musl_eabi/usr/lib -L/home/nrobert/opt/openwrt/staging_dir/target-arm_cortex-a9+vfpv3_musl_eabi/lib -L/home/nrobert/opt/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-7.5.0_musl_eabi/usr/lib -L/home/nrobert/opt/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-7.5.0_musl_eabi/lib -znow -zrelro  -o htop   AvailableMetersPanel.o CategoriesPanel.o CheckItem.o ClockMeter.o ColorsPanel.o ColumnsPanel.o CPUMeter.o CRT.o MainPanel.o DisplayOptionsPanel.o FunctionBar.o Hashtable.o Header.o htop.o ListItem.o LoadAverageMeter.o MemoryMeter.o Meter.o MetersPanel.o Object.o Panel.o BatteryMeter.o Process.o ProcessList.o RichString.o ScreenManager.o Settings.o SignalsPanel.o StringUtils.o SwapMeter.o TasksMeter.o UptimeMeter.o TraceScreen.o UsersTable.o Vector.o AvailableColumnsPanel.o AffinityPanel.o HostnameMeter.o OpenFilesScreen.o Affinity.o IncSet.o Action.o EnvScreen.o InfoScreen.o XAlloc.o linux/Platform.o linux/IOPriorityPanel.o linux/IOPriority.o linux/LinuxProcess.o linux/LinuxProcessList.o linux/LinuxCRT.o linux/Battery.o  -lncurses -ltinfo -lm  
/home/nrobert/opt/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-7.5.0_musl_eabi/lib/gcc/arm-openwrt-linux-muslgnueabi/7.5.0/../../../../arm-openwrt-linux-muslgnueabi/bin/ld: linux/LinuxCRT.o: in function `CRT_handleSIGSEGV':
LinuxCRT.c:(.text+0x28): undefined reference to `backtrace'
/home/nrobert/opt/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-7.5.0_musl_eabi/lib/gcc/arm-openwrt-linux-muslgnueabi/7.5.0/../../../../arm-openwrt-linux-muslgnueabi/bin/ld: LinuxCRT.c:(.text+0x48): undefined reference to `backtrace_symbols_fd'
collect2: error: ld returned 1 exit status
Makefile:820: recipe for target 'htop' failed
make[5]: *** [htop] Error 1
make[5]: Leaving directory '/home/nrobert/opt/openwrt/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/htop-2.2.0'
Makefile:603: recipe for target 'all' failed
make[4]: *** [all] Error 2
make[4]: Leaving directory '/home/nrobert/opt/openwrt/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/htop-2.2.0'
Makefile:55: recipe for target '/home/nrobert/opt/openwrt/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/htop-2.2.0/.built' failed
make[3]: *** [/home/nrobert/opt/openwrt/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/htop-2.2.0/.built] Error 2
nrobert13 commented 4 years ago

new libexecinfo package https://github.com/openwrt/packages/pull/11864

nrobert13 commented 4 years ago

patch htop to use libexecinfo https://github.com/openwrt/packages/pull/11865

hnyman commented 4 years ago

Building htop for fails with the following error.

htop compiles just fine with musl. Are you using some special config/options???

nrobert13 commented 4 years ago
 scripts/diffconfig.sh | egrep -v "(^#|^$|PACKAGE|BUSYBOX|DEFAULT|OPEN)" config_lede_w_tools 
CONFIG_DEVEL=y
CONFIG_BUILD_LOG=y
CONFIG_LIBCURL_COOKIES=y
CONFIG_LIBCURL_FILE=y
CONFIG_LIBCURL_FTP=y
CONFIG_LIBCURL_HTTP=y
CONFIG_LIBCURL_MBEDTLS=y
CONFIG_LIBCURL_NO_SMB="!"
CONFIG_LIBCURL_PROXY=y
CONFIG_RSYNC_zlib=y
CONFIG_TVHEADEND_CWC_SUPPORT=y
CONFIG_TVHEADEND_LINUXDVB_SUPPORT=y
CONFIG_TOOLCHAINOPTS=y
hnyman commented 4 years ago

Well, you grepped away all interesting package selections as well as the package disables with "#", which are part of the config...

Just show the diffconfig output.

nrobert13 commented 4 years ago

I thought the package selection would influence this... here's the diffconfig,


 scripts/diffconfig.sh                                                                                                                       [176/1934]
CONFIG_TARGET_mvebu=y                                                                                                                                                                                       
CONFIG_TARGET_mvebu_cortexa9=y                                                                                                                                                                              
CONFIG_TARGET_mvebu_cortexa9_DEVICE_linksys_wrt1900acs=y                                                                                                                                                    
CONFIG_DEVEL=y                                                                                                                                                                                              
CONFIG_TOOLCHAINOPTS=y                                                                                                                                                                                      
CONFIG_BUILD_LOG=y                                                                                                                                                                                          
CONFIG_GNUTLS_ALPN=y                                                                                                                                                                                        
CONFIG_GNUTLS_ANON=y                                                                                                                                                                                        
CONFIG_GNUTLS_DTLS_SRTP=y                                                                                                                                                                                   
CONFIG_GNUTLS_HEARTBEAT=y                                                                                                                                                                                   
CONFIG_GNUTLS_OCSP=y                                                                                                                                                                                        
CONFIG_GNUTLS_PSK=y                                                                                                                                                                                         
CONFIG_LIBCURL_COOKIES=y                                                                                                                                                                                    
CONFIG_LIBCURL_FILE=y                                                                                                                                                                                       
CONFIG_LIBCURL_FTP=y                                                                                                                                                                                        
CONFIG_LIBCURL_HTTP=y                                                                                                                                                                                       
CONFIG_LIBCURL_MBEDTLS=y                                                                                                                                                                                    
CONFIG_LIBCURL_NO_SMB="!"
CONFIG_LIBCURL_PROXY=y
CONFIG_OPENSSL_ENGINE=y
CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM=y
CONFIG_OPENSSL_WITH_ASM=y
CONFIG_OPENSSL_WITH_CHACHA_POLY1305=y
CONFIG_OPENSSL_WITH_CMS=y
CONFIG_OPENSSL_WITH_DEPRECATED=y
CONFIG_OPENSSL_WITH_ERROR_MESSAGES=y
CONFIG_OPENSSL_WITH_NPN=y
CONFIG_OPENSSL_WITH_PSK=y
CONFIG_OPENSSL_WITH_SRP=y
CONFIG_OPENSSL_WITH_TLS13=y
CONFIG_OPENVPN_openssl_ENABLE_DEF_AUTH=y
CONFIG_OPENVPN_openssl_ENABLE_FRAGMENT=y
CONFIG_OPENVPN_openssl_ENABLE_LZ4=y
CONFIG_OPENVPN_openssl_ENABLE_LZO=y
CONFIG_OPENVPN_openssl_ENABLE_MULTIHOME=y
CONFIG_OPENVPN_openssl_ENABLE_PF=y
CONFIG_OPENVPN_openssl_ENABLE_PORT_SHARE=y
CONFIG_OPENVPN_openssl_ENABLE_SERVER=y
CONFIG_OPENVPN_openssl_ENABLE_SMALL=y
CONFIG_PACKAGE_NTFS-3G_HAS_PROBE=y
CONFIG_PACKAGE_ar=m
CONFIG_PACKAGE_bind-dig=y
CONFIG_PACKAGE_bind-libs=y
CONFIG_PACKAGE_binutils=m
CONFIG_PACKAGE_block-mount=y
CONFIG_PACKAGE_ca-bundle=y
CONFIG_PACKAGE_cgi-io=y
CONFIG_PACKAGE_curl=y
CONFIG_PACKAGE_ddns-scripts=y
CONFIG_PACKAGE_diffutils=y
CONFIG_PACKAGE_e2fsprogs=y
CONFIG_PACKAGE_ebtables=y
CONFIG_PACKAGE_ebtables-utils=y
CONFIG_PACKAGE_expect=m                                                                                                                                                                           [122/1934]
CONFIG_PACKAGE_fdisk=y
CONFIG_PACKAGE_gdb=m
CONFIG_PACKAGE_gdbserver=m
CONFIG_PACKAGE_htop=y
CONFIG_PACKAGE_iftop=y
CONFIG_PACKAGE_iperf3=y
CONFIG_PACKAGE_ipset=y
CONFIG_PACKAGE_ipset-dns=y
CONFIG_PACKAGE_kmod-br-netfilter=y
CONFIG_PACKAGE_kmod-crypto-aead=y
CONFIG_PACKAGE_kmod-crypto-crc32c=y
CONFIG_PACKAGE_kmod-crypto-des=y
CONFIG_PACKAGE_kmod-crypto-ecb=y
CONFIG_PACKAGE_kmod-crypto-hash=y
CONFIG_PACKAGE_kmod-crypto-hmac=y
CONFIG_PACKAGE_kmod-crypto-manager=y
CONFIG_PACKAGE_kmod-crypto-md4=y
CONFIG_PACKAGE_kmod-crypto-md5=y
CONFIG_PACKAGE_kmod-crypto-null=y
CONFIG_PACKAGE_kmod-crypto-pcompress=y
CONFIG_PACKAGE_kmod-crypto-sha256=y
CONFIG_PACKAGE_kmod-dnsresolver=y
CONFIG_PACKAGE_kmod-dvb-usb-tt3650=m
CONFIG_PACKAGE_kmod-dvb-usb-tt4650=m
CONFIG_PACKAGE_kmod-dvb-usb-tthtc=m
CONFIG_PACKAGE_kmod-ebtables=y
CONFIG_PACKAGE_kmod-ebtables-ipv4=y
CONFIG_PACKAGE_kmod-ebtables-watchers=y
CONFIG_PACKAGE_kmod-fs-autofs4=y
CONFIG_PACKAGE_kmod-fs-cifs=y
CONFIG_PACKAGE_kmod-fs-ext4=y
CONFIG_PACKAGE_kmod-fs-nfs=y
CONFIG_PACKAGE_kmod-fs-nfs-common=y
CONFIG_PACKAGE_kmod-fs-nfs-v3=y
CONFIG_PACKAGE_kmod-fs-nfs-v4=y
CONFIG_PACKAGE_kmod-fs-ntfs=y
CONFIG_PACKAGE_kmod-fuse=y
CONFIG_PACKAGE_kmod-input-core=y
CONFIG_PACKAGE_kmod-ipt-ipset=y
CONFIG_PACKAGE_kmod-lib-crc16=y
CONFIG_PACKAGE_kmod-nfnetlink=y
CONFIG_PACKAGE_kmod-nls-base=y
CONFIG_PACKAGE_kmod-sched-core=y
CONFIG_PACKAGE_kmod-scsi-core=y
CONFIG_PACKAGE_kmod-tun=y
CONFIG_PACKAGE_kmod-usb-core=y
CONFIG_PACKAGE_kmod-usb-serial=y
CONFIG_PACKAGE_kmod-usb-serial-pl2303=y
CONFIG_PACKAGE_kmod-usb-storage=y
CONFIG_PACKAGE_libatomic=y
CONFIG_PACKAGE_libbfd=m
CONFIG_PACKAGE_libblkid=y
CONFIG_PACKAGE_libcomerr=y
CONFIG_PACKAGE_libcurl=y                                                                                                                                                                           [68/1934]
CONFIG_PACKAGE_libdvbapi=m
CONFIG_PACKAGE_libdvben50221=m
CONFIG_PACKAGE_libelf=y
CONFIG_PACKAGE_libevent2=y
CONFIG_PACKAGE_libexecinfo=y
CONFIG_PACKAGE_libext2fs=y
CONFIG_PACKAGE_libf2fs=y
CONFIG_PACKAGE_libfdisk=y
CONFIG_PACKAGE_libgcrypt=m
CONFIG_PACKAGE_libgmp=m
CONFIG_PACKAGE_libgnutls=m
CONFIG_PACKAGE_libgpg-error=m
CONFIG_PACKAGE_libiconv-full=m
CONFIG_PACKAGE_libipset=y
CONFIG_PACKAGE_libiwinfo-lua=y
CONFIG_PACKAGE_libjpeg=m
CONFIG_PACKAGE_liblua=y
CONFIG_PACKAGE_liblucihttp=y
CONFIG_PACKAGE_liblucihttp-lua=y
CONFIG_PACKAGE_liblzo=y
CONFIG_PACKAGE_libmbedtls=y
CONFIG_PACKAGE_libmicrohttpd-ssl=m
CONFIG_PACKAGE_libmnl=y
CONFIG_PACKAGE_libncurses=y
CONFIG_PACKAGE_libnettle=m
CONFIG_PACKAGE_libopcodes=m
CONFIG_PACKAGE_libopenssl=y
CONFIG_PACKAGE_libopenssl-conf=y
CONFIG_PACKAGE_libpcap=y
CONFIG_PACKAGE_libpopt=y
CONFIG_PACKAGE_libreadline=m
CONFIG_PACKAGE_librt=y
CONFIG_PACKAGE_libsmartcols=y
CONFIG_PACKAGE_libss=y
CONFIG_PACKAGE_libstdcpp=y
CONFIG_PACKAGE_libubus-lua=y
CONFIG_PACKAGE_libuci-lua=y
CONFIG_PACKAGE_libucsi=m
CONFIG_PACKAGE_libusb-1.0=y
CONFIG_PACKAGE_libustream-openssl=y
CONFIG_PACKAGE_libuuid=y
CONFIG_PACKAGE_libuv=y
CONFIG_PACKAGE_libwebcam=m
CONFIG_PACKAGE_libxml2=m
CONFIG_PACKAGE_lua=y
CONFIG_PACKAGE_luci=y
CONFIG_PACKAGE_luci-app-ddns=y
CONFIG_PACKAGE_luci-app-firewall=y
CONFIG_PACKAGE_luci-app-opkg=y
CONFIG_PACKAGE_luci-app-wifischedule=y
CONFIG_PACKAGE_luci-base=y
CONFIG_PACKAGE_luci-compat=y
CONFIG_PACKAGE_luci-lib-ip=y
CONFIG_PACKAGE_luci-lib-ipkg=y                                                                                                                                                                     [14/1934]
CONFIG_PACKAGE_luci-lib-jsonc=y
CONFIG_PACKAGE_luci-lib-nixio=y
CONFIG_PACKAGE_luci-mod-admin-full=y
CONFIG_PACKAGE_luci-mod-network=y
CONFIG_PACKAGE_luci-mod-status=y
CONFIG_PACKAGE_luci-mod-system=y
CONFIG_PACKAGE_luci-proto-ipv6=y
CONFIG_PACKAGE_luci-proto-ppp=y
CONFIG_PACKAGE_luci-ssl-openssl=y
CONFIG_PACKAGE_luci-theme-bootstrap=y
CONFIG_PACKAGE_mkf2fs=y
CONFIG_PACKAGE_motion=m
CONFIG_PACKAGE_mtr=y
CONFIG_PACKAGE_netcat=y
CONFIG_PACKAGE_netmount=y
CONFIG_PACKAGE_ntfs-3g=y
CONFIG_PACKAGE_objdump=m
CONFIG_PACKAGE_openssl-util=y
CONFIG_PACKAGE_openvpn-easy-rsa=y
CONFIG_PACKAGE_openvpn-openssl=y
CONFIG_PACKAGE_procps-ng=y
CONFIG_PACKAGE_procps-ng-free=y
CONFIG_PACKAGE_procps-ng-kill=y
CONFIG_PACKAGE_procps-ng-pgrep=y
CONFIG_PACKAGE_procps-ng-pkill=y
CONFIG_PACKAGE_procps-ng-pmap=y
CONFIG_PACKAGE_procps-ng-ps=y
CONFIG_PACKAGE_procps-ng-pwdx=y
CONFIG_PACKAGE_procps-ng-skill=y
CONFIG_PACKAGE_procps-ng-slabtop=y
CONFIG_PACKAGE_procps-ng-snice=y
CONFIG_PACKAGE_procps-ng-tload=y
CONFIG_PACKAGE_procps-ng-top=y
CONFIG_PACKAGE_procps-ng-uptime=y
CONFIG_PACKAGE_procps-ng-vmstat=y
CONFIG_PACKAGE_procps-ng-w=y
CONFIG_PACKAGE_procps-ng-watch=y
CONFIG_PACKAGE_resize2fs=y
CONFIG_PACKAGE_rpcd=y
CONFIG_PACKAGE_rpcd-mod-file=y
CONFIG_PACKAGE_rpcd-mod-iwinfo=y
CONFIG_PACKAGE_rpcd-mod-luci=y
CONFIG_PACKAGE_rpcd-mod-rrdns=y
CONFIG_PACKAGE_rsync=y
CONFIG_PACKAGE_ss=y
CONFIG_PACKAGE_tc=y
CONFIG_PACKAGE_tcl=m
CONFIG_PACKAGE_tcpdump=y
CONFIG_PACKAGE_terminfo=y
CONFIG_PACKAGE_tune2fs=y
CONFIG_PACKAGE_tvheadend=m
CONFIG_PACKAGE_uhttpd=y
CONFIG_PACKAGE_uhttpd-mod-ubus=y
CONFIG_PACKAGE_usbreset=y
CONFIG_PACKAGE_usbutils=y
CONFIG_PACKAGE_uvcdynctrl=m
CONFIG_PACKAGE_wifischedule=y
CONFIG_PACKAGE_wireless-tools=y
CONFIG_PACKAGE_xupnpd=m
CONFIG_PACKAGE_zlib=y
CONFIG_RSYNC_zlib=y
CONFIG_TVHEADEND_CWC_SUPPORT=y
CONFIG_TVHEADEND_LINUXDVB_SUPPORT=y
# CONFIG_PACKAGE_python3-click-log-src is not set
# CONFIG_PACKAGE_python3-decorator-src is not set
# CONFIG_PACKAGE_python3-schema-src is not set
hnyman commented 4 years ago

That is a massive set of packages. Possibly the htop configure script finds a bit too much available functionality, and tries to compile also that backtrace support. Or something similar. (If your htop vanilla compilation really fails, without you having tried to somehow force the backtrace to be active.)

Note that buildbot builds htop nicely for both master and 19.07, so it is possibly something in your config that triggers the breakage.

Your patches would introduce backtrace features and the libexecinfo library as mandatory part of htop for all users, and I am not sure if that is really appropriate. If it would be included, it should be optional, I think.

nrobert13 commented 4 years ago

Agree with you, but not sure how can we make it optional ...

micmac1 commented 4 years ago

I think there must be something special about your buildroot. LinuxCRT.c only uses backtrace in case HAVE_EXECINFO_H is set by configure script. That only happens when configure detects a usable execinfo.h, which shouldn't exist in your buildroot with musl.

Can you check where the header is located in your buildroot?

micmac1 commented 4 years ago

You can also look at config.log and search for "checking execinfo.h presence" if that helps. That should at least give you the include directories used.

micmac1 commented 4 years ago

Now I get it, you have libexecinfo because you've prepared pull request #11860

htop doesn't have an off-switch for libexecinfo. You'd need to spin up a patch for that.

micmac1 commented 4 years ago

Or alternatively a patch to link to the external lib your pull request is providing.

nrobert13 commented 4 years ago

the cause effect is actually the other way around. I get this error during build, so I created the PR #11865 and #11864 which would fix it. now that you said that LinuxCRT is using backtrace only if configure detects execinfo.h, I realised that I introduced this libexecinfo some time back, because tvheadend build was failing due to the same error. So already having libexecinfo in my buildroot, htop also enables backtrace capability. Unfortunately I'm not proficient enough in C to patch htop...

micmac1 commented 4 years ago

Ah, thanks for clearing this up. This was confusion me quite a bit.

So I would suggest remove libexecinfo from your buildroot and be done with it, close this issue and the two pull requests of yours. I take it that you don't need htop linked against libexecinfo for debugging stuff.

I think introducing external libexecinfo like this could cause the same problem that you found with htop for other packages as well. More headache :)

nrobert13 commented 4 years ago

you are right, I don't need backtrace, but I cannot remove libexecinfo due to tvheadend. I need tvheadend, which doesn't build without it.

micmac1 commented 4 years ago

Understandable, but that's not an OpenWrt problem. You have your customized tvheadend package. That's why you need libexecinfo. Right?

And you can remove your libexecinfo before compiling htop. And when you want to compile your tvheadend again you can install libexecinfo again.

nrobert13 commented 4 years ago

true. guess what. Just tried to remove the libexecinfo from buildroot and remove it from tvheadend package as well, and it worked. thanks for helping me figure this out. closing this and the PR's.