Discussion:
[PATCH] Documentation: ptp: Fix build failure on MIPS cross builds
(too old to reply)
Markos Chandras
2014-10-20 08:42:18 UTC
Permalink
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 <***@gmail.com>
Cc: Jonathan Corbet <***@lwn.net>
Cc: ***@vger.kernel.org
Cc: linux-***@vger.kernel.org
Cc: linux-***@vger.kernel.org
Signed-off-by: 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

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Richard Cochran
2014-10-21 11:07:25 UTC
Permalink
Post by Markos Chandras
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 linux-doc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Markos Chandras
2014-10-21 12:11:22 UTC
Permalink
Post by Richard Cochran
Post by Markos Chandras
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
Richard Cochran
2014-10-21 12:52:40 UTC
Permalink
(adding Peter Foley to CC ...)
Post by Markos Chandras
Post by Richard Cochran
Post by Markos Chandras
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.
Post by Markos Chandras
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 linux-doc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Markos Chandras
2014-10-21 13:03:45 UTC
Permalink
Post by Richard Cochran
(adding Peter Foley to CC ...)
Post by Markos Chandras
Post by Richard Cochran
Post by Markos Chandras
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
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Richard Cochran
2014-10-21 13:39:59 UTC
Permalink
Post by Markos Chandras
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 linux-doc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller
2014-10-21 16:35:44 UTC
Permalink
From: Richard Cochran <***@gmail.com>
Date: Tue, 21 Oct 2014 13:07:25 +0200
Post by Richard Cochran
Post by Markos Chandras
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.
David Daney
2014-10-21 16:58:51 UTC
Permalink
Post by David Miller
Date: Tue, 21 Oct 2014 13:07:25 +0200
Post by Richard Cochran
Post by Markos Chandras
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 linux-doc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Richard Cochran
2014-10-21 18:27:57 UTC
Permalink
(adding Makefile author Peter Foley onto CC)
Post by David Daney
Post by David Miller
Date: Tue, 21 Oct 2014 13:07:25 +0200
Post by Richard Cochran
Post by Markos Chandras
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 linux-doc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Peter Foley
2014-10-21 22:04:51 UTC
Permalink
On Tue, Oct 21, 2014 at 2:27 PM, Richard Cochran
Post by Richard Cochran
Post by David Daney
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 linux-doc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Richard Cochran
2014-10-22 08:03:02 UTC
Permalink
Post by Peter Foley
The intention of these changes was to generate more compiliation
coverage for code in Documentation/
Sounds good.
Post by Peter Foley
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.
Post by Peter Foley
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.
Post by Peter Foley
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
Peter Foley
2014-10-22 14:09:37 UTC
Permalink
On Wed, Oct 22, 2014 at 4:03 AM, Richard Cochran
Post by Richard Cochran
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.

Continue reading on narkive:
Loading...