Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1196077 > unrolled thread

Re: samples/kdbus/kdbus-workers.c and cross compiling MIPS

Started byDavid Herrmann <dh.herrmann@gmail.com>
First post2015-07-30 16:30 +0200
Last post2015-08-03 07:00 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: samples/kdbus/kdbus-workers.c and cross compiling MIPS David Herrmann <dh.herrmann@gmail.com> - 2015-07-30 16:30 +0200
    Re: samples/kdbus/kdbus-workers.c and cross compiling MIPS Paul Gortmaker <paul.gortmaker@windriver.com> - 2015-07-30 17:40 +0200
    Re: samples/kdbus/kdbus-workers.c and cross compiling MIPS Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-07-31 18:30 +0200
      Re: samples/kdbus/kdbus-workers.c and cross compiling MIPS Michael Ellerman <mpe@ellerman.id.au> - 2015-08-03 07:00 +0200

#1196077 — Re: samples/kdbus/kdbus-workers.c and cross compiling MIPS

FromDavid Herrmann <dh.herrmann@gmail.com>
Date2015-07-30 16:30 +0200
SubjectRe: samples/kdbus/kdbus-workers.c and cross compiling MIPS
Message-ID<pRX0m-XW-21@gated-at.bofh.it>
Hi

On Thu, Jul 30, 2015 at 3:50 PM, Paul Gortmaker
<paul.gortmaker@windriver.com> wrote:
> On 2015-07-29 12:31 PM, David Herrmann wrote:
>> Hi
>>
>> On Wed, Jul 29, 2015 at 6:19 PM, Paul Gortmaker
>> <paul.gortmaker@windriver.com> wrote:
>>> Hi David,
>>>
>>> Does it make sense to build this sample when cross compiling?
>>>
>>> The reason I ask is that it has been breaking the linux-next build of
>>> allmodconfig for a while now, with:
>>>
>>>   HOSTCC  samples/kdbus/kdbus-workers
>>> samples/kdbus/kdbus-workers.c: In function ‘prime_new’:
>>> samples/kdbus/kdbus-workers.c:934:18: error: ‘__NR_memfd_create’ undeclared (first use in this function)
>>>   p->fd = syscall(__NR_memfd_create, "prime-area", MFD_CLOEXEC);
>>>                   ^
>>> samples/kdbus/kdbus-workers.c:934:18: note: each undeclared identifier is reported only once for each function it appears in
>>> scripts/Makefile.host:91: recipe for target 'samples/kdbus/kdbus-workers' failed
>>> make[2]: *** [samples/kdbus/kdbus-workers] Error 1
>>
>> mips does have this syscall, so I assume the problem is out-of-date
>> kernel headers. You can fix this by running:
>>
>>     $ make headers_install
>
> No, let me try and clarify. Please note the emphasis on cross compiling
> and automated build coverage, i.e. there is no place for manual steps.

User-space samples in ./samples/ are compiled with HOSTCC, which is
the compiler for the _local_ machine. Regardless of cross-compiling
the same local compiler is used. So I cannot understand why this is
even remotely related to cross compiling. Please elaborate.
Please note that this is HOSTCC running, so it does *NOT* require the
toolchain for your cross-compiled architecture.

Also, please tell me why your system has "linux/memfd.h" available,
but __NR_memfd_create is undefined?

Anyway, patch is attached. Can you verify it works?
David

diff --git a/samples/kdbus/Makefile b/samples/kdbus/Makefile
index 137f842..dbd9de8 100644
--- a/samples/kdbus/Makefile
+++ b/samples/kdbus/Makefile
@@ -1,9 +1,13 @@
 # kbuild trick to avoid linker error. Can be omitted if a module is built.
 obj- := dummy.o

+ifndef CROSS_COMPILE
+
 hostprogs-$(CONFIG_SAMPLE_KDBUS) += kdbus-workers

 always := $(hostprogs-y)

 HOSTCFLAGS_kdbus-workers.o += -I$(objtree)/usr/include
 HOSTLOADLIBES_kdbus-workers := -lrt
+
+endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1196140

FromPaul Gortmaker <paul.gortmaker@windriver.com>
Date2015-07-30 17:40 +0200
Message-ID<pRY66-2v3-23@gated-at.bofh.it>
In reply to#1196077
On 2015-07-30 10:23 AM, David Herrmann wrote:
> Hi
> 
> On Thu, Jul 30, 2015 at 3:50 PM, Paul Gortmaker
> <paul.gortmaker@windriver.com> wrote:
>> On 2015-07-29 12:31 PM, David Herrmann wrote:
>>> Hi
>>>
>>> On Wed, Jul 29, 2015 at 6:19 PM, Paul Gortmaker
>>> <paul.gortmaker@windriver.com> wrote:
>>>> Hi David,
>>>>
>>>> Does it make sense to build this sample when cross compiling?
>>>>
>>>> The reason I ask is that it has been breaking the linux-next build of
>>>> allmodconfig for a while now, with:
>>>>
>>>>   HOSTCC  samples/kdbus/kdbus-workers
>>>> samples/kdbus/kdbus-workers.c: In function ‘prime_new’:
>>>> samples/kdbus/kdbus-workers.c:934:18: error: ‘__NR_memfd_create’ undeclared (first use in this function)
>>>>   p->fd = syscall(__NR_memfd_create, "prime-area", MFD_CLOEXEC);
>>>>                   ^
>>>> samples/kdbus/kdbus-workers.c:934:18: note: each undeclared identifier is reported only once for each function it appears in
>>>> scripts/Makefile.host:91: recipe for target 'samples/kdbus/kdbus-workers' failed
>>>> make[2]: *** [samples/kdbus/kdbus-workers] Error 1
>>>
>>> mips does have this syscall, so I assume the problem is out-of-date
>>> kernel headers. You can fix this by running:
>>>
>>>     $ make headers_install
>>
>> No, let me try and clarify. Please note the emphasis on cross compiling
>> and automated build coverage, i.e. there is no place for manual steps.
> 
> User-space samples in ./samples/ are compiled with HOSTCC, which is
> the compiler for the _local_ machine. Regardless of cross-compiling
> the same local compiler is used. So I cannot understand why this is
> even remotely related to cross compiling. Please elaborate.

