Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"directory" In "compile_commands.json" Is Ignored? #12183

Closed
vindicatorr opened this issue Apr 9, 2024 · 2 comments
Closed

"directory" In "compile_commands.json" Is Ignored? #12183

vindicatorr opened this issue Apr 9, 2024 · 2 comments
Assignees
Labels
Language Service more info needed The issue report is not actionable in its current state

Comments

@vindicatorr
Copy link

Environment

  • OS and Version: Linux x64 6.5.0-dirty
  • VS Code Version: 1.86.0
  • Commit: feff7c8a7e1c82320380f42d898a1e03051fefb7
  • C/C++ Extension Version: v1.15.3-main

Bug Summary and Steps to Reproduce

Bug Summary:
It appears that the directory field in compile_commands.json is ignored and looks like it should be used to switch to that path when running the command.

Steps to reproduce:

  1. Get a Linux repo
  2. $ make LLVM=1 O=<pathTo>/build_<arch>/ tinyconfig
  3. $ ./scripts/config --file <pathTo>/build_<arch>/.config --enable RANDSTRUCT_FULL
  4. $ make LLVM=1 O=<pathTo>/build_<arch>/ compile_commands.json
  5. Load linux repo folder in vscode
  6. Set necessary c_cpp_properties.json fields (listed below)
  7. See error in log output below

Expected behavior:
'./scripts/basic/randstruct.seed' should be found because it DOES exist.
-frandomize-layout-seed-file=./scripts/basic/randstruct.seed

$ ls -l ./build_arm64/scripts/basic/randstruct.seed
-rw------- 1 userName userName 65 Apr  1 20:19 ./build_arm64/scripts/basic/randstruct.seed

Configuration and Logs

/<pathTo>/linux-stable/build_arm64/compile_commands.json:

[
  {
    "command": "clang -Wp,-MMD,arch/arm64/xen/../../arm/xen/.enlighten.o.d -nostdinc -I../arch/arm64/include -I./arch/arm64/include/generated -I../include -I./include -I../arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I../include/uapi -I./include/generated/uapi -include ../include/linux/compiler-version.h -include ../include/linux/kconfig.h -include ../include/linux/compiler_types.h -D__KERNEL__ --target=aarch64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument -mlittle-endian -DCC_USING_PATCHABLE_FUNCTION_ENTRY -DKASAN_SHADOW_SCALE_SHIFT= -fmacro-prefix-map=../= -Werror -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mgeneral-regs-only -DCONFIG_CC_HAS_K_CONSTRAINT=1 -Wno-psabi -fasynchronous-unwind-tables -mbranch-protection=pac-ret+bti -Wa,-march=armv8.5-a -DARM64_ASM_ARCH='\"armv8.5-a\"' -ffixed-x18 -DKASAN_SHADOW_SCALE_SHIFT= -fno-delete-null-pointer-checks -O2 -fstack-protector-strong -fno-omit-frame-pointer -fno-optimize-sibling-calls -ftrivial-auto-var-init=pattern -fzero-call-used-regs=used-gpr -fpatchable-function-entry=2 -fsanitize=kcfi -falign-functions=64 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-gnu -Wno-unused-but-set-variable -Wno-unused-const-variable -Wvla -Wno-pointer-sign -Wcast-function-type -Wimplicit-fallthrough -Werror=date-time -Werror=incompatible-pointer-types -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -Wno-cast-function-type-strict -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-initializer-overrides -Wno-sign-compare -DRANDSTRUCT -frandomize-layout-seed-file=./scripts/basic/randstruct.seed -mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=5008   -fsanitize=array-bounds -fsanitize=shift -fsanitize=unreachable -fsanitize=bool -fsanitize=enum  -fsanitize-coverage=trace-pc -fsanitize-coverage=trace-cmp  -fsanitize=thread -fno-optimize-sibling-calls -mllvm -tsan-compound-read-before-write=1 -mllvm -tsan-distinguish-volatile=1  -I ../arch/arm64/xen -I ./arch/arm64/xen    -DKBUILD_MODFILE='\"arch/arm64/xen/xen-arm\"' -DKBUILD_BASENAME='\"enlighten\"' -DKBUILD_MODNAME='\"xen_arm\"' -D__KBUILD_MODNAME=kmod_xen_arm -c -o arch/arm64/xen/../../arm/xen/enlighten.o ../arch/arm64/xen/../../arm/xen/enlighten.c",
    "directory": "/<pathTo>/linux-stable/build_arm64",
    "file": "/<pathTo>/linux-stable/arch/arm/xen/enlighten.c"
  },
<...>

settings.json:

{
    "C_Cpp.intelliSenseEngine": "default",
    "C_Cpp.loggingLevel": "Debug"
}

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "compileCommands": "/<pathTo>/linux-stable/build_arm64/compile_commands.json",
            "dotConfig": "/<pathTo>/linux-stable/build_arm64/.config"
        }
    ],
    "version": 4
}

