https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91694
Bug ID: 91694
Summary: configure.ac does not correctly check for gethostname
Product: gcc
Version: 9.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgomp
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
CC: jakub at gcc dot gnu.org
Target Milestone: ---
In commit 7e5a76c87d27b72e05b0b32189e9cfafaebba6bc at:
https://github.com/gcc-mirror/gcc/commit/7e5a76c87d27b72e05b0b32189e9cfafaebba6bc
configure.ac (line 283) is setup to COMPILE a program that has:
#include <unistd.h>
int
main ()
{
char buf[256];
if (gethostname (buf, sizeof (buf) - 1) == 0)
buf[255] = '\0';
;
return 0;
}
The output of this (if gethostname is not defined is):
tmp1.c: In function 'main':
tmp1.c:7:8: warning: implicit declaration of function 'gethostname'; did you
mean 'sethostname'? [-Wimplicit-function-declaration]
7 | if (gethostname (buf, sizeof (buf) - 1) == 0)
| ^~~~~~~~~~~
| sethostname
And, if you link it, it will error out with:
/tmp/ccYoUvKr.o: In function `main':
.../libgomp/tmp1.c:7: undefined reference to `gethostname'
collect2: error: ld returned 1 exit status
I think AC_COMPILE_IFELSE should be AC_LINK_IFELSE.
However, I'm not sure. Can someone please comment?