Well, it only shows up when we cross compile for mips.  It does not
seem to be showing up for any other arch (and we cover ~10 of them).
Nor does it show up for x86 builds.  Also note that the main linux-next
build machine is actually a PowerPC host.

> Please note that this is HOSTCC running, so it does *NOT* require the
> toolchain for your cross-compiled architecture.
> 
> Also, please tell me why your system has "linux/memfd.h" available,
> but __NR_memfd_create is undefined?

My local system is a bog standard ubuntu 14.10 and it sees it.  I dont
know what distro the linux-next IBM powerpc builder is based on but it
also sees it....

Here is what V=1 output looks like:

(cat /dev/null; ) > samples/kdbus/modules.order
  gcc -Wp,-MD,samples/kdbus/.kdbus-workers.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89    -I./usr/include -o samples/kdbus/kdbus-workers samples/kdbus/kdbus-workers.c  -lrt
samples/kdbus/kdbus-workers.c: In function ‘prime_new’:
samples/kdbus/kdbus-workers.c:934:18: error: ‘__NR_memfd_create’ undeclared (first use in this function)
  p->fd = syscall(__NR_memfd_create, "prime-area", MFD_CLOEXEC);
                  ^
samples/kdbus/kdbus-workers.c:934:18: note: each undeclared identifier is reported only once for each function it appears in
scripts/Makefile.host:91: recipe for target 'samples/kdbus/kdbus-workers' failed
make[2]: *** [samples/kdbus/kdbus-workers] Error 1
scripts/Makefile.build:403: recipe for target 'samples/kdbus' failed
make[1]: *** [samples/kdbus] Error 2
Makefile:1569: recipe for target 'samples/' failed
make: *** [samples/] Error 2

and here is what is in ./usr/include:

paul@yow-lpgnfs-02:~/git/linux-head$ grep -R __NR_memfd_create ./usr/include/
./usr/include/asm-generic/unistd.h:#define __NR_memfd_create 279
./usr/include/asm-generic/unistd.h:__SYSCALL(__NR_memfd_create, sys_memfd_create)
./usr/include/asm/unistd.h:#define __NR_memfd_create            (__NR_Linux + 354)
./usr/include/asm/unistd.h:#define __NR_memfd_create            (__NR_Linux + 314)
./usr/include/asm/unistd.h:#define __NR_memfd_create            (__NR_Linux + 318)
paul@yow-lpgnfs-02:~/git/linux-head$ 

..so it is in there, but presumably something wrt mips ifdeffery
means it is thrown out by cpp.

> 
> Anyway, patch is attached. Can you verify it works?

Yes, after I fixed up the mangling from it being sent as
quoted-printable, it fixes the issue; or at least avoids it.

Tested-by: Paul Gortmaker <paul.gortmaker@windriver.com>

Thanks,
Paul.
--

> David
> 
> diff --git a/samples/kdbus/Makefile b/samples/kdbus/Makefile
> index 137f842..dbd9de8 100644
> --- a/samples/kdbus/Makefile
> +++ b/samples/kdbus/Makefile
> @@ -1,9 +1,13 @@
>  # kbuild trick to avoid linker error. Can be omitted if a module is built.
>  obj- := dummy.o
> 
> +ifndef CROSS_COMPILE
> +
>  hostprogs-$(CONFIG_SAMPLE_KDBUS) += kdbus-workers
> 
>  always := $(hostprogs-y)
> 
>  HOSTCFLAGS_kdbus-workers.o += -I$(objtree)/usr/include
>  HOSTLOADLIBES_kdbus-workers := -lrt
> +
> +endif
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1197165

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2015-07-31 18:30 +0200
Message-ID<pSlm1-2GV-1@gated-at.bofh.it>
In reply to#1196077
On Fri, Jul 31, 2015 at 05:01:01PM +1000, Michael Ellerman wrote:
> It's obviously possible that some samples build with that configuration, but
> building against another arch'es kernel headers just seems like it's asking for
> trouble. Even if we can build the samples, they will never run correctly.
> 
> So I suggest we should just disable SAMPLES if we're cross compiling, full stop.

Yes, that seems like a much better solution overall.  Can you send a
patch for this?

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1198539

FromMichael Ellerman <mpe@ellerman.id.au>
Date2015-08-03 07:00 +0200
Message-ID<pTg0W-PQ-3@gated-at.bofh.it>
In reply to#1197165
On Fri, 2015-07-31 at 09:29 -0700, Greg Kroah-Hartman wrote:
> On Fri, Jul 31, 2015 at 05:01:01PM +1000, Michael Ellerman wrote:
> > It's obviously possible that some samples build with that configuration, but
> > building against another arch'es kernel headers just seems like it's asking for
> > trouble. Even if we can build the samples, they will never run correctly.
> > 
> > So I suggest we should just disable SAMPLES if we're cross compiling, full stop.
> 
> Yes, that seems like a much better solution overall.  Can you send a
> patch for this?

Yep, will do.

cheers


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web