wok-next view ninja/stuff/patches/ninja-1.8.2-add_NINJAJOBS_var-1.patch @ rev 20607
perdition: up 2.2
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Thu Apr 19 15:57:59 2018 +0300 (2018-04-19) |
parents | |
children |
line source
1 Submitted By: Bruce Dubbs <bdubbs at linuxfromscratch dot org>
2 Date: 2017-10-14
3 Initial Package Version: 1.9.2
4 Upstream Status: Not submitted
5 Origin: Self
6 Description: Ninja normally uses all cores+2 when building
7 a package. This patch allows useers to limit the
8 cores used by setting an environment variable:
9 NINJAJOBS to an integer.
11 The patch also fixes a few warnings.
14 diff -Naur ninja-1.8.2.orig/src/build_log.cc ninja-1.8.2/src/build_log.cc
15 --- ninja-1.8.2.orig/src/build_log.cc 2017-09-10 20:20:10.000000000 -0500
16 +++ ninja-1.8.2/src/build_log.cc 2017-10-12 14:38:00.988957823 -0500
17 @@ -75,12 +75,12 @@
18 }
19 switch (len & 7)
20 {
21 - case 7: h ^= uint64_t(data[6]) << 48;
22 - case 6: h ^= uint64_t(data[5]) << 40;
23 - case 5: h ^= uint64_t(data[4]) << 32;
24 - case 4: h ^= uint64_t(data[3]) << 24;
25 - case 3: h ^= uint64_t(data[2]) << 16;
26 - case 2: h ^= uint64_t(data[1]) << 8;
27 + case 7: h ^= uint64_t(data[6]) << 48; __attribute__ ((fallthrough));
28 + case 6: h ^= uint64_t(data[5]) << 40; __attribute__ ((fallthrough));
29 + case 5: h ^= uint64_t(data[4]) << 32; __attribute__ ((fallthrough));
30 + case 4: h ^= uint64_t(data[3]) << 24; __attribute__ ((fallthrough));
31 + case 3: h ^= uint64_t(data[2]) << 16; __attribute__ ((fallthrough));
32 + case 2: h ^= uint64_t(data[1]) << 8; __attribute__ ((fallthrough));
33 case 1: h ^= uint64_t(data[0]);
34 h *= m;
35 };
36 diff -Naur ninja-1.8.2.orig/src/hash_map.h ninja-1.8.2/src/hash_map.h
37 --- ninja-1.8.2.orig/src/hash_map.h 2017-09-10 20:20:10.000000000 -0500
38 +++ ninja-1.8.2/src/hash_map.h 2017-10-12 14:30:29.563974429 -0500
39 @@ -39,8 +39,8 @@
40 len -= 4;
41 }
42 switch (len) {
43 - case 3: h ^= data[2] << 16;
44 - case 2: h ^= data[1] << 8;
45 + case 3: h ^= data[2] << 16; __attribute__ ((fallthrough));
46 + case 2: h ^= data[1] << 8; __attribute__ ((fallthrough));
47 case 1: h ^= data[0];
48 h *= m;
49 };
50 diff -Naur ninja-1.8.2.orig/src/ninja.cc ninja-1.8.2/src/ninja.cc
51 --- ninja-1.8.2.orig/src/ninja.cc 2017-09-10 20:20:10.000000000 -0500
52 +++ ninja-1.8.2/src/ninja.cc 2017-10-12 14:47:34.143936739 -0500
53 @@ -221,6 +221,12 @@
55 /// Choose a default value for the -j (parallelism) flag.
56 int GuessParallelism() {
57 +
58 + int j = 0;
59 + char* jobs = getenv( "NINJAJOBS" );
60 + if ( jobs != NULL ) j = atoi( jobs );
61 + if ( j > 0 ) return j;
62 +
63 switch (int processors = GetProcessorCount()) {
64 case 0:
65 case 1: