GNU make's -j option

前端 未结 6 554
走了就别回头了
走了就别回头了 2021-01-31 07:21

Ever since I learned about -j I\'ve used -j8 blithely. The other day I was compiling an atlas installation and the make failed. Eventually I tracked it down to things being ma

6条回答
  •  庸人自扰
    2021-01-31 08:14

    It is a good idea to have an automated test to test the -j option of ALL the make files. Even the best developers have problems with the -j option of make. The most common issues is the simplest.

    myrule: subrule1 subrule2
         echo done
    
    subrule1:
         echo hello
    
    subrule2:
         echo world
    

    In normal make, you will see hello -> world -> done. With make -j 4, you will might see world -> hello -> done

    Where I have see this happen most is with the creation of output directories. For example:

    build: $(DIRS) $(OBJECTS)
         echo done
    
    $(DIRS):
         -@mkdir -p $@
    
    $(OBJECTS):
         $(CC) ...
    

提交回复
热议问题