[Bug libgomp/91694] configure.ac does not correctly check for gethostname

2019-09-09 Thread ri...@extreme-scale.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91694

--- Comment #6 from Rishi Khan  ---
(In reply to Jakub Jelinek from comment #5)
> > It seems like libgomp's configure.ac is already using AC_LINK_IFELSE for all
> > OS's around line 241 to 'Check for pthread_{,attr_}[sg]etaffinity_np.'.
> 
> True, but that is something most of the targets don't have, it is glibc
> specific mostly, so doesn't matter if it fails.
> 
> > In my newlib startup setup, I only build libgomp in stage2.
> > See here for Makefile:
> > https://github.com/riscv/riscv-gnu-toolchain/blob/master/Makefile.in
> > On line 541 I have --enable-threads and on line 551 I have --enable-libgomp
> 
> Your OS isn't among those where libgomp is supported.  

This may be the case. It worked fine in gcc-7.3 but when we upgraded it failed
due to these configure errors.

> Do you say you have POSIX threads but not gethostname?

Yes. There is no real reason we don't have gethostname beyond the fact that we
didn't implement it yet.

Why is it the case that libgomp checks to see if it has gethostname by
compiling a program that has gethostname but not linking it? Regardless of if
the OS supports or is does not support gethostname, just compiling it will
succeed. [same for uname and getpid]

Here are some more examples where it tries to link to check if a function
exists:
# Check for functions needed. (line 219 of configure.ac, 
AC_CHECK_FUNCS(getloadavg clock_gettime strtoull)
AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)

in configure, AC_CHECK_FUNCS resolves to calls to ac_fn_c_check_func (line
15811), which calls ac_fn_c_try_link (line 1867)

[Bug libgomp/91694] configure.ac does not correctly check for gethostname

2019-09-09 Thread ri...@extreme-scale.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91694

--- Comment #4 from Rishi Khan  ---
(In reply to Jakub Jelinek from comment #3)
> Can you start by saying what OS this is on?  The lib*/configure* in gcc tree
> can't use linking in all cases due to newlib startup setups, but it is true
> that in libgomp's configure AC_LINK_IFELSE is used already for most targets
> (but not all).

This is on my custom OS that doesn't have gethostname ('hcos', which is in the
config.sub upstream). I am actually using newlib. 

It seems like libgomp's configure.ac is already using AC_LINK_IFELSE for all
OS's around line 241 to 'Check for pthread_{,attr_}[sg]etaffinity_np.'.

In my newlib startup setup, I only build libgomp in stage2.
See here for Makefile:
https://github.com/riscv/riscv-gnu-toolchain/blob/master/Makefile.in
On line 541 I have --enable-threads and on line 551 I have --enable-libgomp

[Bug libgomp/91694] configure.ac does not correctly check for gethostname

2019-09-09 Thread ri...@extreme-scale.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91694

--- Comment #2 from Rishi Khan  ---
Created attachment 46857
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46857&action=edit
patch for libgomp

Attached is a patch that works for me.

[Bug libgomp/91694] configure.ac does not correctly check for gethostname

2019-09-07 Thread ri...@extreme-scale.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91694

Rishi Khan  changed:

   What|Removed |Added

 CC||ri...@extreme-scale.com

--- Comment #1 from Rishi Khan  ---
To clarify further, configure.ac instructs to see if the program can compile
and produce a *.o file. This works, with a warning but not error returned.
However, a system that does not have gethostname will not link properly. That
is why I think it should be AC_LINK_IFELSE instead of AC_COMPILE_IFELSE. There
are a few other AC_COMPILE_IFELSE that should also be looked at. I think they
may suffer the same problem.

[Bug libgomp/91694] New: configure.ac does not correctly check for gethostname

2019-09-06 Thread ri...@extreme-scale.com
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: ri...@extreme-scale.com
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 
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?