[waffle] waffle vs msvc: Round 1, Fight !!!

Chad Versace chad.versace at intel.com
Tue Jul 1 16:22:11 PDT 2014


On Mon, Jun 30, 2014 at 01:05:27AM +0100, Emil Velikov wrote:
> Hello all,
> 
> Another day another long email :)
> 
> As usual, a list of issues, possible solutions, and my personal
> preference for each. At the end I have tried to assign a priority for
> most.
> 
> Any input would be greatly appreciated.
> 
> Highlights:
> 
> General (nitbits):
>  * C "Hello world" does not work OOTB with VC12 :)
>  ** Have to switch the platform toolset to v120_xp, as the default
> v120 complains about missing headers, libraries... (SDKDDKVer.h...),
> 
>  * Compiling ninja - fails due to the missing toolset.
>  ** Planning to use VC for now.
> 
> Jose are you having similar experience with VC12 ? Pardon but I'm
> using VC12 for the first time, and the documentation out there is
> rather... :\
> 
> 
> Build system related:
>  * Tests fail to build due to the missing toolset (+ others?)
>  Possible fix(es)
>  ** if (windows && !mingw) hardcode generator and toolset across whole
> of waffle endif ()
> 
>  * cmake does not find some headers and libs - GL/gl.h windows.h opengl32.lib
>  Possible fix(es)
>  ** Hardcode the libname, and ignore the headers' location as they
> should just work (tm)

On you GSOC2014 branch, I see that you're searching the headers with:

  if(waffle_on_windows)
      find_path(opengl_INCLUDE_DIR GL/gl.h REQUIRED)
      ...
  endif()

What happens if you instead do this?

  if(waffle_on_windows)
      find_path(OpenGL REQUIRED)
      ...
  endif()

> POSIX only
>  * getopt (utils/wflinfo, examples/gl_basic) - reuse one of the
> following (license implications?)
>  Current implementations
>  ** http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/pkgtools/libnbcompat/files/getopt.c
> (BSD 3-clause)
>  ** http://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/misc/getopt.c
> (unknown + BSD 2-clause)
>  Leaning towards reusing the NetBSD's implementation.

I also prefer to reuse NetBSD's getopt. As long as VisualStudio can
compile it :/


>  * pthreads - reuse one of the following (license implications?)
>  Current implementations
>  ** http://locklessinc.com/downloads/winpthreads.h (BSD 3-clause)
>  ** https://www.sourceware.org/pthreads-win32/ (GNU Lesser GPL)
>  ** http://cgit.freedesktop.org/mesa/mesa/tree/include/c11/threads_win32.h
> (Boost Software License, Version 1.0)
>  ** http://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-libraries/winpthreads
> (unknown [2]) - allegedly uses undocumented Windows API's
>  Leaning towards reusing locklessinc's implementation.

For now, I also prefer to use a permissively licensed simulation of the pthreads
API. Ideally, using a pthreads wrapper means you could simply drop in the
winpthreads.h header and waffle's pthreads usage should just work.

If time were not a decision factor, I would also consider Mesa's
simulation of the standard C11 threads API. But that would require you
to make more changes to Waffle, and therefore take more time.

> Other
>  * Symbols must be identically annotated in both declaration and
> definition (i.e. we need to bring WAFFLEAPI back into the public
> header ?)
>  Possible fix(es)
>  ** Pre-parse the header and ship one without the keyword ?
>  ** Define an empty WAFFLEAPI when using MSVC and use "module
> definition file (.def)"
>  Leaning towards using a .def

I want to avoid mangling the header sources. Instead, let's use
the preprocessor to solve this problem.

I suggest examining /usr/include/KHR/khrplatform.h for possible
solutions.

>  * struct waffle_* {} wfl - not strictly supported by C99 ?
> http://stackoverflow.com/questions/755305/empty-structure-in-c
>  MSVC message "C requires that a struct or union has at least one member"
>  Possible fix(es)
>  ** Add a dummy param inside the struct. We do not rely on the struct
> having a zero size but use it as a pointer to the start of the parent
> struct ?
> 
> Chad, does the last point make sense or did I completely miss out the
> plot while reading through the internal API ?

Ugh. I regret doing that little bit of nastiness in the internal API.
I just submitted a patch to the list, you cc'd, to fix this.

> Priority (high to low)
>  * struct waffle_* {} wfl
>  * pthreads
>  * getopt
>  * WAFFLEAPI
>  * everything else
> 
> 
> Cheers,
> Emil


More information about the waffle mailing list