3 min read

Git 및 기타 등등 팁 저장 포스트

생각날 때마다 추가합니다. 개별 포스트로 남기기 애매한 친구들 매번 검색하다가 질려서 저장용으로 적는 글.

  • Git submodule까지 모두 풀 하기
    • git submodule update --recursive
  • gcc 버전 여러 개 쓰기 (update alternative)
    • sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 600

VScode 현재 Workspace Duplicate

ctrl + shift + P 의 커맨드팔레트에서 duplicate 검색하면 나옴

옛날 리눅스 커널 컴파일하기

error : gcc: error: elf_x86_64: No such file or directory

  • Sol : arch/x86/vdso/Makefile에서 -m elf_x86_64 -> -m64, -m elf_i386 -> -m32

Error : No PIC enabled

  • Sol : 옛날 gcc 사용. (최신 gcc 지원 안 됨)

Error : Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.

  • Sol : Perl 버전 문제. defined() 없애면 됨

리눅스 커널 VScode 셋업

GitHub - FlorentRevest/linux-kernel-vscode: Reference setup for Linux kernel development in VSCode
Reference setup for Linux kernel development in VSCode - FlorentRevest/linux-kernel-vscode

이거 하고 빌드해서 compile-commands.json 만들고 clangd indexing 해주면 끝.

{
    "clangd.arguments": [
        "--compile-commands-dir=${workspaceFolder}",
        "--background-index",
        "--completion-style=detailed",
        "--header-insertion=never",
        "-log=info",
        "-pretty"
    ],
    "clangd.path": "/usr/bin/clangd"
}

아마도 필요없지만 혹시나 인식이 안될때

커널 컴파일

.config는 알아서~ make menuconfig로 해도 되고~
Linux kernel compile & install
make menuconfig
make
sudo make modules_install
sudo make install
Then update grub

clangd 시스템 라이브러리 헤더 못찾고 허우적댈때

  1. clangd --check=/path/to/your/proj.cpp 로 로그 확인
  2. stddef.h 같은 거 못 찾고 있으면 ([pp_file_not_found] Line 1: in included file: 'stddef.h' file not found)
  3. clang compile flag에 -resource-dir="/usr/lib/clang/14.0.0" 과 같이 본인 clang 버전에 맞는 resource dir 제공

이렇게 허우적대면 빨간 줄 뜨면서 in template: no type named 'size_type' in 'std::basic_string<char>::_Alloc_traits_impl<std::char_traits<char>, void>'와 같이 기본적인 거 못 찾는 에러가 보임.

clangd의 위치때문이라는 글을 봤는데 내 경우 ../에 정확히 라이브러리가 있는데도 못 찾음.

스케쥴러 디버깅

    logfile="logs/$(basename "$config" .xml).log"
    
    # Only run if config is newer than the log file or log file doesn't exist
    if [ ! -f "$logfile" ] || [ "$config" -nt "$logfile" ]; then
        echo "Running benchmark with config: $config"
        sudo /home/seunghyun/bin/perf sched record -o sched_logs/$(basename "$config" .xml).data -- /home/seunghyun/sched_bench/build/memory_benchmark --config "$config" > "$logfile" 2>&1
    else
        echo "Skipping $config (result already up to date)"
    fi
done
#!/bin/bash

# Iterate through all directories in the current path
for dir in */; do
    # Check if the directory exists and contains sched_logs
    if [ -d "${dir}sched_logs" ]; then
        echo "Processing ${dir}sched_logs/"
        
        # Iterate through all files in sched_logs directory
        for file in "${dir}sched_logs"/*.data; do
            if [ -f "$file" ]; then
                echo "Processing file: $file"
                # Add your processing logic here
                # For example:
                # cat "$file"
                sudo perf sched script -i "$file" | grep "memory_bench" > "${file}_processed.txt"
            fi
        done
        echo "Finished processing ${dir}sched_logs/"
        echo "-----------------------------------"
    fi
done