Concerning issue #2, it is how the macro checks for the declaration which I 
think isn't correct.  The macro definition tries to get a compile failure to 
indicate successful detection.  For example with sched_setaffinity, the 
_HWLOC_CHECK_DECL() macro creates a small conftest.c file which contains a 
dummy declaration for sched_setaffinity (void * sched_setaffinity;  The entire 
test is below for reference).  If we were on Linux, this gives an error:

conftest.c(104): error: declaration is incompatible with "int 
sched_setaffinity(__pid_t={int}, size_t={unsigned long}, const cpu_set_t *)" 
(declared at line 117 of "/usr/include/sched.h")
    void * sched_setaffinity;

But this implies that the test *passes* because the logic in 
_HWLOC_CHECK_DECL():

AC_DEFUN([_HWLOC_CHECK_DECL], [
  AC_MSG_CHECKING([whether function $1 is declared])
  AC_REQUIRE([AC_PROG_CC])
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
       [AC_INCLUDES_DEFAULT([$4])
   void * $1;],
    )],
    [AC_MSG_RESULT([no])  <---- This runs when the test successfully compiles
     $3],
    [AC_MSG_RESULT([yes]) <---- This runs when the test fails to compile
     $2]
  )
])

The issue is now when Visual Studio tries to compile, it also fails.  This 
result is expected, but also implies that the declaration exists!  Below is the 
exact output from trying with Visual Studio.  It says the result is "yes" 
despite sched_setaffinity not existing on native Windows machines.

configure:23499: /cygdrive/o/users/jlpeyton/hwloc/config/compile cl -c -nologo 
-O2  conftest.c >&5
conftest.c
conftest.c(96) : fatal error C1083: Cannot open include file: 'sched.h': No 
such file or directory
configure:23499: $? = 2
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "hwloc"
| ...
| /* end confdefs.h.  */
|
| #ifndef _GNU_SOURCE
| # define _GNU_SOURCE
| #endif
| #include <sched.h>
|
|
|   void * sched_setaffinity;
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:23504: result: yes <---- **** Oops ****
configure:23512: WARNING: Support for sched_setaffinity() requires a C compiler 
which
configure:23514: WARNING: considers incorrect argument counts to be a fatal 
error.
configure:23516: error: Cannot continue.

Fundamentally, I think _HWLOC_CHECK_DECL()'s macro logic is broken.  But maybe 
there is something I'm missing since it seems to have been necessary for 
something else.

-- Johnny

From: hwloc-devel [mailto:hwloc-devel-boun...@open-mpi.org] On Behalf Of Brice 
Goglin
Sent: Monday, April 4, 2016 4:16 PM
To: hwloc-de...@open-mpi.org
Subject: Re: [hwloc-devel] Three patches for MSVC/ICL builds on Windows.

Le 04/04/2016 21:39, Peyton, Jonathan L a écrit :

Hello everyone,

I've been working on a build using both MSVC and the Intel Windows compiler 
(ICL).  These three patches allow building of hwloc + utils.

1) add-ifndef-guard-around-gnu-source.patch - this minor change only adds 
#ifndef _GNU_SOURCE inside the hwloc.m4 tests because it seems to be defined on 
Linux systems beforehand causing a warning in these autoconf tests.

Hello

I am pushing this one thanks.


2) use-ac-check-decl.patch - this change removes the _HWLOC_CHECK_DECL() macro 
with the autoconf AC_CHECK_DECLS() macro.  The problem I was having concerned 
how _HWLOC_CHECK_DECL() worked.  It has an expected failure structure where if 
say, sched_setaffinity, is already defined, then the AC_COMPILE_IFELSE() macro 
will fail and say it *is* declared (the AC_MSG_RESULT([yes]) is in the 
"if-false" part of the check).  This is problematic when using MSVC because it 
will say that sched_setaffinity is declared when it really isn't.  The comment 
for _HWLOC_CHECK_DECL is also outdated so I think this can be safely removed.

I am not very confident about this one because this is really something that 
was needed in the past. Unfortunately the very old commit 
075eff1d1dd64292ff421a95f06d0151f1c246b5 doesn't give any detail. Looking the 
hwloc-devel archives in early 2009/11, it's likely related to some PGCC issues.

What problem did you actually see?




3) windows-compatibility-changes.patch - this change adds necessary autoconf 
checks that I needed to get MSVC/ICL to compile hwloc.  For instance, ssize_t 
wasn't declared and is defined from SSIZE_T instead, S_ISREG isn't defined in 
the windows headers so it is defined correctly when it doesn't exist, etc.  
This also introduced hwloc_strcasecmp() which is modeled after 
hwloc_strncasecmp().  If strcasecmp() isn't defined, then hwloc_strcasecmp() is 
used instead.  These MSVC/ICL auxiliary defines are put in 
include/private/misc.h and this header was added to some source files that 
needed it.


There are some easy pieces that I will commit soon.
There are some harder ones like changing the strtoull() stuff, I need to spend 
some time making sure it doesn't break anything.
By the way, hwloc-ps uses dirent for readding /proc, I think we should just 
always disable that program on Windows.

Brice

Reply via email to