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

Verilator 工程添加 .sv 文件后,无法生成compile_command.json #5623

Open
SikongJueluo opened this issue Sep 15, 2024 · 5 comments
Open
Labels

Comments

@SikongJueluo
Copy link

Xmake 版本

v2.9.4+20240729

操作系统版本和架构

Linux - NixOS

描述问题

当我在开发基于Verilator的FPGA工程时,添加相关的 .sv 文件和 .cpp 文件后,xmake就无法生成相应的 compile_command.json。但如果没添加相关的 .sv 文件,就能够正常生成。

期待的结果

希望能够正确处理 .sv 文件,并正确生成相应的 compile_command.json

工程配置

--- Generate compile_commands.json for clangd language server
add_rules("plugin.compile_commands.autoupdate", {outputdir = ".vscode"})
--- Get C/C++ Lib Path
local INCLUDE_DIRS = path.splitenv(
  string.vformat("$(env VERILATOR_INCLUDE):$(env SYSTEMC_INCLUDE)")
)

target("TB_ISP")
  add_rules("verilator.binary")
  set_toolchains("@verilator")
  --- C/C++ Codes
  add_files(
    "src/**.cpp",
    "rtl/isp.sv"
  )
  --- Include directories
  add_includedirs("src", INCLUDE_DIRS)

附加信息和错误日志

❯ xmake project -vD -k compile_commands .vscode
checking for gcc ... /nix/store/zznja5f8v3jafffyah1rk46vpfcn38dv-gcc-wrapper-13.3.0/bin/gcc
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checking for verilator ... /nix/store/ly3ff79vnj84ly4w5h93gcwi5d25ds2z-verilator-5.026/bin/verilator
checking for verilator ... verilator
configure
{
    arch = x86_64
    mode = release
    kind = static
    plat = linux
    host = linux
    ccache = true
    ndk_stdcxx = true
    cflags = $(env NIX_CFLAGS_COMPILE)
    buildir = build
}
error: @programdir/core/main.lua:329: @programdir/core/sandbox/modules/io.lua:177: cannot open file: build/.gens/TB_ISP/linux/x86_64/release/rules/verilator/TB_ISP.cmake, No such file or directory
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:973]:
    [@programdir/core/sandbox/modules/io.lua:177]: in function 'gsub'
    [@programdir/rules/verilator/verilator.lua:36]: in function '_get_sourcefiles_from_cmake'
    [@programdir/rules/verilator/verilator.lua:313]: in function 'buildcmd_cppfiles'
    [@programdir/rules/verilator/xmake.lua:46]: in function 'script'
    [@programdir/plugins/project/utils/target_cmds.lua:79]: in function 'get_target_buildcmd_files'
    [@programdir/plugins/project/utils/target_cmds.lua:110]: in function 'get_target_buildcmd_sourcegroups'
    [@programdir/plugins/project/clang/compile_commands.lua:251]: in function '_add_target_commands'
    [@programdir/plugins/project/clang/compile_commands.lua:281]: in function '_add_target'
    [@programdir/plugins/project/clang/compile_commands.lua:293]: in function '_add_targets'
    [@programdir/plugins/project/clang/compile_commands.lua:309]: in function '?'
    [@programdir/plugins/project/main.lua:75]: in function '_make'
    [@programdir/plugins/project/main.lua:95]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:275]:
    [@programdir/core/base/task.lua:491]: in function 'run'
    [@programdir/core/main.lua:327]: in function 'cotask'
    [@programdir/core/base/scheduler.lua:406]:

stack traceback:
        [C]: in function 'error'
        @programdir/core/base/os.lua:973: in function 'base/os.raiselevel'
        (...tail calls...)
        @programdir/core/main.lua:329: in upvalue 'cotask'
        @programdir/core/base/scheduler.lua:406: in function <@programdir/core/base/scheduler.lua:399>

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Xmake version

v2.9.4+20240729

Operating system version and architecture

Linux-NixOS

Describe the problem

When I was developing an FPGA project based on Verilator, after adding the relevant .sv files and .cpp files, xmake could not generate the corresponding compile_command.json. But if the relevant .sv file is not added, it can be generated normally.

Expected results

Hopefully, .sv files will be processed correctly and the corresponding compile_command.json will be generated correctly

Project configuration

--- Generate compile_commands.json for clangd language server
add_rules("plugin.compile_commands.autoupdate", {outputdir = ".vscode"})
--- Get C/C++ Lib Path
local INCLUDE_DIRS = path.splitenv(
  string.vformat("$(env VERILATOR_INCLUDE):$(env SYSTEMC_INCLUDE)")
)

