【轉】核心編譯時間, 到底用make clean, make mrproper還是make distclean(轉載)

來源:互聯網
上載者:User

標籤:

原文網址:http://dongyulong.blog.51cto.com/1451604/449470

核心編譯時間, 到底用make clean, make mrproper還是make distclean

在編譯核心時,  被make clean, make mrproer 和 make distclean搞的糾結, 稍微總結一下這三者之間的區別:
 
解壓核心源碼包後, 到核心原始碼分類樹的頂層目錄, 執行
# make help
Cleaning targets:
  clean           - Remove most generated files but keep the config and
                    enough build support to build external modules
  mrproper        - Remove all generated files + config + various backup files
  distclean       - mrproper + remove editor backup and patch files
看協助可以發現刪除的檔案範圍從小到大依次為: make clean < make mrproper < make distclean, 查看源碼分類樹的頂層目錄下的Makefile求證, 可以發現:
clean: archclean $(clean-dirs)
        $(call cmd,rmdirs)
        $(call cmd,rmfiles)
        @find . $(RCS_FIND_IGNORE) \
                \( -name ‘*.[oas]‘ -o -name ‘*.ko‘ -o -name ‘.*.cmd‘ \
                -o -name ‘.*.d‘ -o -name ‘.*.tmp‘ -o -name ‘*.mod.c‘ \
                -o -name ‘*.symtypes‘ -o -name ‘modules.order‘ \
                -o -name ‘Module.markers‘ \) \
                -type f -print | xargs rm -f
 
mrproper: clean archmrproper $(mrproper-dirs)
        $(call cmd,rmdirs)
        $(call cmd,rmfiles)
 
distclean: mrproper
        @find $(srctree) $(RCS_FIND_IGNORE) \
                \( -name ‘*.orig‘ -o -name ‘*.rej‘ -o -name ‘*~‘ \
                -o -name ‘*.bak‘ -o -name ‘#*#‘ -o -name ‘.*.orig‘ \
                -o -name ‘.*.rej‘ -o -size 0 \
                -o -name ‘*%‘ -o -name ‘.*.cmd‘ -o -name ‘core‘ \) \
                -type f -print | xargs rm -f
也就是說, 執行make mrproper, 會先執行make clean, 執行make distclean之前, 會先執行make mrproper。
再回到make help的結果:
make clean      刪除大多數的編譯組建檔案, 但是會保留核心的設定檔.config, 還有足夠的編譯支援來建立擴充模組
make mrproper   刪除所有的編譯組建檔案, 還有核心設定檔, 再加上各種備份檔案
make distclean  mrproper刪除的檔案, 加上編輯備份檔案和一些補丁檔案。
 
其 實, 對於一個剛剛從kernel.org上下載的核心源碼包, 可以不用執行make clean/make mrproper/make distclean, 因為源碼包的狀態本身就是clean的。
 
另外, 就算編譯過核心之後, 需不需要clean一下,  個人覺得應該具體問題具體對待, 且看linuxsir上也有兄弟對這個問題有疑問:
Q: 很多核心編譯的教程都說在make之前要先make mrproper,清除以前編譯的產物。但編譯器/連結器本身就會檢查檔案的日期,並確定是否需要重新編譯/連結。如果清除了,很多以前已經編譯過的代碼 又得重新編譯。如果說這樣能節省硬碟空間的話,那隻有那些先前編譯過而現在不再需要的模組的空間被節省了,而代價則是編譯時間延長了。個人覺得得不償失, 至少不需要每次編譯都來一次make mrproper。
 
A:  我沒有make mrproper,每次修改核心配置後很快就能編譯完成,很方便,也沒發現什麼問題
如果make不能確定那些檔案要重新編譯,那還要make做什 麼
個人觀點,盡信書則不如無書,實踐出真知,呵呵
 
A:  不執行make mrproper是否出錯,取決於Makefile的智能化程度。如果Makefile沒能完成你所要求的全部改動,很可能編譯出來的核心不如你所願,甚 至可能導致panic。建議重新編譯的時候注意看看改動是否都落實了。

【轉】核心編譯時間, 到底用make clean, make mrproper還是make distclean(轉載)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.