[arch-commits] Commit in rkt/trunk (PKGBUILD ilog2.patch)

Massimiliano Torromeo mtorromeo at archlinux.org
Wed Jun 21 11:01:41 UTC 2017


    Date: Wednesday, June 21, 2017 @ 11:01:40
  Author: mtorromeo
Revision: 239233

upgpkg: rkt 1.27.0-1

Added:
  rkt/trunk/ilog2.patch
Modified:
  rkt/trunk/PKGBUILD

-------------+
 PKGBUILD    |   29 ++++++++-----
 ilog2.patch |  126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 145 insertions(+), 10 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2017-06-21 10:46:21 UTC (rev 239232)
+++ PKGBUILD	2017-06-21 11:01:40 UTC (rev 239233)
@@ -7,7 +7,7 @@
 # Contributor: Carl George <arch at cgtx dot us> PGP-Key: 4BA2F7E101D9F512
 
 pkgname=rkt
-pkgver=1.26.0
+pkgver=1.27.0
 pkgrel=1
 pkgdesc="App container runtime"
 arch=('x86_64')
@@ -32,17 +32,18 @@
         coreos_production_pxe_image-$CCN_IMG_RELEASE.cpio.gz.sig::http://alpha.release.core-os.net/amd64-usr/$CCN_IMG_RELEASE/coreos_production_pxe_image.cpio.gz.sig
         https://www.kernel.org/pub/linux/kernel/v4.x/linux-$KERNEL_VERSION.tar.xz
         kvmtool-$KVMTOOL_VERSION.tar.gz::https://kernel.googlesource.com/pub/scm/linux/kernel/git/will/kvmtool/+archive/$KVMTOOL_VERSION.tar.gz
-        rkt.sysusers)
+        rkt.sysusers
+        ilog2.patch)
 noextract=(coreos_production_pxe_image.cpio.gz
-           linux-$KERNEL_VERSION.tar.xz
            kvmtool-$KVMTOOL_VERSION.tar.gz)
 validpgpkeys=('04127D0BFABEC8871FFB2CCE50E0885593D2DCB4' '48F9B96A2E16137F')
