bugmake - Bugs: bug #63185, configure fails to detect...

 
 

bug #63185: configure fails to detect getloadavg declaration on sun and aix.

Submitter:  Dmitry Goncharov <dgoncharov>
Submitted:  Sat 08 Oct 2022 08:26:14 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  4.4 Operating System:  POSIX-Based
Fixed Release:  4.4 Triage Status:  Small Effort
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 27 Oct 2022 07:20:05 PM UTC, comment #8: 

RE sys/time.h, I have no idea why that's there, I must have found an example somewhere or something.  But we already manage this in makeint.h so it's not needed here anyway; I'll remove it.

Paul D. Smith <psmith>
Group administrator
Wed 26 Oct 2022 07:28:57 PM UTC, comment #7: 

i guess, it is possible that sys/loadavg.h exists, but still doesn't declare getloadavg.

It is also possible that configure sets HAVE_DECL_GETLOADAVG to 0 and also defines HAVE_SYS_LOADAVG_H and in this case there is a declaraion in sys/loadavg.h and also in job.c. Which should be benign as long as the declarations match.

This alone

#if HAVE_DECL_GETLOADAVG == 0
int getloadavg (double loadavg[], int nelem);
#endif

gets the job done.

Btw, why do you include sys/time.h?

Dmitry Goncharov <dgoncharov>
Wed 26 Oct 2022 05:21:37 PM UTC, comment #6: 

You're right, I forgot that it's always wrong to use ifdef/ifndef with HAVE_DECL values in autoconf.

But, I don't understand why you've added the !defined(HAVE_SYS_LOADAVG_H) to the check.  If the function is not declared we need to declare it, it doesn't matter whether we have sys/loadavg.h or not.

I don't know of any system like this, but it could be that sys/loadavg.h exists but still doesn't declare getloadavg().  And if it does declare getloadavg(), then HAVE_DECL_GETLOADAVG will be 1 anyway not 0 and we don't need to check it.

Am I missing something?  I don't want to get this wrong again.

Paul D. Smith <psmith>
Group administrator
Tue 25 Oct 2022 10:23:24 PM UTC, comment #5: 

i guess this fell through the cracks. Paul, can you please have a look at the attached patch?
One part of the patch you already applied, but there is the second part, which is still needed.

Dmitry Goncharov <dgoncharov>
Wed 19 Oct 2022 01:28:44 AM UTC, comment #4: 

This piece of code


+#ifdef HAVE_SYS_LOADAVG_H
+# include <sys/loadavg.h>
+#endif


indeed helps on sun, because sun has sys/loadavg.h.

