diff mbox

Documentation: ptp: Fix build failure on MIPS cross builds

Message ID 1413794538-28465-1-git-send-email-markos.chandras@imgtec.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Markos Chandras Oct. 20, 2014, 8:42 a.m. UTC
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(+)

Comments

Richard Cochran Oct. 21, 2014, 11:07 a.m. UTC | #1
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Markos Chandras Oct. 21, 2014, 12:11 p.m. UTC | #2
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.
Richard Cochran Oct. 21, 2014, 12:52 p.m. UTC | #3
(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

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Markos Chandras Oct. 21, 2014, 1:03 p.m. UTC | #4
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) $
Richard Cochran Oct. 21, 2014, 1:39 p.m. UTC | #5
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Oct. 21, 2014, 4:35 p.m. UTC | #6
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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Daney Oct. 21, 2014, 4:58 p.m. UTC | #7
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Richard Cochran Oct. 21, 2014, 6:27 p.m. UTC | #8
(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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Peter Foley Oct. 21, 2014, 10:04 p.m. UTC | #9
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Richard Cochran Oct. 22, 2014, 8:03 a.m. UTC | #10
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Peter Foley Oct. 22, 2014, 2:09 p.m. UTC | #11
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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)