> Could you help to look into it?

Not much, sorry.

> Is this a misconfiguration in my project build environment or a bug in GNU 
> Make 4.2.1?

Maybe you'd be convinced that it's the former if you run a test like this:

martind@sirius:~/tmp/mason-zhu-2021-12-21$ cat Makefile
TARGETS = a b c
default: $(TARGETS)
$(TARGETS):; sleep 10
martind@sirius:~/tmp/mason-zhu-2021-12-21$ tty
/dev/pts/9
martind@sirius:~/tmp/mason-zhu-2021-12-21$ make -j2 & sleep 1; ps -Hjelf | grep 
pts/9; time -p wait
[1] 14504
sleep 10
sleep 10
5 S martind  14286 14280 14280 14280  0  80   0 - 22903 -      13:42 ?        
00:00:00       sshd: martind@pts/9
0 S martind  14287 14286 14287 14287  0  80   0 -  3682 -      13:42 pts/9    
00:00:00         -bash
0 S martind  14504 14287 14504 14287  0  80   0 -  2211 -      13:44 pts/9    
00:00:00           make -j2
0 S martind  14506 14504 14504 14287  0  80   0 -  1611 -      13:44 pts/9    
00:00:00             sleep 10
0 S martind  14507 14504 14504 14287  0  80   0 -  1611 -      13:44 pts/9    
00:00:00             sleep 10
0 R martind  14508 14287 14508 14287  0  80   0 -  7773 -      13:44 pts/9    
00:00:00           ps -Hjelf
0 S martind  14509 14287 14508 14287  0  80   0 -  3349 -      13:44 pts/9    
00:00:00           grep pts/9
sleep 10
[1]+  Done                    make -j2
real 18.95
user 0.00
sys 0.00
martind@sirius:~/tmp/mason-zhu-2021-12-21$

Two out of the three targets were visibly built in parallel.  Now I'm not 
running make 4.2.1 there and nor am I using RedHat 7.7 on a VM, but it'd be 
more convincing if you ran the test in the afflicted environment.

> Is there anyway to get it work?

Assuredly, but that's going to have to come largely from you.  We're not privy 
to /usr/local/bin/mr, whatever gmake is, much of the invoke_gmk function and 
your other makefiles.  Nor, I'm afraid, would we want to be.  I can point out, 
though, that Make's NEWS file contains the following snippet regarding change 
in the 4.2 era [

* The interface to GNU make's "jobserver" is stable as documented in the
  manual, for tools which may want to access it.

  WARNING: Backward-incompatibility! The internal-only command line option
  --jobserver-fds has been renamed for publishing, to --jobserver-auth.

* The amount of parallelism can be determined by querying MAKEFLAGS, even when
  the job server is enabled (previously MAKEFLAGS would always contain only
  "-j", with no number, when job server was enabled).

].  The manual section alluded to there is 
https://www.gnu.org/software/make/manual/make.html#Job-Slots.  It looks like 
you have a recursive make setup.  That manual section tells us:

> only command lines that make understands to be recursive invocations of make 
> (see How the MAKE Variable 
> Works<https://www.gnu.org/software/make/manual/make.html#MAKE-Variable>) will 
> have access to the jobserver

Here's an example where recursive Make processes cooperate to run the desired 
load in parallel, hinting that they're communicating using an environment 
variable, MAKEFLAGS, that names a couple of file descriptors:

martind@sirius:~/tmp/mason-zhu-2021-12-21$ cat Makefile.1
TARGETS = a b c
default: $(TARGETS)
$(TARGETS):; $(MAKE) -f Makefile.2 $@
martind@sirius:~/tmp/mason-zhu-2021-12-21$ cat Makefile.2
TARGETS = a b c
$(TARGETS):; @echo MAKEFLAGS is $(MAKEFLAGS) && sleep 10
martind@sirius:~/tmp/mason-zhu-2021-12-21$ ~/download/make/make -j2 -f 
Makefile.1 & sleep 1; ps -Hjelf | grep pts/9; time -p wait
[1] 28612
/home/martind/download/make/make -f Makefile.2 a
/home/martind/download/make/make -f Makefile.2 b
make[1]: Entering directory '/home/martind/tmp/mason-zhu-2021-12-21'
make[1]: Entering directory '/home/martind/tmp/mason-zhu-2021-12-21'
MAKEFLAGS is -j2 --jobserver-auth=3,4
MAKEFLAGS is -j2 --jobserver-auth=3,4
5 S martind  14286 14280 14280 14280  0  80   0 - 22927 -      13:42 ?        
00:00:02       sshd: martind@pts/9
0 S martind  14287 14286 14287 14287  0  80   0 -  3709 -      13:42 pts/9    
00:00:00         -bash
0 S martind  28612 14287 28612 14287  0  80   0 -  2214 core_s 14:27 pts/9    
00:00:00           /home/martind/download/make/make -j2 -f Makefile.1
0 S martind  28614 28612 28612 14287  0  80   0 -  2214 -      14:27 pts/9    
00:00:00             /home/martind/download/make/make -f Makefile.2 a
0 S martind  28616 28614 28612 14287  0  80   0 -  1071 -      14:27 pts/9    
00:00:00               /bin/sh -c echo MAKEFLAGS is  -j2 --jobserver-auth=3,4 
&& sleep 10
0 S martind  28618 28616 28612 14287  0  80   0 -  1611 -      14:27 pts/9    
00:00:00                 sleep 10
0 S martind  28615 28612 28612 14287  0  80   0 -  2214 -      14:27 pts/9    
00:00:00             /home/martind/download/make/make -f Makefile.2 b
0 S martind  28617 28615 28612 14287  0  80   0 -  1071 -      14:27 pts/9    
00:00:00               /bin/sh -c echo MAKEFLAGS is  -j2 --jobserver-auth=3,4 
&& sleep 10
0 S martind  28619 28617 28612 14287  0  80   0 -  1611 -      14:27 pts/9    
00:00:00                 sleep 10
0 R martind  28620 14287 28620 14287  0  80   0 -  7801 -      14:27 pts/9    
00:00:00           ps -Hjelf
0 S martind  28621 14287 28620 14287  0  80   0 -  3349 -      14:27 pts/9    
00:00:00           grep pts/9
make[1]: Leaving directory '/home/martind/tmp/mason-zhu-2021-12-21'
/home/martind/download/make/make -f Makefile.2 c
make[1]: Leaving directory '/home/martind/tmp/mason-zhu-2021-12-21'
make[1]: Entering directory '/home/martind/tmp/mason-zhu-2021-12-21'
MAKEFLAGS is -j2 --jobserver-auth=3,4
make[1]: Leaving directory '/home/martind/tmp/mason-zhu-2021-12-21'
[1]+  Done                    ~/download/make/make -j2 -f Makefile.1
real 18.96
user 0.00
sys 0.00
martind@sirius:~/tmp/mason-zhu-2021-12-21$

If something in your recursive setup is filtering MAKEFLAGS, closing those file 
descriptors or otherwise getting in the way of that communication, then that 
might explain your problem.  The details of that communication might have 
changed since make-3.82 was released in 2010, though the only change I observed 
between runs of the above test on 3.81 and 4.3.90 was the s/fd/auth/ change and 
that MAKEFLAGS used to include -j in place of -j2, as flagged in NEWS.  That 
last change did bite me once, in the opposite way than it's bitten you:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=827132 (debhelper: make-4.2 
renamed --jobserver-fds to --jobserver-auth causing parallel build issues)

