programing

“make oldconfig”는 Linux 커널 makefile에서 정확히 무엇을합니까?

nasanasas 2020. 10. 26. 08:03
반응형

“make oldconfig”는 Linux 커널 makefile에서 정확히 무엇을합니까?


Linux 커널 makefile에서 대상 "oldconfig"가 정확히 무엇을하는지 설명 할 수 있습니까? 일부 빌드 문서에서 참조했지만 정확히 무엇을하는지 설명하지 않았습니다.


기존 .config파일을 읽고 파일에서 찾을 수없는 현재 커널 소스의 옵션을 사용자에게 프롬프트합니다. 이것은 기존 구성을 가져와 새 커널로 이동할 때 유용합니다.


를 실행하기 전에 make oldconfig이전 커널의 커널 구성 파일을 새 커널의 루트 디렉토리로 복사해야합니다.

에서 실행중인 시스템의 이전 커널 구성 파일 사본을 찾을 수 있습니다 /boot/config-3.11.0. 또는 커널 소스 코드에 구성이 있습니다.linux-3.11.0/arch/x86/configs/{i386_defconfig / x86_64_defconfig}

커널 소스가 다음 위치에있는 경우 /usr/src/linux:

cd /usr/src/linux
cp /boot/config-3.9.6-gentoo .config
make oldconfig

요약

Ignacio 에서 언급했듯이 .config커널 소스를 업데이트 한 후 업데이트합니다 (예 : git pull.

기존 옵션을 유지하려고합니다.

다음과 같은 이유로 스크립트가 있으면 도움이됩니다.

  • 새 옵션이 추가되었거나 이전 옵션이 제거되었을 수 있습니다.

  • 커널의 Kconfig 구성 형식에는 다음과 같은 옵션이 있습니다.

    • 서로를 통해 암시 select
    • 다른 것을 통해 의존 depends

    이러한 옵션 관계는 수동 구성 해결을 더욱 어렵게 만듭니다.

구성을 해결하는 방법을 이해하기 위해 .config를 수동으로 수정 해 보겠습니다.

먼저 다음을 사용하여 기본 구성을 생성하십시오.

make defconfig

이제 생성 된 .config파일을 수동으로 편집하여 커널 업데이트를 에뮬레이트하고 다음을 실행합니다.

make oldconfig

무슨 일이 일어나는지 볼 수 있습니다. 몇 가지 결론 :

  1. 유형의 라인 :

    # CONFIG_XXX is not set
    

    단순한 주석이 아니라 실제로 매개 변수가 설정되지 않았 음을 나타냅니다.

    예를 들어, 라인을 제거하면 :

    # CONFIG_DEBUG_INFO is not set
    

    실행 make oldconfig하면 다음 과 같은 메시지가 표시됩니다.

    Compile the kernel with debug info (DEBUG_INFO) [N/y/?] (NEW)
    

    완료되면 .config파일이 업데이트됩니다.

    행의 문자를 변경하면 (예 :로 # CONFIG_DEBUG_INFO) 계산되지 않습니다.

  2. 유형의 라인 :

    # CONFIG_XXX is not set
    

    다음과 같은 경우에도 항상 속성의 부정에 사용됩니다.

    CONFIG_XXX=n
    

    부정으로도 이해됩니다.

    예를 들어, 제거 # CONFIG_DEBUG_INFO is not set하고 대답하는 경우 :

    Compile the kernel with debug info (DEBUG_INFO) [N/y/?] (NEW)
    

    를 사용 N하면 출력 파일에 다음이 포함됩니다.

    # CONFIG_DEBUG_INFO is not set
    

    그리고 아닙니다 :

    CONFIG_DEBUG_INFO=n
    

    또한 라인을 다음과 같이 수동으로 수정하는 경우 :

    CONFIG_DEBUG_INFO=n
    

    실행 make oldconfig하면 줄이 다음과 같이 수정됩니다.

    # CONFIG_DEBUG_INFO is not set
    

    oldconfig우리에게 묻지 않고 .

  3. 종속성이 충족되지 않는 구성은 .config. 다른 모든 것.

    예를 들어 다음을 설정하십시오.

    CONFIG_DEBUG_INFO=y
    

    그리고 실행하십시오 make oldconfig. : 지금 우리를 물어볼 것 DEBUG_INFO_REDUCED, DEBUG_INFO_SPLIT등 CONFIGS.

    Those properties did not appear on the defconfig before.

    If we look under lib/Kconfig.debug where they are defined, we see that they depend on DEBUG_INFO:

    config DEBUG_INFO_REDUCED
        bool "Reduce debugging information"
        depends on DEBUG_INFO
    

    So when DEBUG_INFO was off, they did not show up at all.

  4. Configs which are selected by turned on configs are automatically set without asking the user.

    For example, if CONFIG_X86=y and we remove the line:

    CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
    

    and run make oldconfig, the line gets recreated without asking us, unlike DEBUG_INFO.

    This happens because arch/x86/Kconfig contains:

    config X86
        def_bool y
        [...]
        select ARCH_MIGHT_HAVE_PC_PARPORT
    

    and select forces that option to be true. See also: https://unix.stackexchange.com/questions/117521/select-vs-depends-in-kernel-kconfig

  5. Configs whose constraints are not met are asked for.

    For example, defconfig had set:

    CONFIG_64BIT=y
    CONFIG_RCU_FANOUT=64
    

    If we edit:

    CONFIG_64BIT=n
    

    and run make oldconfig, it will ask us:

    Tree-based hierarchical RCU fanout value (RCU_FANOUT) [32] (NEW)
    

    This is because RCU_FANOUT is defined at init/Kconfig as:

    config RCU_FANOUT
        int "Tree-based hierarchical RCU fanout value"
        range 2 64 if 64BIT
        range 2 32 if !64BIT
    

    Therefore, without 64BIT, the maximum value is 32, but we had 64 set on the .config, which would make it inconsistent.

Bonuses

make olddefconfig sets every option to their default value without asking interactively. It gets run automatically on make to ensure that the .config is consistent in case you've modified it manually like we did. See also: https://serverfault.com/questions/116299/automatically-answer-defaults-when-doing-make-oldconfig-on-a-kernel-tree

make alldefconfig is like make olddefconfig, but it also accepts a config fragment to merge. This target is used by the merge_config.sh script: https://stackoverflow.com/a/39440863/895245

And if you want to automate the .config modification, that is not too simple: How do you non-interactively turn on features in a Linux kernel .config file?


Updates an old config with new/changed/removed options.


From this page:

Make oldconfig takes the .config and runs it through the rules of the Kconfig files and produces a .config which is consistant with the Kconfig rules. If there are CONFIG values which are missing, the make oldconfig will ask for them.

If the .config is already consistant with the rules found in Kconfig, then make oldconfig is essentially a no-op.

If you were to run make oldconfig, and then run make oldconfig a second time, the second time won't cause any additional changes to be made.


It's torture. Instead of including a generic conf file, they make you hit return 9000 times to generate one.

참고URL : https://stackoverflow.com/questions/4178526/what-does-make-oldconfig-do-exactly-in-the-linux-kernel-makefile

반응형