Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 648630 - sys-process/htop-2.1.0 - htop-Process.o: In function `Process_writeField': Process.c:(.text+0xe4b): undefined reference to `minor'
Summary: sys-process/htop-2.1.0 - htop-Process.o: In function `Process_writeField': Pr...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Christian Ruppert (idl0r)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-23 18:20 UTC by Piotr Karbowski (RETIRED)
Modified: 2018-02-26 12:35 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
htop-2.1.0-check-sysmacros.patch (htop-2.1.0-check-sysmacros.patch,528 bytes, patch)
2018-02-25 08:19 UTC, Dennis Schridde
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Karbowski (RETIRED) gentoo-dev 2018-02-23 18:20:24 UTC
I am unable to build htop-2.1.0. I see that it is patched to include sysmacros.h, however it's behind defguard of ifdef HAVE_SYS_SYSMACROS_H.

Removing the ifdef around making the sys/sysmacros.h being always included fixes it in my case.

Build log:
make[1]: Entering directory '/var/portage/tmp/portage/sys-process/htop-2.1.0/work/htop-2.1.0'
x86_64-pc-linux-gnu-gcc -pedantic -Wall -Wextra -std=c99 -D_XOPEN_SOURCE_EXTENDED -DSYSCONFDIR=\"/etc\" -I"./linux" -rdynamic  -O3 -pipe -march=native    -o htop   htop-AvailableMetersPanel.o htop-CategoriesPanel.o htop-CheckItem.o htop-ClockMeter.o htop-ColorsPanel.o htop-ColumnsPanel.o htop-CPUMeter.o htop-CRT.o htop-MainPanel.o htop-DisplayOptionsPanel.o htop-FunctionBar.o htop-Hashtable.o htop-Header.o htop-htop.o htop-ListItem.o htop-LoadAverageMeter.o htop-MemoryMeter.o htop-Meter.o htop-MetersPanel.o htop-Object.o htop-Panel.o htop-BatteryMeter.o htop-Process.o htop-ProcessList.o htop-RichString.o htop-ScreenManager.o htop-Settings.o htop-SignalsPanel.o htop-StringUtils.o htop-SwapMeter.o htop-TasksMeter.o htop-UptimeMeter.o htop-TraceScreen.o htop-UsersTable.o htop-Vector.o htop-AvailableColumnsPanel.o htop-AffinityPanel.o htop-HostnameMeter.o htop-OpenFilesScreen.o htop-Affinity.o htop-IncSet.o htop-Action.o htop-EnvScreen.o htop-InfoScreen.o htop-XAlloc.o linux/htop-Platform.o linux/htop-IOPriorityPanel.o linux/htop-IOPriority.o linux/htop-LinuxProcess.o linux/htop-LinuxProcessList.o linux/htop-LinuxCRT.o linux/htop-Battery.o  -L/usr/lib64 -lncursesw -lm  
htop-Process.o: In function `Process_writeField':
Process.c:(.text+0xe4b): undefined reference to `minor'
Process.c:(.text+0xe58): undefined reference to `major'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:733: htop] Error 1
make[1]: Leaving directory '/var/portage/tmp/portage/sys-process/htop-2.1.0/work/htop-2.1.0'
make: *** [Makefile:528: all] Error 2

Running with sys-libs/glibc-2.26-r6

Reproducible: Always
Comment 1 Ben Kohler gentoo-dev 2018-02-24 13:51:07 UTC
I think HAVE_SYS_SYSMACROS_H doesn't get defined unless we put sys/sysmacros.h into AC_CHECK_HEADERS in configure.ac.  Maybe something like this:

--- a/configure.ac
+++ b/configure.ac
@@ -56,7 +56,7 @@
 # ----------------------------------------------------------------------
 AC_HEADER_DIRENT
 AC_HEADER_STDC
-AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h],[:],[
+AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/sysmacros.h sys/time.h unistd.h],[:],[
   missing_headers="$missing_headers $ac_header"
 ])
 AC_CHECK_HEADERS([execinfo.h],[:],[:])
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -25,6 +25,7 @@
 #include <time.h>
 #include <assert.h>
 #include <sys/types.h>
+#include <sys/sysmacros.h>
 #include <fcntl.h>
 
 #ifdef HAVE_DELAYACCT
--- a/Process.c
+++ b/Process.c
@@ -19,6 +19,9 @@
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#ifdef HAVE_SYS_SYSMACROS_H
+# include <sys/sysmacros.h>	/* for major, minor */
+#endif
 #include <unistd.h>
 #include <stdlib.h>
 #include <signal.h>
Comment 2 Piotr Karbowski (RETIRED) gentoo-dev 2018-02-24 13:56:09 UTC
Seems like it's the case. I can build htop with your patch.
Comment 3 Ben Kohler gentoo-dev 2018-02-24 13:58:58 UTC
I'm not sure this patch is technically correct since autoreconf will die if sys/sysmacros.h is missing, rather than just detect it's missing and not define HAVE_SYS_SYSMACROS_H for that case.

But someone with more autotools skills will have to chime in here, I think.
Comment 4 Dennis Schridde 2018-02-25 08:15:04 UTC
(In reply to Ben Kohler from comment #3)
> I'm not sure this patch is technically correct since autoreconf will die if
> sys/sysmacros.h is missing, rather than just detect it's missing and not
> define HAVE_SYS_SYSMACROS_H for that case.
> 
> But someone with more autotools skills will have to chime in here, I think.

You are right:
if test ! -z "$missing_headers"; then
  AC_MSG_ERROR([missing headers: $missing_headers])
fi

The solution is to patch it like this:
 # Checks for header files.
 # ----------------------------------------------------------------------
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h],[:],[
   missing_headers="$missing_headers $ac_header"
 ])
-AC_CHECK_HEADERS([execinfo.h],[:],[:])
+AC_CHECK_HEADERS([execinfo.h sys/sysmacros.h],[:],[:])
 
 # Checks for typedefs, structures, and compiler characteristics.

In that case sys/sysmacros.h is not added to the headers configure.ac bails on when missing, but it just passes and goes on (`:`) instead.
Comment 5 Dennis Schridde 2018-02-25 08:19:09 UTC
Created attachment 520968 [details, diff]
htop-2.1.0-check-sysmacros.patch
Comment 6 Larry the Git Cow gentoo-dev 2018-02-26 12:35:53 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=711f07a43b5e011123a93e7b09edcdce1008f4cd

commit 711f07a43b5e011123a93e7b09edcdce1008f4cd
Author:     Lars Wendler <polynomial-c@gentoo.org>
AuthorDate: 2018-02-26 12:34:55 +0000
Commit:     Lars Wendler <polynomial-c@gentoo.org>
CommitDate: 2018-02-26 12:34:55 +0000

    sys-process/htop: Replaced sysmacros patch with a much better one.
    
    See https://github.com/hishamhm/htop/pull/746
    
    Closes: https://bugs.gentoo.org/648630
    Package-Manager: Portage-2.3.24, Repoman-2.3.6

 sys-process/htop/files/htop-2.1.0-sysmacros.patch | 91 ++++++++++++++++-------
 1 file changed, 66 insertions(+), 25 deletions(-)