Maybe there's some insight there into the kind of thing you're looking for.

________________________________
From: Bug-make <bug-make-bounces+martin.dorey=hds....@gnu.org> on behalf of 
Zhu, Mason <mason....@sap.com>
Sent: Monday, December 20, 2021 23:57
To: bug-make@gnu.org <bug-make@gnu.org>
Cc: Gelle, Sreenivasulu <sreenivasulu.ge...@sap.com>; Zheng, Fred 
<fred.zh...@sap.com>; Bedalov, Matthew <matthew.beda...@sap.com>; Foster, Casey 
<casey.fos...@sap.com>; Levan, Mark <mark.le...@sap.com>
Subject: make -j does not work on RedHat7.7 VM

***** EXTERNAL EMAIL *****

Hello,



I have a problem with make -j parallel execution in our project build.



My environment information

OS: Red Hat 7.7 virtual machine with 4 CPUs



lscpu

Architecture:          x86_64

CPU op-mode(s):        32-bit, 64-bit

Byte Order:            Little Endian

CPU(s):                4

On-line CPU(s) list:   0-3

Thread(s) per core:    1

Core(s) per socket:    1

Socket(s):             4

NUMA node(s):          1

Vendor ID:             GenuineIntel

CPU family:            6

Model:                 63

Model name:            Intel(R) Xeon(R) CPU E5-2698 v3 @ 2.30GHz

Stepping:              2

CPU MHz:               2297.339

BogoMIPS:              4594.67

Hypervisor vendor:     VMware

Virtualization type:   full

L1d cache:             32K

L1i cache:             32K

L2 cache:              256K

L3 cache:              40960K

NUMA node0 CPU(s):     0-3

Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca 
cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm 
constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc 
eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt 
tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 
invpcid_single ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 
invpcid xsaveopt arat md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities



GNU make:

/opt/rh/devtoolset-9/root/usr/bin/make  GNU Make 4.2.1

/usr/bin/make  GNU Make 3.82



gcc/g++: /opt/rh/devtoolset-9/root/usr/bin/gcc, 
/opt/rh/devtoolset-9/root/usr/bin/g++  gcc version 9.1.1 20190605 (Red Hat 
9.1.1-2) (GCC)



If I build our project with /opt/rh/devtoolset-9/root/usr/bin/make  -j 4, there 
is only on g++ process. In other words, -j 4 parallel execution option does not 
work here. The project build takes 75 minutes.



[cid:image001.png@01D7F681.ABE27C80]



If I build our project with /usr/bin/make   -j 4, I can see 4 g++ process. The 
project build takes only 25 minutes.



[cid:image002.png@01D7F681.ABE27C80]



I checked related GNU make document. It seems no additional configuration is 
required for -j option.



https://www.gnu.org/software/make/manual/html_node/Parallel.html<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.gnu.org%2Fsoftware%2Fmake%2Fmanual%2Fhtml_node%2FParallel.html&data=04%7C01%7CMartin.Dorey%40hitachivantara.com%7C082b3df4284d48a2853808d9c48b5bf8%7C18791e1761594f52a8d4de814ca8284a%7C0%7C0%7C637756925104766729%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=Ppz0au0ulOCZ7uXhD%2FneONOBln%2BID9iNnIhULQ3mmjc%3D&reserved=0>



I need your help to make progress in this task. Could you help to look into it?

Is this a misconfiguration in my project build environment or a bug in GNU Make 
4.2.1?

Is there anyway to get it work?



Thanks,

Mason




Reply via email to