Output - C/C++:

loggingLevel: Debug
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
File exclude: **/.vs
File exclude: **/.vscode
File exclude: **/.factorypath
File exclude: **/.settings
File exclude: **/.project
File exclude: **/Thumbs.db
File exclude: **/.svn
File exclude: **/.git
File exclude: **/.hg
File exclude: **/.classpath
File exclude: **/.DS_Store
File exclude: **/CVS
Search exclude: **/*.code-search
Search exclude: **/node_modules
Search exclude: **/bower_components
LSP: Message ignored due to no registered handler: $/setTrace
LSP: cpptools/didChangeCppProperties (id: 1)
LSP: cpptools/queryCompilerDefaults (id: 2)
Code browsing service initialized
Querying compiler for default C++ language standard using command line: /usr/bin/clang -x c++ -E -dM /dev/null
Detected language standard version: c++17
Querying compiler's default target using command line: "/usr/bin/clang" -dumpmachine
Compiler returned default target value: x86_64-pc-linux-gnu
Compiler query command line: /usr/bin/clang -Wp,-MMD,arch/arm64/kvm/../../../virt/kvm/.vfio.o.d -nostdinc --target=aarch64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument -mlittle-endian -fmacro-prefix-map=../= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mgeneral-regs-only -Wno-psabi -fasynchronous-unwind-tables -mbranch-protection=pac-ret+bti -Wa,-march=armv8.5-a -ffixed-x18 -fno-delete-null-pointer-checks -O2 -fstack-protector-strong -fno-omit-frame-pointer -fno-optimize-sibling-calls -ftrivial-auto-var-init=pattern -fzero-call-used-regs=used-gpr -fpatchable-function-entry=2 -fsanitize=kcfi -falign-functions=64 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-gnu -Wno-unused-but-set-variable -Wno-unused-const-variable -Wvla -Wno-pointer-sign -Wcast-function-type -Wimplicit-fallthrough -Werror=date-time -Werror=incompatible-pointer-types -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -Wno-cast-function-type-strict -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-initializer-overrides -Wno-sign-compare -frandomize-layout-seed-file=./scripts/basic/randstruct.seed -mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=5008 -fsanitize=array-bounds -fsanitize=shift -fsanitize=unreachable -fsanitize=bool -fsanitize=enum -fsanitize-coverage=trace-pc -fsanitize-coverage=trace-cmp -fsanitize=thread -fno-optimize-sibling-calls -mllvm -tsan-compound-read-before-write=1 -mllvm -tsan-distinguish-volatile=1 -Wp,-v -fno-blocks -E -dM -x c /dev/null
error: cannot read randomize layout seed file './scripts/basic/randstruct.seed'

//same error for every file


### Other Extensions

_No response_

### Additional context

And the reason for me trying to have c_cpp extension do this is because the clangd extension causes an OOM when I use the `allyesconfig`.

While I encountered this using `allyesconfig`, I am using `tinyconfig` w/`RANDSTRUCT_FULL` enabled to speed up the process for this repo.
@Colengms
Copy link
Collaborator

Colengms commented Apr 9, 2024

Hi @vindicatorr . I've recently verified, in the context of multiple other reported issues, that the directory field is being used as the current working directory when querying compilers from compile_commands.json. i.e. : #12024 (comment)

C/C++ Extension Version: v1.15.3-main

That is a rather old version of the extension (and custom built from main?). There was a known issue with this behavior prior to 1.19.3. It you're indeed still using v1.15.3, I'd recommend updating to a more recent version.

@Colengms Colengms self-assigned this Apr 9, 2024
@Colengms Colengms added Language Service more info needed The issue report is not actionable in its current state labels Apr 9, 2024
@vindicatorr
Copy link
Author

Yeah, this definitely sounds like your #12024 (comment) so I'll close this and upgrade all of it and re-open if needed, but I doubt I will need to since your comment there addresses that perfectly.

Definitely don't think I would've considered even looking at that issue submission given the title didn't look anywhere near what my issue was, but your comment inside nailed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Service more info needed The issue report is not actionable in its current state
Projects
None yet
Development

No branches or pull requests

2 participants