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

'--device-debug (-G)' overrides '--generate-line-info (-lineinfo)' in nvcc #5777

Closed
Aurorabili opened this issue Nov 1, 2024 · 7 comments
Closed
Assignees
Labels
Milestone

Comments

@Aurorabili
Copy link
Contributor

Xmake 版本

2.9.6

操作系统版本和架构

Ubuntu 22.04, Linux Kernel 5.14.0-427.31.1.el9_4.x86_64

描述问题

使用 xmake create -l cuda 创建默认 cuda 项目并在 mode.debug 下构建得到 nvcc 警告:

nvcc warning : '--device-debug (-G)' overrides '--generate-line-info (-lineinfo)'
ptxas warning : Conflicting options --device-debug and --generate-line-info specified, ignoring --generate-line-info option

期待的结果

mode.debug 下仅包含 --device-debug (-G) 选项。

工程配置

add_rules("mode.debug", "mode.release")

target("hello-cuda")
    set_kind("binary")
    add_files("src/*.cu")
    set_toolchains("cuda")
    add_cugencodes("native")

附加信息和错误日志

console log

devcontainer ➜ /workspaces/hello-cuda $ xmake f -m debug
checking for platform ... linux
checking for architecture ... x86_64
checking for Cuda SDK directory ... /usr/local/cuda
devcontainer ➜ /workspaces/hello-cuda $ xmake -rvD      
checking for /usr/local/cuda/bin/nvcc ... ok
checking for flags (-O0) ... ok
> nvcc "-O0"
checking for flags (-rdc=true) ... ok
> nvcc "-rdc=true"
checking for flags (-gencode arch=compute_61,code=sm_61) ... ok
> nvcc "-gencode" "arch=compute_61,code=sm_61"
[ 50%]: compiling.debug src/main.cu
/usr/local/cuda/bin/nvcc -c -Xcompiler -fPIE -G -g -lineinfo -O0 -I/usr/local/cuda/include -m64 -rdc=true -gencode arch=compute_61,code=sm_61 -o build/.objs/hello-cuda/linux/x86_64/debug/src/main.cu.o src/main.cu
checking for flags (-MMD -MF) ... ok
> nvcc "-MMD" "-MF" "/dev/null"
nvcc warning : '--device-debug (-G)' overrides '--generate-line-info (-lineinfo)'
ptxas warning : Conflicting options --device-debug and --generate-line-info specified, ignoring --generate-line-info option
checking for nvcc ... /usr/local/cuda/bin/nvcc
checking for the cuda linker (culd) ... nvcc
checking for flags (-gencode arch=compute_61,code=sm_61) ... ok
> nvcc "-gencode" "arch=compute_61,code=sm_61"
[ 75%]: devlinking.debug hello-cuda_gpucode.cu.o
/usr/local/cuda/bin/nvcc -o build/.objs/hello-cuda/linux/x86_64/debug/rules/cuda/devlink/hello-cuda_gpucode.cu.o build/.objs/hello-cuda/linux/x86_64/debug/src/main.cu.o -L/usr/local/cuda/lib64 -lcudadevrt -lcudart_static -lrt -lpthread -ldl -m64 -gencode arch=compute_61,code=sm_61 -dlink
checking for g++ ... /usr/bin/g++
checking for the linker (ld) ... g++
checking for /usr/bin/g++ ... ok
checking for flags (-fPIC) ... ok
> g++ "-fPIC" "-m64" "-m64"
checking for flags (-Wl,-rpath=/usr/local/cuda/lib64) ... ok
> g++ "-Wl,-rpath=/usr/local/cuda/lib64" "-m64" "-m64"
[ 75%]: linking.debug hello-cuda
/usr/bin/g++ -o build/linux/x86_64/debug/hello-cuda build/.objs/hello-cuda/linux/x86_64/debug/src/main.cu.o build/.objs/hello-cuda/linux/x86_64/debug/rules/cuda/devlink/hello-cuda_gpucode.cu.o -m64 -L/usr/local/cuda/lib64 -Wl,-rpath=/usr/local/cuda/lib64 -lcudadevrt -lcudart_static -lrt -lpthread -ldl

build cache stats:
cache directory: build/.build_cache
cache hit rate: 0%
cache hit: 0
cache hit total time: 0.000s
cache miss: 0
cache miss total time: 0.000s
new cached files: 0
remote cache hit: 0
remote new cached files: 0
preprocess failed: 0
compile fallback count: 0
compile total time: 0.000s

[100%]: build ok, spent 7.894s

compile_commands.json

[
  {
    "directory": "/workspaces/hello-cuda",
    "arguments": [
      "/usr/local/cuda/bin/nvcc",
      "-c",
      "-Xcompiler",
      "-fPIE",
      "-G",
      "-g",
      "-lineinfo",
      "-O0",
      "-I/usr/local/cuda/include",
      "-m64",
      "-rdc=true",
      "-gencode",
      "arch=compute_61,code=sm_61",
      "-o",
      "build/.objs/hello-cuda/linux/x86_64/debug/src/main.cu.o",
      "src/main.cu"
    ],
    "file": "src/main.cu"
  }
]
@Aurorabili Aurorabili added the bug label Nov 1, 2024
@waruqi
Copy link
Member

waruqi commented Nov 2, 2024

@xq114 Any idea? 6523b8e

@xq114
Copy link
Contributor

xq114 commented Nov 3, 2024

Can we turn on --device-debug for debug mode and --generate-line-info for releasedbg mode? The first option will turn off optimization while the second won't. https://nanxiao.me/en/dont-use-g-compile-option-for-profiling-cuda-programs/ seems -lineinfo is made for profiling needs.

@waruqi
Copy link
Member

waruqi commented Nov 4, 2024

Can we turn on --device-debug for debug mode and --generate-line-info for releasedbg mode? The first option will turn off optimization while the second won't. https://nanxiao.me/en/dont-use-g-compile-option-for-profiling-cuda-programs/ seems -lineinfo is made for profiling needs.

那就只能 symbols 里面同时去掉 -G/-lineinfo,只保留 -g 。。然后 在 module/rules 里面分别对 debug/releasedbg 单独加 add_cuflags("-G") 和 lineinfo

@Aurorabili
Copy link
Contributor Author

好主意。我注意到 module/rules 中存在 mode.profile,将 -lineinfo 加在这里是否会比加在 mode.releasedbg 更符合语义?

@Issues-translate-bot
Copy link

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


Good idea. I noticed that mode.profile exists in module/rules, would adding -lineinfo there be more semantic than adding mode.releasedbg?

@waruqi
Copy link
Member

waruqi commented Nov 4, 2024

好主意。我注意到 module/rules 中存在 mode.profile,将 -lineinfo 加在这里是否会比加在 mode.releasedbg 更符合语义?

也可以

@Issues-translate-bot
Copy link

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


Good idea. I noticed that mode.profile exists in module/rules, would adding -lineinfo there be more semantic than adding mode.releasedbg?

OK

Aurorabili added a commit to Aurorabili/xmake that referenced this issue Nov 4, 2024
@waruqi waruqi closed this as completed in f01ed0a Nov 4, 2024
waruqi added a commit that referenced this issue Nov 4, 2024
@waruqi waruqi added this to the v2.9.7 milestone Nov 4, 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

4 participants