netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
@ 2014-10-20  8:42 Markos Chandras
  2014-10-21 11:07 ` Richard Cochran
  0 siblings, 1 reply; 12+ messages in thread
From: Markos Chandras @ 2014-10-20  8:42 UTC (permalink / raw)
  To: linux-mips
  Cc: Markos Chandras, Richard Cochran, Jonathan Corbet, netdev,
	linux-doc, linux-kernel

The MIPS system calls are defined based on the -mabi gcc option.
However, the testptp is built on the host using the unistd header
from the kernel sources which were built for the MIPS architecture
thus guarded with the __MIPS_SIM_{ABI64, ABI32, NABI32} definitions
leading to the following build problem:

Documentation/ptp/testptp.c: In function 'clock_adjtime':
Documentation/ptp/testptp.c:55: error: '__NR_clock_adjtime'
undeclared (first use in this function)
Documentation/ptp/testptp.c:55: error: (Each undeclared identifier is reported
only once Documentation/ptp/testptp.c:55: error: for each function it appears in.)

This fix is similar to e9107f88c985bcda ("samples/seccomp/Makefile: do not build
tests if cross-compiling for MIPS")

Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: netdev@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
---
 Documentation/ptp/Makefile | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/ptp/Makefile b/Documentation/ptp/Makefile
index 293d6c09a11f..397c1cd2eda7 100644
--- a/Documentation/ptp/Makefile
+++ b/Documentation/ptp/Makefile
@@ -1,5 +1,15 @@
 # List of programs to build
+ifndef CROSS_COMPILE
 hostprogs-y := testptp
+else
+# MIPS system calls are defined based on the -mabi that is passed
+# to the toolchain which may or may not be a valid option
+# for the host toolchain. So disable testptp if target architecture
+# is MIPS but the host isn't.
+ifndef CONFIG_MIPS
+hostprogs-y := testptp
+endif
+endif
 
 # Tell kbuild to always build the programs
 always := $(hostprogs-y)
-- 
2.1.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
  2014-10-20  8:42 [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds Markos Chandras
@ 2014-10-21 11:07 ` Richard Cochran
  2014-10-21 12:11   ` Markos Chandras
  2014-10-21 16:35   ` David Miller
  0 siblings, 2 replies; 12+ messages in thread
From: Richard Cochran @ 2014-10-21 11:07 UTC (permalink / raw)
  To: Markos Chandras
  Cc: linux-mips, Jonathan Corbet, netdev, linux-doc, linux-kernel

On Mon, Oct 20, 2014 at 09:42:18AM +0100, Markos Chandras wrote:
> diff --git a/Documentation/ptp/Makefile b/Documentation/ptp/Makefile
> index 293d6c09a11f..397c1cd2eda7 100644
> --- a/Documentation/ptp/Makefile
> +++ b/Documentation/ptp/Makefile
> @@ -1,5 +1,15 @@
>  # List of programs to build
> +ifndef CROSS_COMPILE
>  hostprogs-y := testptp
> +else
> +# MIPS system calls are defined based on the -mabi that is passed
> +# to the toolchain which may or may not be a valid option
> +# for the host toolchain. So disable testptp if target architecture
> +# is MIPS but the host isn't.
> +ifndef CONFIG_MIPS
> +hostprogs-y := testptp
> +endif
> +endif

It seems like a shame to simply give up and not compile this at all.
Is there no way to correctly cross compile this for MIPS?

Thanks,
Richard

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
  2014-10-21 11:07 ` Richard Cochran
@ 2014-10-21 12:11   ` Markos Chandras
  2014-10-21 12:52     ` Richard Cochran
  2014-10-21 16:35   ` David Miller
  1 sibling, 1 reply; 12+ messages in thread
From: Markos Chandras @ 2014-10-21 12:11 UTC (permalink / raw)
  To: Richard Cochran
  Cc: linux-mips, Jonathan Corbet, netdev, linux-doc, linux-kernel

