summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbsiegert <bsiegert@pkgsrc.org>2019-08-10 12:32:34 +0000
committerbsiegert <bsiegert@pkgsrc.org>2019-08-10 12:32:34 +0000
commitc9ffc0748028b5ba881df521cc890a608b450255 (patch)
tree6c7e741b426b012d50d0e0d89244d05542523a47
parent36e2b487e6f48e8443a5ed97e68206d121808700 (diff)
downloadpkgsrc-c9ffc0748028b5ba881df521cc890a608b450255.tar.gz
Pullup ticket #6027 - requested by maya
devel/libusb1: clang build fix Revisions pulled up: - devel/libusb1/Makefile 1.19 - devel/libusb1/distinfo 1.11 - devel/libusb1/patches/patch-ub 1.1 --- Module Name: pkgsrc Committed By: maya Date: Tue Aug 6 08:50:28 UTC 2019 Modified Files: pkgsrc/devel/libusb1: Makefile distinfo Added Files: pkgsrc/devel/libusb1/patches: patch-ub Log Message: libusb1: patch some undefined behaviour, disable strict aliasing, change -O2 to -O1 when building with clang. This isn't in a separate hacks.mk file because I think that hides the problem too much, it's an issue with the code in the package, not with the compiler's choices. Fixes functionality when built with clang. >From Shingo Nishioka in PR pkg/54441.
-rw-r--r--devel/libusb1/Makefile10
-rw-r--r--devel/libusb1/distinfo3
-rw-r--r--devel/libusb1/patches/patch-ub36
3 files changed, 47 insertions, 2 deletions
diff --git a/devel/libusb1/Makefile b/devel/libusb1/Makefile
index 8adf3fa0586..a85e543201d 100644
--- a/devel/libusb1/Makefile
+++ b/devel/libusb1/Makefile
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.18 2019/06/22 11:30:11 nia Exp $
+# $NetBSD: Makefile,v 1.18.2.1 2019/08/10 12:32:34 bsiegert Exp $
DISTNAME= libusb-1.0.22
PKGNAME= ${DISTNAME:S/libusb/libusb1/}
+PKGREVISION= 1
CATEGORIES= devel
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=libusb/}
EXTRACT_SUFX= .tar.bz2
@@ -20,6 +21,13 @@ USE_LIBTOOL= yes
USE_TOOLS+= pkg-config
MAKE_JOBS_SAFE= no
+.include "../../mk/compiler.mk"
+.if !empty(PKGSRC_COMPILER:Mclang)
+# Uses undefined behaviour
+BUILDLINK_TRANSFORM+= opt:-O2:-O1
+CFLAGS+= -fno-strict-aliasing
+.endif
+
PKGCONFIG_OVERRIDE+= libusb-1.0.pc.in
# systemd dependency
diff --git a/devel/libusb1/distinfo b/devel/libusb1/distinfo
index f81998e2343..95440b27525 100644
--- a/devel/libusb1/distinfo
+++ b/devel/libusb1/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.10 2019/06/21 16:58:23 sjmulder Exp $
+$NetBSD: distinfo,v 1.10.2.1 2019/08/10 12:32:34 bsiegert Exp $
SHA1 (libusb-1.0.22.tar.bz2) = 10116aa265aac4273a0c894faa089370262ec0dc
RMD160 (libusb-1.0.22.tar.bz2) = 59b800abb0b4c088dbee950fa67bb31240b8a134
@@ -7,3 +7,4 @@ Size (libusb-1.0.22.tar.bz2) = 598833 bytes
SHA1 (patch-configure) = 2776ff354ea8f17663a9a5330f6fe990af27d8fe
SHA1 (patch-configure.ac) = 9344b3d6439348164410d1b2071cf14c3f388354
SHA1 (patch-libusb_os_sunos__usb.c) = 4896e497d451487a09b3be9ad74f72595a441086
+SHA1 (patch-ub) = 14bffca93ec8445cbfccb613dfda92f652b0ceb0
diff --git a/devel/libusb1/patches/patch-ub b/devel/libusb1/patches/patch-ub
new file mode 100644
index 00000000000..40a6fb0a127
--- /dev/null
+++ b/devel/libusb1/patches/patch-ub
@@ -0,0 +1,36 @@
+$NetBSD: patch-ub,v 1.1.2.2 2019/08/10 12:32:34 bsiegert Exp $
+
+Avoid undefined behaviour that breaks clang
+
+--- libusb/descriptor.c.orig 2019-08-02 09:59:25.784968424 +0900
++++ libusb/descriptor.c 2019-08-02 09:59:44.009134412 +0900
+@@ -54,7 +54,9 @@
+ for (cp = descriptor; *cp; cp++) {
+ switch (*cp) {
+ case 'b': /* 8-bit byte */
+- *dp++ = *sp++;
++ memcpy(dp, sp, 1);
++ dp += 1;
++ sp += 1;
+ break;
+ case 'w': /* 16-bit word, convert from little endian to CPU */
+ dp += ((uintptr_t)dp & 1); /* Align to word boundary */
+@@ -63,7 +65,7 @@
+ memcpy(dp, sp, 2);
+ } else {
+ w = (sp[1] << 8) | sp[0];
+- *((uint16_t *)dp) = w;
++ memcpy(dp, &w, 4);
+ }
+ sp += 2;
+ dp += 2;
+@@ -76,7 +78,7 @@
+ } else {
+ d = (sp[3] << 24) | (sp[2] << 16) |
+ (sp[1] << 8) | sp[0];
+- *((uint32_t *)dp) = d;
++ memcpy(dp, &d, 4);
+ }
+ sp += 4;
+ dp += 4;
+