pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/pkgsrc-2019Q2]: pkgsrc/devel/libusb1 Pullup ticket #6027 - requested ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/18cb808d1905
branches:  pkgsrc-2019Q2
changeset: 338430:18cb808d1905
user:      bsiegert <bsiegert%pkgsrc.org@localhost>
date:      Sat Aug 10 12:32:34 2019 +0000

description:
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.

diffstat:

 devel/libusb1/Makefile         |  10 +++++++++-
 devel/libusb1/distinfo         |   3 ++-
 devel/libusb1/patches/patch-ub |  36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 2 deletions(-)

diffs (81 lines):

diff -r e8649b469039 -r 18cb808d1905 devel/libusb1/Makefile
--- a/devel/libusb1/Makefile    Sat Aug 10 12:12:55 2019 +0000
+++ b/devel/libusb1/Makefile    Sat Aug 10 12:32:34 2019 +0000
@@ -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_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 -r e8649b469039 -r 18cb808d1905 devel/libusb1/distinfo
--- a/devel/libusb1/distinfo    Sat Aug 10 12:12:55 2019 +0000
+++ b/devel/libusb1/distinfo    Sat Aug 10 12:32:34 2019 +0000
@@ -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 @@
 SHA1 (patch-configure) = 2776ff354ea8f17663a9a5330f6fe990af27d8fe
 SHA1 (patch-configure.ac) = 9344b3d6439348164410d1b2071cf14c3f388354
 SHA1 (patch-libusb_os_sunos__usb.c) = 4896e497d451487a09b3be9ad74f72595a441086
+SHA1 (patch-ub) = 14bffca93ec8445cbfccb613dfda92f652b0ceb0
diff -r e8649b469039 -r 18cb808d1905 devel/libusb1/patches/patch-ub
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/libusb1/patches/patch-ub    Sat Aug 10 12:32:34 2019 +0000
@@ -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;
+



Home | Main Index | Thread Index | Old Index