On 10/21/2014 12:07 PM, Richard Cochran wrote:
> On Mon, Oct 20, 2014 at 09:42:18AM +0100, Markos Chandras wrote:
>> diff --git a/Documentation/ptp/Makefile b/Documentation/ptp/Makefile
>> index 293d6c09a11f..397c1cd2eda7 100644
>> --- a/Documentation/ptp/Makefile
>> +++ b/Documentation/ptp/Makefile
>> @@ -1,5 +1,15 @@
>>  # List of programs to build
>> +ifndef CROSS_COMPILE
>>  hostprogs-y := testptp
>> +else
>> +# MIPS system calls are defined based on the -mabi that is passed
>> +# to the toolchain which may or may not be a valid option
>> +# for the host toolchain. So disable testptp if target architecture
>> +# is MIPS but the host isn't.
>> +ifndef CONFIG_MIPS
>> +hostprogs-y := testptp
>> +endif
>> +endif
> 
> It seems like a shame to simply give up and not compile this at all.
> Is there no way to correctly cross compile this for MIPS?
> 
> Thanks,
> Richard
> 

As far as I can see you don't cross-compile the file. You use the host
toolchain. There is no clean way to build it for host if you have your
kernel configured for MIPS. Perhaps maybe you could define
__MIPS_SIM_{ABI64, ABI32, NABI32} in the gcc command line (-D...) but
this is a bit ugly. Or maybe use the host headers instead of the ones in
the kernel source.

-- 
markos

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
  2014-10-21 12:11   ` Markos Chandras
@ 2014-10-21 12:52     ` Richard Cochran
  2014-10-21 13:03       ` Markos Chandras
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Cochran @ 2014-10-21 12:52 UTC (permalink / raw)
  To: Markos Chandras
  Cc: linux-mips, Jonathan Corbet, netdev, linux-doc, linux-kernel,
	Peter Foley

(adding Peter Foley to CC ...)

On Tue, Oct 21, 2014 at 01:11:22PM +0100, Markos Chandras wrote:
> On 10/21/2014 12:07 PM, Richard Cochran wrote:
> > On Mon, Oct 20, 2014 at 09:42:18AM +0100, Markos Chandras wrote:
> >> diff --git a/Documentation/ptp/Makefile b/Documentation/ptp/Makefile
> >> index 293d6c09a11f..397c1cd2eda7 100644
> >> --- a/Documentation/ptp/Makefile
> >> +++ b/Documentation/ptp/Makefile
> >> @@ -1,5 +1,15 @@
> >>  # List of programs to build
> >> +ifndef CROSS_COMPILE
> >>  hostprogs-y := testptp
> >> +else
> >> +# MIPS system calls are defined based on the -mabi that is passed
> >> +# to the toolchain which may or may not be a valid option
> >> +# for the host toolchain. So disable testptp if target architecture
> >> +# is MIPS but the host isn't.
> >> +ifndef CONFIG_MIPS
> >> +hostprogs-y := testptp
> >> +endif
> >> +endif
> > 
> > It seems like a shame to simply give up and not compile this at all.
> > Is there no way to correctly cross compile this for MIPS?
> > 
> > Thanks,
> > Richard
> > 
> 
> As far as I can see you don't cross-compile the file. You use the host
> toolchain.

Look at Documentation/ptp/testptp.mk. There I do use $CROSS_COMPILE.

> There is no clean way to build it for host if you have your
> kernel configured for MIPS. Perhaps maybe you could define
> __MIPS_SIM_{ABI64, ABI32, NABI32} in the gcc command line (-D...) but
> this is a bit ugly. Or maybe use the host headers instead of the ones in
> the kernel source.

Your patch is for the file, Documentation/ptp/Makefile. I did not
write that file. Maybe Peter knows how to fix it?

Thanks,
Richard


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
  2014-10-21 12:52     ` Richard Cochran
@ 2014-10-21 13:03       ` Markos Chandras
  2014-10-21 13:39         ` Richard Cochran
  0 siblings, 1 reply; 12+ messages in thread
From: Markos Chandras @ 2014-10-21 13:03 UTC (permalink / raw)
  To: Richard Cochran
  Cc: linux-mips, Jonathan Corbet, netdev, linux-doc, linux-kernel,
	Peter Foley

