imx-usb-loader: fix build with older gcc
PATCH 1/1 imx-usb-loader: fix build with older gcc
Since the last version bump imx-usb-loader uses __builtin_bswap16 which is not universally available in gcc older than version 4.8. Add a patch switching to a local 16-bit bytes swap implementation.
Should fix:
http://autobuild.buildroot.net/results/a63/a63b593b7ef3b6d32e755afe42b77d47dbf0276e/
http://autobuild.buildroot.net/results/48c/48c95cfc65f99fa02be81a11303ba8999f57091a/
http://autobuild.buildroot.net/results/c9d/c9d4f99b49ddb9b2ce08fce7672dd7c70cf62912/
--- ....h-fix-build-with-gcc-older-than-4.8.patch | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patch
package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patch new file +42 -0
@@ -0,0 +1,42 @@ +From c581e6037ec7ab2f9cd615f6ffa149b4d0a5638c Mon Sep 17 00:00:00 2001 +From: Baruch Siach <[email protected]> +Date: Tue, 19 Jun 2018 15:31:52 +0300 +Subject: [PATCH] portable.h: fix build with gcc older than 4.8 + +__builtin_bswap16 is available in all gcc architectures only since +version 4.8. Older gcc versions fail to build: + +imx_sdp.o: In function `perform_dcd': +.../imx_sdp.c:1138: undefined reference to `__builtin_bswap16' +imx_sdp.o: In function `write_dcd_table_ivt': +.../imx_sdp.c:457: undefined reference to `__builtin_bswap16' +imx_sdp.o: In function `write_dcd': +.../imx_sdp.c:410: undefined reference to `__builtin_bswap16' +imx_sdp.o: In function `init_header': +.../imx_sdp.c:1075: undefined reference to `__builtin_bswap16' + +Use a local implementation instead. + +Signed-off-by: Baruch Siach <[email protected]> +--- +Upstream status: https://github.com/boundarydevices/imx_usb_loader/pull/82 + + portable.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/portable.h b/portable.h +index 364fe47b212a..364832b5ea69 100644 +--- a/portable.h ++++ b/portable.h +@@ -58,7 +58,7 @@ extern int debugmode; + #ifdef __GNUC__ + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + #define BE32(x) __builtin_bswap32(x) +-#define BE16(x) __builtin_bswap16(x) ++#define BE16(x) (x<<8 | x>>8) + #else + #define BE32(x) x + #define BE16(x) x +-- +2.17.1 +
Signature · 1 line
2.17.1
PATCH 1/1 imx-usb-loader: fix build with older gcc
Quoted 52 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Baruch" == Baruch Siach <[email protected]> writes:
Since the last version bump imx-usb-loader uses
__builtin_bswap16which is not universally available in gcc older than version 4.8. Add a patch switching to a local 16-bit bytes swap implementation.Should fix:
http://autobuild.buildroot.net/results/a63/a63b593b7ef3b6d32e755afe42b77d47dbf0276e/
http://autobuild.buildroot.net/results/48c/48c95cfc65f99fa02be81a11303ba8999f57091a/
http://autobuild.buildroot.net/results/c9d/c9d4f99b49ddb9b2ce08fce7672dd7c70cf62912/Cc Adam Duskett <[email protected]>Signed-off-by Baruch Siach <[email protected]>--- ....h-fix-build-with-gcc-older-than-4.8.patch | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patchdiff --git
a/package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patchb/package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patchnew file mode 100644
index 000000000000..c0aabed542c6package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patch new file +26
-0@@ -0,0 +1,42 @@ +From c581e6037ec7ab2f9cd615f6ffa149b4d0a5638c Mon Sep 17 00:00:00 2001 +From: Baruch Siach <[email protected]> +Date: Tue, 19 Jun 2018 15:31:52 +0300 +Subject: [PATCH] portable.h: fix build with gcc older than 4.8 + +__builtin_bswap16 is available in all gcc architectures only since +version 4.8. Older gcc versions fail to build: + +imx_sdp.o: In function `perform_dcd': +.../imx_sdp.c:1138: undefined reference to `__builtin_bswap16' +imx_sdp.o: In function `write_dcd_table_ivt': +.../imx_sdp.c:457: undefined reference to `__builtin_bswap16' +imx_sdp.o: In function `write_dcd': +.../imx_sdp.c:410: undefined reference to `__builtin_bswap16' +imx_sdp.o: In function `init_header': +.../imx_sdp.c:1075: undefined reference to `__builtin_bswap16' + +Use a local implementation instead. + +Signed-off-by: Baruch Siach <[email protected]> +--- +Upstream status: https://github.com/boundarydevices/imx_usb_loader/pull/82 + + portable.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) +
package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patch line 36
Quoted 10 lines
package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patch new file +10
-0+diff --git a/portable.h b/portable.h +index 364fe47b212a..364832b5ea69 100644 +--- a/portable.h ++++ b/portable.h +@@ -58,7 +58,7 @@ extern int debugmode; + #ifdef __GNUC__ + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + #define BE32(x) __builtin_bswap32(x) +-#define BE16(x) __builtin_bswap16(x) ++#define BE16(x) (x<<8 | x>>8)
I take it this is never called on anything where the double evaluation causes any side effects?
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 imx-usb-loader: fix build with older gcc
Quoted 57 lines · Peter Korsgaard
Quoted 57 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Baruch" == Baruch Siach <[email protected]> writes:
Since the last version bump imx-usb-loader uses
__builtin_bswap16which is not universally available in gcc older than version 4.8. Add a patch switching to a local 16-bit bytes swap implementation.Should fix:
http://autobuild.buildroot.net/results/a63/a63b593b7ef3b6d32e755afe42b77d47dbf0276e/
http://autobuild.buildroot.net/results/48c/48c95cfc65f99fa02be81a11303ba8999f57091a/
http://autobuild.buildroot.net/results/c9d/c9d4f99b49ddb9b2ce08fce7672dd7c70cf62912/Cc Adam Duskett <[email protected]>Signed-off-by Baruch Siach <[email protected]>--- ....h-fix-build-with-gcc-older-than-4.8.patch | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patchdiff --git
a/package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patchb/package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patchnew file mode 100644
index 000000000000..c0aabed542c6package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patch new file +31
-0@@ -0,0 +1,42 @@ +From c581e6037ec7ab2f9cd615f6ffa149b4d0a5638c Mon Sep 17 00:00:00 2001 +From: Baruch Siach <[email protected]> +Date: Tue, 19 Jun 2018 15:31:52 +0300 +Subject: [PATCH] portable.h: fix build with gcc older than 4.8 + +__builtin_bswap16 is available in all gcc architectures only since +version 4.8. Older gcc versions fail to build: + +imx_sdp.o: In function `perform_dcd': +.../imx_sdp.c:1138: undefined reference to `__builtin_bswap16' +imx_sdp.o: In function `write_dcd_table_ivt': +.../imx_sdp.c:457: undefined reference to `__builtin_bswap16' +imx_sdp.o: In function `write_dcd': +.../imx_sdp.c:410: undefined reference to `__builtin_bswap16' +imx_sdp.o: In function `init_header': +.../imx_sdp.c:1075: undefined reference to `__builtin_bswap16' + +Use a local implementation instead. + +Signed-off-by: Baruch Siach <[email protected]> +--- +Upstream status: https://github.com/boundarydevices/imx_usb_loader/pull/82 + + portable.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/portable.h b/portable.h +index 364fe47b212a..364832b5ea69 100644 +--- a/portable.h ++++ b/portable.h +@@ -58,7 +58,7 @@ extern int debugmode;
Quoted 8 lines
package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patch line 36
Quoted 5 lines
package/imx-usb-loader/0001-portable.h-fix-build-with-gcc-older-than-4.8.patch new file +5
-0+ #ifdef __GNUC__ + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + #define BE32(x) __builtin_bswap32(x) +-#define BE16(x) __builtin_bswap16(x) ++#define BE16(x) (x<<8 | x>>8)I take it this is never called on anything where the double evaluation causes any side effects?
Even so, x without parenthesis around it is extremely dangerous...
Since this is inside __GNUC__, we could just use an expression statement like
in the kernel:
#define BE16(x) \
({ \
typeof(x) __x = (x); \
(__x<<8 | __x>>8); \
}) Regards,
Arnout
Quoted 3 lines
Committed, thanks.
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 imx-usb-loader: fix build with older gcc
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Arnout" == Arnout Vandecappelle <[email protected]> writes:
Hi,
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
++#define BE16(x) (x<<8 | x>>8)
I take it this is never called on anything where the double evaluation causes any side effects?
Even so, x without parenthesis around it is extremely dangerous...
Quoted 8 lines
Since this is inside
__GNUC__, we could just use an expression statement like
in the kernel:#define BE16(x) \
({ \ typeof(x) __x = (x); \ (__x<<8 | __x>>8); \ })
Correct. Baruch, will you send an update (here and upstream)?
Signature · 1 line
Bye, Peter Korsgaard