However, aix does not have sys/loadavg.h (i didn't find a declaration of getloadavg in any header on aix) and the change above does not help on aix.

The problem with the existing code

#ifndef HAVE_DECL_GETLOADAVG
int getloadavg (double loadavg[], int nelem);
#endif


is that configure always defines HAVE_DECL_GETLOADAVG.
On sun and linux HAVE_DECL_GETLOADAVG is defined to be 1.
On aix HAVE_DECL_GETLOADAVG is defined to be 0.


$ grep HAVE_DECL_GETLOADAVG src/config.h
#define HAVE_DECL_GETLOADAVG 0


This causes the preprocessor to remove this declaration of getloadavg from job.c.

The attached patch does

-#ifndef HAVE_DECL_GETLOADAVG
+#if HAVE_DECL_GETLOADAVG == 0 && !defined(HAVE_SYS_LOADAVG_H)
 int getloadavg (double loadavg[], int nelem);
 #endif


Tested on linux, sun and aix, all 64 bit.

Dmitry Goncharov <dgoncharov>
Tue 18 Oct 2022 08:13:24 PM UTC, comment #3: 

I added my fix below, hope it works...

Paul D. Smith <psmith>
Group administrator
Sat 15 Oct 2022 10:34:18 PM UTC, comment #2: 

Instead of reverting the content in job.c, can you keep that content but add this:


#if HAVE_SYS_LOADAVG_H
#include <sys/time.h>
#include <sys/loadavg.h>
#endif

#ifndef HAVE_DECL_GETLOADAVG
int getloadavg (double loadavg[], int nelem);
#endif


and see if that works?

Paul D. Smith <psmith>
Group administrator
Sat 08 Oct 2022 08:27:23 PM UTC, comment #1: 

The latest configure from 4.3.90 fails to detect getloadavg declaration on sun
and aix.


../src/job.c: In function ▒load_too_high▒:
../src/job.c:2103:7: warning: implicit declaration of function ▒getloadavg▒ [-Wimplicit-function-declaration]
 2103 |   if (getloadavg (&load, 1) != 1)
      |       ^~~~~~~~~~



$ grep GETLOADAVG src/config.h
#define GNULIB_TEST_GETLOADAVG 1
#define HAVE_DECL_GETLOADAVG 1
$


The change was introduced in dd24a4c1cfa7b6928ddb2bcd00a023f23aaaf440.


$ git sh --pretty=format:%H dd24a4c1cfa7b6928ddb2bcd00a023f23aaaf440  -- configure.ac src/job.c
dd24a4c1cfa7b6928ddb2bcd00a023f23aaaf440
diff --git a/configure.ac b/configure.ac
index 51817b2c..4a0d5301 100644
--- a/configure.ac
+++ b/configure.ac
@@ -437,6 +437,9 @@ AS_CASE([$host],
 AC_DEFINE_UNQUOTED([PATH_SEPARATOR_CHAR],['$PATH_SEPARATOR'],
         [Define to the character that separates directories in PATH.])

+AC_DEFINE_UNQUOTED([HAVE_DECL_GETLOADAVG],[$HAVE_DECL_GETLOADAVG],
+        [Define to 1 if you have the declaration of 'getloadavg'.])
+
 # Include the Maintainer's Makefile section, if it's here.

 MAINT_MAKEFILE=/dev/null
diff --git a/src/job.c b/src/job.c
index 0c9054bd..402d409f 100644
--- a/src/job.c
+++ b/src/job.c
@@ -216,7 +216,7 @@ pid2str (pid_t pid)
   return pidstring;
 }

-#ifndef HAVE_GETLOADAVG
+#ifndef HAVE_DECL_GETLOADAVG
 int getloadavg (double loadavg[], int nelem);
 #endif


This is the relevant part of config.log

configure:7677: checking for getloadavg
configure:7677: gcc-11 -o conftest -Wall -Wextra -ggdb -m64 -DMAKE_MAINTAINER_MODE=1   conftest.c  >&5
configure:7677: $? = 0
configure:7677: result: yes
configure:8030: checking for sys/loadavg.h
configure:8030: gcc-11 -c -Wall -Wextra -ggdb -m64 -DMAKE_MAINTAINER_MODE=1  conftest.c >&5
configure:8030: $? = 0
configure:8030: result: yes
configure:8042: checking whether getloadavg is declared
configure:8042: gcc-11 -c -Wall -Wextra -ggdb -m64 -DMAKE_MAINTAINER_MODE=1   conftest.c >&5
configure:8042: $? = 0
configure:8042: result: yes
...
| #define HAVE_SYS_LOADAVG_H 1
| #define GNULIB_TEST_GETLOADAVG 1
...
ac_cv_func_getloadavg=yes
...
ac_cv_have_decl_getloadavg=yes
...
GETLOADAVG_LIBS=''
GL_COND_OBJ_GETLOADAVG_FALSE=''
GL_COND_OBJ_GETLOADAVG_TRUE='#'
...
GL_GNULIB_GETLOADAVG='1'
...
HAVE_DECL_GETLOADAVG='1'
...
#define HAVE_DECL_GETLOADAVG 1


Reverting the change in job.c fixes the issue.

Dmitry Goncharov <dgoncharov>
Sat 08 Oct 2022 08:26:14 PM UTC, original submission:  

.

Dmitry Goncharov <dgoncharov>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #53879:  sv63185.diff added by dgoncharov (930B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by dgoncharov (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-10-19 dgoncharov Attached File- Added sv63185.diff, #53879
    2022-10-18 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.4
        Triage StatusNone Small Effort

    Back to the top

    Powered by Savane 3.13-da57.
    Corresponding source code