On 10/21/2014 01:52 PM, Richard Cochran wrote:
> (adding Peter Foley to CC ...)
> 
> On Tue, Oct 21, 2014 at 01:11:22PM +0100, Markos Chandras wrote:
>> On 10/21/2014 12:07 PM, Richard Cochran wrote:
>>> On Mon, Oct 20, 2014 at 09:42:18AM +0100, Markos Chandras wrote:
>>>> diff --git a/Documentation/ptp/Makefile b/Documentation/ptp/Makefile
>>>> index 293d6c09a11f..397c1cd2eda7 100644
>>>> --- a/Documentation/ptp/Makefile
>>>> +++ b/Documentation/ptp/Makefile
>>>> @@ -1,5 +1,15 @@
>>>>  # List of programs to build
>>>> +ifndef CROSS_COMPILE
>>>>  hostprogs-y := testptp
>>>> +else
>>>> +# MIPS system calls are defined based on the -mabi that is passed
>>>> +# to the toolchain which may or may not be a valid option
>>>> +# for the host toolchain. So disable testptp if target architecture
>>>> +# is MIPS but the host isn't.
>>>> +ifndef CONFIG_MIPS
>>>> +hostprogs-y := testptp
>>>> +endif
>>>> +endif
>>>
>>> It seems like a shame to simply give up and not compile this at all.
>>> Is there no way to correctly cross compile this for MIPS?
>>>
>>> Thanks,
>>> Richard
>>>
>>
>> As far as I can see you don't cross-compile the file. You use the host
>> toolchain.
> 
> Look at Documentation/ptp/testptp.mk. There I do use $CROSS_COMPILE.

Hmm I can't see this testptp.mk file in the mainline. What tree are you
referring to?

