On Thu, Oct 15, 2015 at 12:24:39PM +0100, David Vrabel wrote:
> On 15/10/15 12:18, Mikko Rapeli wrote:
> > On Thu, Oct 15, 2015 at 11:29:12AM +0100, David Vrabel wrote:
> >> On 15/10/15 06:56, Mikko Rapeli wrote:
> >>> xen/interface/xen.h is not exported from kernel headers so remove the
> >>> dependency and provide needed defines for domid_t and xen_pfn_t if they
> >>> are not already defined by some other e.g. Xen specific headers.
> >>>
> >>> Suggested by Andrew Cooper <andrew.coop...@citrix.com> on lkml message
> >>> <5569f9c9.8000...@citrix.com>.
> >>>
> >>> The ifdef for ARM is ugly but did not find better solutions for it.
> >>>
> >>> Fixes userspace compilation error:
> >>>
> >>> xen/privcmd.h:38:31: fatal error: xen/interface/xen.h: No such file or 
> >>> directory
> >> [...]
> >>> --- a/include/uapi/xen/privcmd.h
> >>> +++ b/include/uapi/xen/privcmd.h
> >>> @@ -35,7 +35,19 @@
> >>>  
> >>>  #include <linux/types.h>
> >>>  #include <linux/compiler.h>
> >>> -#include <xen/interface/xen.h>
> >>> +
> >>> +/* Might be defined by Xen specific headers, but if not */
> >>> +#ifndef domid_t
> >>> +typedef __u16 domid_t;
> >>> +#endif /* domid_t */
> >>
> >> As the kbuild bot points out, this does not work since the existence of
> >> a typedef cannot be checked with #ifdef.
> > 
> > Yeah, this hack doesn't cut it. Sorry. Tried to implement these changes:
> > http://www.spinics.net/lists/linux-api/msg11048.html
> > 
> >> I'm not really sure what problem you're trying to solve.  A user space
> >> program making use of this interface gets the domid_t and xen_pfn_t etc
> >> typedefs from the headers provided as part of the libxenctrl library.
> > 
> > I'm trying to make sure that kernel headers in userspace compile with 
> > minimal
> > dependencies which are gcc and libc.
> > 
> > For me it is clear by now that many Linux API's and ABI's like Xen parts do
> > not live in the uapi header files and instead there's a separate userspace
> > library with needed headers and defines which have embedded copies of
> > the needed API and ABI definitions, like header files.
> > 
> > So how could this file be changed so that it compiles in userspace without
> > definitions from libxenctrl?
> 
> I don't think anything needs to be changed.
> 
> Instead I would make your compilation check of this header dependent on
> the existence of the xen/interface/xen.h header. Or you may exclude the
> check of this header entirely.

There are not many headers in uapi which require additional userspace
headers to compile (I'm not saying that uapi headers represent the full
API's/ABI's, it's clear they don't). If there are ~700 headers and just a
single one needs an exception and additional dependencies, I would try to
make it work without the dependency. I just need some advice and guidance
from maintainers how to do this.

Or we should start tracking these userspace library dependencies too,
at least at linux-headers package levels in distributions. This might
be a good idea anyway, but then we might as well move headers like this
directly to the userspace library and out of include/uapi.

Both would solve the non-compiling uapi header problem.

> > I guess I could copy the needed definitions for domid_t and xen_pfn_t from
> > xen/interface/xen.h of libxenctrl. That I should have done to begin with
> > instead of trying to hack something on my own.
> 
> I do not want definitions duplicated/copied from the hypervisor ABI
> headers.  This causes problems when support for new architectures is
> added (for example).

Understood.

-Mikko

> David
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to