target("TB_ISP")
  add_rules("verilator.binary")
  set_toolchains("@verilator")
  ---C/C++ Codes
  add_files(
    "src/**.cpp",
    "rtl/isp.sv"
  )
  --- Include directories
  add_includedirs("src", INCLUDE_DIRS)

Additional information and error logs

❯ xmake project -vD -k compile_commands .vscode
checking for gcc ... /nix/store/zznja5f8v3jafffyah1rk46vpfcn38dv-gcc-wrapper-13.3.0/bin/gcc
checkinfo: cannot runv(zig version), No such file or directory
checking for zig... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim... no
checking for verilator ... /nix/store/ly3ff79vnj84ly4w5h93gcwi5d25ds2z-verilator-5.026/bin/verilator
checking for verilator ... verilator
configure
{
    arch = x86_64
    mode=release
    kind = static
    plat=linux
    host=linux
    ccache=true
    ndk_stdcxx = true
    cflags = $(env NIX_CFLAGS_COMPILE)
    buildir = build
}
error: @programdir/core/main.lua:329: @programdir/core/sandbox/modules/io.lua:177: cannot open file: build/.gens/TB_ISP/linux/x86_64/release/rules/verilator/TB_ISP .cmake, No such file or directory
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:973]:
    [@programdir/core/sandbox/modules/io.lua:177]: in function 'gsub'
    [@programdir/rules/verilator/verilator.lua:36]: in function '_get_sourcefiles_from_cmake'
    [@programdir/rules/verilator/verilator.lua:313]: in function 'buildcmd_cppfiles'
    [@programdir/rules/verilator/xmake.lua:46]: in function 'script'
    [@programdir/plugins/project/utils/target_cmds.lua:79]: in function 'get_target_buildcmd_files'
    [@programdir/plugins/project/utils/target_cmds.lua:110]: in function 'get_target_buildcmd_sourcegroups'
    [@programdir/plugins/project/clang/compile_commands.lua:251]: in function '_add_target_commands'
    [@programdir/plugins/project/clang/compile_commands.lua:281]: in function '_add_target'
    [@programdir/plugins/project/clang/compile_commands.lua:293]: in function '_add_targets'
    [@programdir/plugins/project/clang/compile_commands.lua:309]: in function '?'
    [@programdir/plugins/project/main.lua:75]: in function '_make'
    [@programdir/plugins/project/main.lua:95]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:275]:
    [@programdir/core/base/task.lua:491]: in function 'run'
    [@programdir/core/main.lua:327]: in function 'cotask'
    [@programdir/core/base/scheduler.lua:406]:

stack traceback:
        [C]: in function 'error'
        @programdir/core/base/os.lua:973: in function 'base/os.raiselevel'
        (...tail calls...)
        @programdir/core/main.lua:329: in upvalue 'cotask'
        @programdir/core/base/scheduler.lua:406: in function <@programdir/core/base/scheduler.lua:399>

@waruqi
Copy link
Member

waruqi commented Sep 15, 2024

目前还不支持

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Not supported yet

@waruqi
Copy link
Member

waruqi commented Sep 18, 2024

试试 #5635

xmake update -s github:xmake-io/xmake#compdb

@waruqi waruqi added this to the v2.9.6 milestone Sep 18, 2024
@SikongJueluo
Copy link
Author

似乎依然不能正确生成compile_command.json

❯ xmake project -k compile_commands .vscode
checking for platform ... linux
checking for architecture ... x86_64
error: unknown source file: rtl/isp.sv

我不确定是不是因为我没有正确更新的问题,因为我似乎只能使用sudo才能更新。

❯ xmake update -s github:xmake-io/xmake#compdb
update version compdb from https://github.com/xmake-io/xmake.git ..
  => download https://github.com/xmake-io/xmake.git .. ok
error: run `sh /usr/share/xmake/scripts/update-script.sh /usr/share/xmake /tmp/.xmake1000/240924/xmakesrc/compdb/xmake` failed, may permission denied!
note: try continue to run `sh /usr/share/xmake/scripts/update-script.sh /usr/share/xmake /tmp/.xmake1000/240924/xmakesrc/compdb/xmake` with administrator permission again (pass -y or --confirm=y/n/d to skip confirm)?
please input: y (y/n)
y
failed

❯ sudo xmake update --root -s github:xmake-io/xmake#compdb
update version compdb from https://github.com/xmake-io/xmake.git ..
  => download https://github.com/xmake-io/xmake.git .. ok
  => install script to /usr/share/xmake .. ok

@SikongJueluo SikongJueluo reopened this Sep 24, 2024
@waruqi waruqi removed this from the v2.9.6 milestone Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants