From: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
According to : http://autobuild.buildroot.net/results/3de/3de936d9be79e151e66af15193084d82a...
linux/ioctl.h header must be included in linux_spi.c to obtain missing _IOC_SIZEBITS.
Patch based on : http://git.buildroot.net/buildroot/commit/package/c-periphery/0001-Add-missi...
Signed-off-by: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com --- linux_spi.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/linux_spi.c b/linux_spi.c index 26725e1..8d72420 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -28,6 +28,7 @@ #include <unistd.h> #include <linux/types.h> #include <linux/spi/spidev.h> +#include <linux/ioctl.h> #include <sys/ioctl.h> #include "flash.h" #include "chipdrivers.h"
From: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
When musl is used to provides libc flashrom built fail with : [...] rayer_spi.c:(.text+0x95): undefined reference to `outb' [...] satamv.c:(.text+0x5e): undefined reference to `outl' satamv.c:(.text+0x7b): undefined reference to `outb' collect2: error: ld returned 1 exit status
This patch changed test on __GLIBC__ by __linux__ to obtain a more generic verification.
Patch based on : http://git.buildroot.net/buildroot/commit/package/exfat-utils/0001-fix-compi...
Signed-off-by: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com --- hwaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hwaccess.h b/hwaccess.h index 3e46192..cf27577 100644 --- a/hwaccess.h +++ b/hwaccess.h @@ -27,7 +27,7 @@ #include "platform.h"
#if IS_X86 -#if defined(__GLIBC__) +#if defined(__linux__) #include <sys/io.h> #endif #endif
On Wed, 14 Oct 2015 10:43:07 +0200 Gwenhael Goavec-Merou gwenj@trabucayre.com wrote:
From: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
According to : http://autobuild.buildroot.net/results/3de/3de936d9be79e151e66af15193084d82a...
linux/ioctl.h header must be included in linux_spi.c to obtain missing _IOC_SIZEBITS.
Patch based on : http://git.buildroot.net/buildroot/commit/package/c-periphery/0001-Add-missi...
Signed-off-by: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
Hi Gwenhael,
I don't see how this is related to flashrom. It seems to be a patch against c-periphery. Did you notice any compile problems of flashrom itself?
Hi Stefan On Mon, 26 Oct 2015 23:59:38 +0100 Stefan Tauner stefan.tauner@alumni.tuwien.ac.at wrote:
On Wed, 14 Oct 2015 10:43:07 +0200 Gwenhael Goavec-Merou gwenj@trabucayre.com wrote:
From: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
The compile problem is shown in this build report :
http://autobuild.buildroot.net/results/3de/3de936d9be79e151e66af15193084d82a...
This problem is clearly related to flashrom.
linux/ioctl.h header must be included in linux_spi.c to obtain missing _IOC_SIZEBITS.
This patch is not my patch but one that I was inspired to do mine :
Patch based on : http://git.buildroot.net/buildroot/commit/package/c-periphery/0001-Add-missi...
Signed-off-by: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
Hi Gwenhael,
I don't see how this is related to flashrom. It seems to be a patch against c-periphery. Did you notice any compile problems of flashrom itself? -- Kind regards/Mit freundlichen Grüßen, Stefan Tauner
My patch to fix compile issue is on the missing part of this mail (on the bottom of http://patchwork.coreboot.org/patch/4327/).
regards, Gwenhael
On Tue, 27 Oct 2015 08:12:24 +0100 "gwenhael.goavec" gwenj@trabucayre.com wrote:
Hi Stefan On Mon, 26 Oct 2015 23:59:38 +0100 Stefan Tauner stefan.tauner@alumni.tuwien.ac.at wrote:
On Wed, 14 Oct 2015 10:43:07 +0200 Gwenhael Goavec-Merou gwenj@trabucayre.com wrote:
From: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
The compile problem is shown in this build report :
http://autobuild.buildroot.net/results/3de/3de936d9be79e151e66af15193084d82a...
This problem is clearly related to flashrom.
Well, yes true... however, I am not sure if that's actually a problem with the includes in flashrom or the actual headers they are using. After all we do not use the undefined macro directly, so it should be brought in by the header file that uses it IMHO.
flashrom does not support non-glibc C libraries yet anyway (this also affects your other patch) so this needs more investigation in any case. I am currently building a musl "crosscompiler" toolchain on our flashrom buildbot to allow for that (because the musl-gcc wrapper does not work with libraries like libpci). Don't expect any results soon but I'll put it on my todo list... thanks for the heads-up.
On Wed, 14 Oct 2015 10:43:07 +0200 Gwenhael Goavec-Merou gwenj@trabucayre.com wrote:
From: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
According to : http://autobuild.buildroot.net/results/3de/3de936d9be79e151e66af15193084d82a...
linux/ioctl.h header must be included in linux_spi.c to obtain missing _IOC_SIZEBITS.
Patch based on : http://git.buildroot.net/buildroot/commit/package/c-periphery/0001-Add-missi...
This is actually a bug in the linux headers that apparently is hidden by the glibc headers because they include the right headers "by accident":
glibc headers corresponding to Linux 3.2.0: # 23 "sys/ioctl.h" 2 # 24 "/usr/include/x86_64-linux-gnu/bits/ioctls.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/asm/ioctls.h" 1 3 4 # 1 "/usr/include/asm-generic/ioctls.h" 1 3 4 # 1 "/usr/include/linux/ioctl.h" 1 3 4 # 1 "/usr/include/x86_64-linux-gnu/asm/ioctl.h" 1 3 4 # 1 "/usr/include/asm-generic/ioctl.h" 1 3 4
_IOC_SIZEBITS
(found out with the help of gcc -E -dD and some grep foo)
With musl's 1.0.5 (stable) headers sys/ioctl.h does not include any OS-specific headers (I think) and thus no _IOC_SIZEBITS. That makes it fail to compile flashrom's linux_spi.c as indicated in the log.
Why is that a bug in the kernel headers? Because linux/spi/spidev.h defines a macro named SPI_MSGSIZE (that flashrom uses) that relies on another macro (_IOC_SIZEBITS)from asm-generic/ioctl.h that should be (indirectly) brought in by spidev.h.
Does it matter? No, we have to support it anyway hence I will include the proposed change (if no regression crops up). Still, I would like this to be reported "upstream". Could you please do that Gwenhael?
From: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
This is mostly achieved by fixing or refining the inclusion of header files and replacing glibc-specific ifdefs with more generic ones.
- <sys/io.h>: Linux-specific and not only available in glibc. Include it if we are running Linux and not only if glibc is active. - <sys/fcntl.h>: should be (and is) replaced by <fcntl.h> (without the "sys" prefix). - <linux/spi/spidev.h>: Does not include all necessary headers, namely _IOC_SIZEBITS that is used in the definition of SPI_MSGSIZE is not brought in via <linux/ioctl.h> but instead we relied so far on glibc's including it via <sys/ioctl.h>. Change that to explicitly including <linux/ioctl.h>. - <endian.h>: Would also be available in musl but there is no easy way to detect it so we do not try yet.
The bug report and initial patches were Signed-off-by: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
Signed-off-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at ---
No regressions detected on the buildbot... flashrom can be built completely (with libpci, libusb and libftdi programmers) with musl after applying this.
hwaccess.h | 3 ++- linux_spi.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/hwaccess.h b/hwaccess.h index 3e46192..25b1456 100644 --- a/hwaccess.h +++ b/hwaccess.h @@ -27,7 +27,7 @@ #include "platform.h"
#if IS_X86 -#if defined(__GLIBC__) +#if defined(__linux__) #include <sys/io.h> #endif #endif @@ -115,6 +115,7 @@ #if !defined (__FLASHROM_BIG_ENDIAN__) && !defined (__FLASHROM_LITTLE_ENDIAN__)
/* Nonstandard libc-specific macros for determining endianness. */ +/* musl provides an endian.h as well... but it can not be detected from within C. */ #if defined(__GLIBC__) #include <endian.h> #if BYTE_ORDER == LITTLE_ENDIAN diff --git a/linux_spi.c b/linux_spi.c index 26725e1..19b4965 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -22,13 +22,14 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> -#include <sys/fcntl.h> +#include <fcntl.h> #include <errno.h> #include <ctype.h> #include <unistd.h> +#include <sys/ioctl.h> #include <linux/types.h> #include <linux/spi/spidev.h> -#include <sys/ioctl.h> +#include <linux/ioctl.h> #include "flash.h" #include "chipdrivers.h" #include "programmer.h"