markos linux (master) $ grep -r CROSS_COMPILE Documentation/ptp/*
markos linux (master) $

-- 
markos

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
  2014-10-21 13:03       ` Markos Chandras
@ 2014-10-21 13:39         ` Richard Cochran
  0 siblings, 0 replies; 12+ messages in thread
From: Richard Cochran @ 2014-10-21 13:39 UTC (permalink / raw)
  To: Markos Chandras
  Cc: linux-mips, Jonathan Corbet, netdev, linux-doc, linux-kernel,
	Peter Foley

On Tue, Oct 21, 2014 at 02:03:45PM +0100, Markos Chandras wrote:
> 
> Hmm I can't see this testptp.mk file in the mainline. What tree are you
> referring to?

Sorry, I have net-next open in front of me. The same guy who added
the buggy Makefile deleted my working makefile...

Thanks,
Richard

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
  2014-10-21 11:07 ` Richard Cochran
  2014-10-21 12:11   ` Markos Chandras
@ 2014-10-21 16:35   ` David Miller
  2014-10-21 16:58     ` David Daney
  1 sibling, 1 reply; 12+ messages in thread
From: David Miller @ 2014-10-21 16:35 UTC (permalink / raw)
  To: richardcochran
  Cc: markos.chandras, linux-mips, corbet, netdev, linux-doc, linux-kernel

From: Richard Cochran <richardcochran@gmail.com>
Date: Tue, 21 Oct 2014 13:07:25 +0200

> On Mon, Oct 20, 2014 at 09:42:18AM +0100, Markos Chandras wrote:
>> diff --git a/Documentation/ptp/Makefile b/Documentation/ptp/Makefile
>> index 293d6c09a11f..397c1cd2eda7 100644
>> --- a/Documentation/ptp/Makefile
>> +++ b/Documentation/ptp/Makefile
>> @@ -1,5 +1,15 @@
>>  # List of programs to build
>> +ifndef CROSS_COMPILE
>>  hostprogs-y := testptp
>> +else
>> +# MIPS system calls are defined based on the -mabi that is passed
>> +# to the toolchain which may or may not be a valid option
>> +# for the host toolchain. So disable testptp if target architecture
>> +# is MIPS but the host isn't.
>> +ifndef CONFIG_MIPS
>> +hostprogs-y := testptp
>> +endif
>> +endif
> 
> It seems like a shame to simply give up and not compile this at all.
> Is there no way to correctly cross compile this for MIPS?

Yeah seriously, we should try to make this work instead of throwing our
hands in the air.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
  2014-10-21 16:35   ` David Miller
@ 2014-10-21 16:58     ` David Daney
  2014-10-21 18:27       ` Richard Cochran
  0 siblings, 1 reply; 12+ messages in thread
From: David Daney @ 2014-10-21 16:58 UTC (permalink / raw)
  To: David Miller
  Cc: richardcochran, markos.chandras, linux-mips, corbet, netdev,
	linux-doc, linux-kernel

On 10/21/2014 09:35 AM, David Miller wrote:
> From: Richard Cochran <richardcochran@gmail.com>
> Date: Tue, 21 Oct 2014 13:07:25 +0200
>
>> On Mon, Oct 20, 2014 at 09:42:18AM +0100, Markos Chandras wrote:
>>> diff --git a/Documentation/ptp/Makefile b/Documentation/ptp/Makefile
>>> index 293d6c09a11f..397c1cd2eda7 100644
>>> --- a/Documentation/ptp/Makefile
>>> +++ b/Documentation/ptp/Makefile
>>> @@ -1,5 +1,15 @@
>>>   # List of programs to build
>>> +ifndef CROSS_COMPILE
>>>   hostprogs-y := testptp
>>> +else
>>> +# MIPS system calls are defined based on the -mabi that is passed
>>> +# to the toolchain which may or may not be a valid option
>>> +# for the host toolchain. So disable testptp if target architecture
>>> +# is MIPS but the host isn't.
>>> +ifndef CONFIG_MIPS
>>> +hostprogs-y := testptp
>>> +endif
>>> +endif
>>
>> It seems like a shame to simply give up and not compile this at all.
>> Is there no way to correctly cross compile this for MIPS?
>
> Yeah seriously, we should try to make this work instead of throwing our
> hands in the air.
>

We cross compile things successfully all the time for all the various 
MIPS ABIs.

It is a simple matter of having the Makefile setup for cross compiling.

What I don't understand is why we are using hostprogs in this Makefile. 
  Isn't this a program that would run on the target, not the build host?

David Daney

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
  2014-10-21 16:58     ` David Daney
@ 2014-10-21 18:27       ` Richard Cochran
  2014-10-21 22:04         ` Peter Foley
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Cochran @ 2014-10-21 18:27 UTC (permalink / raw)
  To: David Daney
  Cc: David Miller, markos.chandras, linux-mips, corbet, netdev,
	linux-doc, linux-kernel, Peter Foley

(adding Makefile author Peter Foley onto CC)

On Tue, Oct 21, 2014 at 09:58:51AM -0700, David Daney wrote:
> On 10/21/2014 09:35 AM, David Miller wrote:
> >From: Richard Cochran <richardcochran@gmail.com>
> >Date: Tue, 21 Oct 2014 13:07:25 +0200
> >
> >>On Mon, Oct 20, 2014 at 09:42:18AM +0100, Markos Chandras wrote:
> >>>diff --git a/Documentation/ptp/Makefile b/Documentation/ptp/Makefile
> >>>index 293d6c09a11f..397c1cd2eda7 100644
> >>>--- a/Documentation/ptp/Makefile
> >>>+++ b/Documentation/ptp/Makefile
> >>>@@ -1,5 +1,15 @@
> >>>  # List of programs to build
> >>>+ifndef CROSS_COMPILE
> >>>  hostprogs-y := testptp
> >>>+else
> >>>+# MIPS system calls are defined based on the -mabi that is passed
> >>>+# to the toolchain which may or may not be a valid option
> >>>+# for the host toolchain. So disable testptp if target architecture
> >>>+# is MIPS but the host isn't.
> >>>+ifndef CONFIG_MIPS
> >>>+hostprogs-y := testptp
> >>>+endif
> >>>+endif
> >>
> >>It seems like a shame to simply give up and not compile this at all.
> >>Is there no way to correctly cross compile this for MIPS?
> >
> >Yeah seriously, we should try to make this work instead of throwing our
> >hands in the air.
> >
> 
> We cross compile things successfully all the time for all the
> various MIPS ABIs.
> 
> It is a simple matter of having the Makefile setup for cross compiling.
> 
> What I don't understand is why we are using hostprogs in this
> Makefile.  Isn't this a program that would run on the target, not
> the build host?

Yes.

Peter, could you please fix it?

Thanks,
Richard

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
  2014-10-21 18:27       ` Richard Cochran
@ 2014-10-21 22:04         ` Peter Foley
  2014-10-22  8:03           ` Richard Cochran
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Foley @ 2014-10-21 22:04 UTC (permalink / raw)
  To: Richard Cochran
  Cc: David Daney, David Miller, markos.chandras, linux-mips, corbet,
	netdev, linux-doc, LKML

On Tue, Oct 21, 2014 at 2:27 PM, Richard Cochran
<richardcochran@gmail.com> wrote:
> On Tue, Oct 21, 2014 at 09:58:51AM -0700, David Daney wrote:
>> What I don't understand is why we are using hostprogs in this
>> Makefile.  Isn't this a program that would run on the target, not
>> the build host?
>
> Yes.
>
> Peter, could you please fix it?


The intention of these changes was to generate more compiliation
coverage for code in Documentation/
The underlying issue is that this doesn't work for cross-compiling
because kbuild doesn't have cross-compile support for userspace code.
I submitted a patch to disable building Documentation when
cross-compiling, as the consensus in the thread that resulted in that
patch (https://lkml.org/lkml/2014/10/8/510) was that implementing
targetprogs in kbuild was not currently worth it.
I can try to take a crack at adding targetprogs support, but I'm
rather busy right now, so it may take a little while.

Thanks,

Peter

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
  2014-10-21 22:04         ` Peter Foley
@ 2014-10-22  8:03           ` Richard Cochran
  2014-10-22 14:09             ` Peter Foley
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Cochran @ 2014-10-22  8:03 UTC (permalink / raw)
  To: Peter Foley
  Cc: David Daney, David Miller, markos.chandras, linux-mips, corbet,
	netdev, linux-doc, LKML

On Tue, Oct 21, 2014 at 06:04:51PM -0400, Peter Foley wrote:
> The intention of these changes was to generate more compiliation
> coverage for code in Documentation/

Sounds good.

> The underlying issue is that this doesn't work for cross-compiling
> because kbuild doesn't have cross-compile support for userspace code.

Well, my testptp does cross compile just fine. All it needs is the glibc
library bundled with the tool chain and the kernel headers.

> I submitted a patch to disable building Documentation when
> cross-compiling, as the consensus in the thread that resulted in that
> patch (https://lkml.org/lkml/2014/10/8/510) was that implementing
> targetprogs in kbuild was not currently worth it.

So this patch did not make it in, right?

Otherwise people wouldn't be disabling cross compilation ad hoc, like
in the patch that started this thread.

> I can try to take a crack at adding targetprogs support, but I'm
> rather busy right now, so it may take a little while.

No rush, please do.

In the mean time, I would like to restore the testptp.mk that *does*
cross compile, so that people may use the test program if they
want. In fact I use this all the time, and so I am a bit annoyed that
something working was deleted and replaced with something broken.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
  2014-10-22  8:03           ` Richard Cochran
@ 2014-10-22 14:09             ` Peter Foley
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Foley @ 2014-10-22 14:09 UTC (permalink / raw)
  To: Richard Cochran
  Cc: David Daney, David Miller, markos.chandras, linux-mips, corbet,
	netdev, linux-doc, LKML

On Wed, Oct 22, 2014 at 4:03 AM, Richard Cochran
<richardcochran@gmail.com> wrote:
> In the mean time, I would like to restore the testptp.mk that *does*
> cross compile, so that people may use the test program if they
> want. In fact I use this all the time, and so I am a bit annoyed that
> something working was deleted and replaced with something broken.

Sure, I didn't realize that anyone was actually using testptp.mk on a
regular basis.
Feel free to restore it.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-10-22 14:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-20  8:42 [PATCH] Documentation: ptp: Fix build failure on MIPS cross builds Markos Chandras
2014-10-21 11:07 ` Richard Cochran
2014-10-21 12:11   ` Markos Chandras
2014-10-21 12:52     ` Richard Cochran
2014-10-21 13:03       ` Markos Chandras
2014-10-21 13:39         ` Richard Cochran
2014-10-21 16:35   ` David Miller
2014-10-21 16:58     ` David Daney
2014-10-21 18:27       ` Richard Cochran
2014-10-21 22:04         ` Peter Foley
2014-10-22  8:03           ` Richard Cochran
2014-10-22 14:09             ` Peter Foley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).