-sha256sums=('35dbecd8ff76bf538465fd783a7690519f32185330d9f4610f762ab19d956b3c'
+sha256sums=('213427c551ddc912622e967b30437e13485b88dcf7021c977a3205a1b03801a1'
             '988e4ad8e044dd8bff54cb5e0a34a1ed25cf7bc8cc241f1a90e3fe7f1412f315'
             'SKIP'
             '8dda9aedd17ae0bf1e06ebb4b79082f83fb3ade45cbcc3ca4c30bf3faf085738'
-            '8de67147aad19c8752b8d49502764f81431ac38816dec1bb055081215443c9ca'
-            '2aee4e8547843f4e6c032761b97cb723c1ecd384d508b86f44d16826bc34d6d6')
+            'b531d7247319ed4fba1f3d8b8fc4025762611d14ef5412a61d2ed8f32f58f5cb'
+            '2aee4e8547843f4e6c032761b97cb723c1ecd384d508b86f44d16826bc34d6d6'
+            '4b836472870b94f74294752af259751ce87bc0c53a3d40f93a70da3bf6512bdf')
 
 prepare() {
   cd "$srcdir"/$pkgname-$pkgver
@@ -53,14 +54,22 @@
   bsdtar -xf "$srcdir"/kvmtool-$KVMTOOL_VERSION.tar.gz \
          -C build-rkt-$pkgver/tmp/usr_from_kvm/lkvm/src
 
+  # fix makedev definition
+  sed '/^#include <sys\/stat.h>$/a #include <sys/sysmacros.h>' -i \
+      build-rkt-$pkgver/tmp/usr_from_kvm/lkvm/src/virtio/9p.c
+
+  # do not extract kernel sources
+  sed '/^\$(call forward-vars,\$(KERNEL_MAKEFILE)/,/tar --extract/d' -i \
+      stage1/usr_from_kvm/kernel.mk
+
   # place prefetched kernel sources
   ln -s "$srcdir"/linux-$KERNEL_VERSION.tar.xz \
         build-rkt-$pkgver/tmp/usr_from_kvm/kernel/
+  ln -s "$srcdir"/linux-$KERNEL_VERSION \
+        build-rkt-$pkgver/tmp/usr_from_kvm/kernel/
 
-  # fix makedev definition
-  sed '/^#include <sys\/stat.h>$/a #include <sys/sysmacros.h>' -i \
-      stage1/prepare-app/prepare-app.c \
-      build-rkt-$pkgver/tmp/usr_from_kvm/lkvm/src/virtio/9p.c
+  cd build-rkt-$pkgver/tmp/usr_from_kvm/kernel/linux-$KERNEL_VERSION
+  patch -p1 -i "$srcdir"/ilog2.patch
 }
 
 build() {

Added: ilog2.patch
===================================================================
--- ilog2.patch	                        (rev 0)
+++ ilog2.patch	2017-06-21 11:01:40 UTC (rev 239233)
@@ -0,0 +1,126 @@
+From 474c90156c8dcc2fa815e6716cc9394d7930cb9c Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds at linux-foundation.org>
+Date: Thu, 2 Mar 2017 12:17:22 -0800
+Subject: give up on gcc ilog2() constant optimizations
+
+gcc-7 has an "optimization" pass that completely screws up, and
+generates the code expansion for the (impossible) case of calling
+ilog2() with a zero constant, even when the code gcc compiles does not
+actually have a zero constant.
+
+And we try to generate a compile-time error for anybody doing ilog2() on
+a constant where that doesn't make sense (be it zero or negative).  So
+now gcc7 will fail the build due to our sanity checking, because it
+created that constant-zero case that didn't actually exist in the source
+code.
+
+There's a whole long discussion on the kernel mailing about how to work
+around this gcc bug.  The gcc people themselevs have discussed their
+"feature" in
+
+   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785
+
+but it's all water under the bridge, because while it looked at one
+point like it would be solved by the time gcc7 was released, that was
+not to be.
+
+So now we have to deal with this compiler braindamage.
+
+And the only simple approach seems to be to just delete the code that
+tries to warn about bad uses of ilog2().
+
+So now "ilog2()" will just return 0 not just for the value 1, but for
+any non-positive value too.
+
+It's not like I can recall anybody having ever actually tried to use
+this function on any invalid value, but maybe the sanity check just
+meant that such code never made it out in public.
+
+Reported-by: Laura Abbott <labbott at redhat.com>
+Cc: John Stultz <john.stultz at linaro.org>,
+Cc: Thomas Gleixner <tglx at linutronix.de>
+Cc: Ard Biesheuvel <ard.biesheuvel at linaro.org>
+Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
+---
+ include/linux/log2.h       | 13 ++-----------
+ tools/include/linux/log2.h | 13 ++-----------
+ 2 files changed, 4 insertions(+), 22 deletions(-)
+
+diff --git a/include/linux/log2.h b/include/linux/log2.h
+index ef3d4f6..c373295 100644
+--- a/include/linux/log2.h
++++ b/include/linux/log2.h
+@@ -16,12 +16,6 @@
+ #include <linux/bitops.h>
+ 
+ /*
+- * deal with unrepresentable constant logarithms
+- */
+-extern __attribute__((const, noreturn))
+-int ____ilog2_NaN(void);
+-
+-/*
+  * non-constant log of base 2 calculators
+  * - the arch may override these in asm/bitops.h if they can be implemented
+  *   more efficiently than using fls() and fls64()
+@@ -85,7 +79,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
+ #define ilog2(n)				\
+ (						\
+ 	__builtin_constant_p(n) ? (		\
+-		(n) < 1 ? ____ilog2_NaN() :	\
++		(n) < 2 ? 0 :			\
+ 		(n) & (1ULL << 63) ? 63 :	\
+ 		(n) & (1ULL << 62) ? 62 :	\
+ 		(n) & (1ULL << 61) ? 61 :	\
+@@ -148,10 +142,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
+ 		(n) & (1ULL <<  4) ?  4 :	\
+ 		(n) & (1ULL <<  3) ?  3 :	\
+ 		(n) & (1ULL <<  2) ?  2 :	\
+-		(n) & (1ULL <<  1) ?  1 :	\
+-		(n) & (1ULL <<  0) ?  0 :	\
+-		____ilog2_NaN()			\
+-				   ) :		\
++		1 ) :				\
+ 	(sizeof(n) <= 4) ?			\
+ 	__ilog2_u32(n) :			\
+ 	__ilog2_u64(n)				\
+diff --git a/tools/include/linux/log2.h b/tools/include/linux/log2.h
+index 4144666..d5677d3 100644
+--- a/tools/include/linux/log2.h
++++ b/tools/include/linux/log2.h
+@@ -13,12 +13,6 @@
+ #define _TOOLS_LINUX_LOG2_H
+ 
+ /*
+- * deal with unrepresentable constant logarithms
+- */
+-extern __attribute__((const, noreturn))
+-int ____ilog2_NaN(void);
+-
+-/*
+  * non-constant log of base 2 calculators
+  * - the arch may override these in asm/bitops.h if they can be implemented
+  *   more efficiently than using fls() and fls64()
+@@ -78,7 +72,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
+ #define ilog2(n)				\
+ (						\
+ 	__builtin_constant_p(n) ? (		\
+-		(n) < 1 ? ____ilog2_NaN() :	\
++		(n) < 2 ? 0 :			\
+ 		(n) & (1ULL << 63) ? 63 :	\
+ 		(n) & (1ULL << 62) ? 62 :	\
+ 		(n) & (1ULL << 61) ? 61 :	\
+@@ -141,10 +135,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
+ 		(n) & (1ULL <<  4) ?  4 :	\
+ 		(n) & (1ULL <<  3) ?  3 :	\
+ 		(n) & (1ULL <<  2) ?  2 :	\
+-		(n) & (1ULL <<  1) ?  1 :	\
+-		(n) & (1ULL <<  0) ?  0 :	\
+-		____ilog2_NaN()			\
+-				   ) :		\
++		1 ) :				\
+ 	(sizeof(n) <= 4) ?			\
+ 	__ilog2_u32(n) :			\
+ 	__ilog2_u64(n)				\
+-- 
+cgit v1.1



More information about the arch-commits mailing list