Skip to content

Commit

Permalink
Merge branch 'latest' into net
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
  • Loading branch information
matttbe committed May 2, 2024
2 parents 07fb401 + 7e4770c commit 5ad57b2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --rm -it \
If you use [VSCode for Linux kernel development](https://github.com/FlorentRevest/linux-kernel-vscode)
add-on, you can configure it to use this docker image: simply copy all files
from the [`vscode`](/tree/main/vscode) directory in your `.vscode` dir from the
kernel source (or use symbolic links).
kernel source (or use symbolic links). `.clangd` needs to be placed at the root
of the kernel source directory.

Notes:
- The VSCode add-on needs some modifications, see
Expand All @@ -248,10 +249,6 @@ Notes:
PRs are not merged, you can use
[this fork](https://github.com/matttbe/linux-kernel-vscode/) (`virtme-support`
branch) for the moment.
- If you build the Docker image yourself, you can use a symbolic link instead of
the `clangd` script:
```bash
ln -s /PATH/TO/mptcp-upstream-virtme-docker/run-tests-dev-cmd.sh .vscode/mptcp-virtme-clangd
```
- CLang will be used by VSCode, e.g. to generate `compile_commands.json`. You
then need to launch docker commands with `-e INPUT_CLANG=1`
- CLang will be used by VSCode instead of GCC. It is then required to launch all
docker commands with `-e INPUT_CLANG=1`, see above.
- CLangD will be used on the host machine, not in the Docker.
30 changes: 21 additions & 9 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ VIRTME_WORKDIR="${KERNEL_SRC}/.virtme"
VIRTME_BUILD_DIR="${VIRTME_WORKDIR}/build"
with_clang && VIRTME_BUILD_DIR+="-clang"
VIRTME_SCRIPTS_DIR="${VIRTME_WORKDIR}/scripts"
VIRTME_HEADERS_DIR="${VIRTME_WORKDIR}/headers"
VIRTME_PERF_DIR="${VIRTME_BUILD_DIR}/tools/perf"
VIRTME_TOOLS_SBIN_DIR="${VIRTME_BUILD_DIR}/tools/sbin"
VIRTME_CACHE_DIR="${VIRTME_BUILD_DIR}/.cache"

VIRTME_KCONFIG="${VIRTME_BUILD_DIR}/.config"

Expand All @@ -115,8 +117,11 @@ export KCONFIG_CONFIG="${VIRTME_KCONFIG}"
mkdir -p \
"${VIRTME_BUILD_DIR}" \
"${VIRTME_SCRIPTS_DIR}" \
"${VIRTME_HEADERS_DIR}" \
"${VIRTME_PERF_DIR}" \
"${VIRTME_CACHE_DIR}" \
"${CCACHE_DIR}"
chmod 777 "${VIRTME_CACHE_DIR}" # to let users writting files there, e.g. clangd

VIRTME_CONFIGKERNEL="virtme-configkernel"
VIRTME_RUN="virtme-run"
Expand Down Expand Up @@ -439,26 +444,30 @@ gen_kconfig() { local mode kconfig=() vck rc=0
build_kernel() { local rc=0
log_section_start "Build kernel"

# undo BPFTrace and cie workaround
find "${VIRTME_BUILD_DIR}/include" \
-mindepth 1 -maxdepth 1 \
! -name 'config' ! -name 'generated' \
-type d -exec rm -r {} +

_make_o || rc=${?}

log_section_end

return ${rc}
}

build_compile_commands() { local rc=0
log_section_start "Build compile_commands.json"

_make_o compile_commands.json || rc=${?}

log_section_end

return ${rc}
}

install_kernel_headers() { local rc=0
log_section_start "Install kernel headers"

# for BPFTrace and cie
cp -r include/ "${VIRTME_BUILD_DIR}"

_make_o headers_install INSTALL_HDR_PATH="${VIRTME_BUILD_DIR}" || rc=${?}
_make_o headers_install INSTALL_HDR_PATH="${VIRTME_HEADERS_DIR}" || rc=${?}

log_section_end

Expand Down Expand Up @@ -505,6 +514,9 @@ build() {
fi

build_kernel
if [ "${EXPECT}" = 0 ] && with_clang; then
build_compile_commands || true # nice to have
fi
install_kernel_headers
build_modules
build_perf
Expand All @@ -518,7 +530,7 @@ build_selftests() { local rc=0

log_section_start "Build the selftests $(basename "${SELFTESTS_DIR}")"

_make_o KHDR_INCLUDES="-I${VIRTME_BUILD_DIR}/include" -C "${SELFTESTS_DIR}" || rc=${?}
_make_o KHDR_INCLUDES="-I${VIRTME_HEADERS_DIR}/include" -C "${SELFTESTS_DIR}" || rc=${?}

log_section_end

Expand All @@ -533,7 +545,7 @@ build_bpftests() { local rc=0

log_section_start "Build BPFTests"

_make_o KHDR_INCLUDES="-I${VIRTME_BUILD_DIR}/include" -C "${BPFTESTS_DIR}" || rc=${?}
_make_o KHDR_INCLUDES="-I${VIRTME_HEADERS_DIR}/include" -C "${BPFTESTS_DIR}" || rc=${?}

log_section_end

Expand Down
3 changes: 3 additions & 0 deletions vscode/.clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Diagnostics:
ClangTidy:
Remove: bugprone-sizeof-expression
6 changes: 0 additions & 6 deletions vscode/mptcp-virtme-clangd

This file was deleted.

3 changes: 1 addition & 2 deletions vscode/settings-extra.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"clangd.arguments": [
"-compile-commands-dir=${workspaceFolder}/.virtme/build-clang"
],
"clangd.path": "${workspaceFolder}/.vscode/mptcp-virtme-clangd"
]
}

0 comments on commit 5ad57b2

Please sign in to comment.