Skip to content

Support nvcc --device-debug flag #2384

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ name: ci
on: [ push, pull_request ]

jobs:
checks:
name: checks
runs-on: ubuntu-latest
outputs:
has-codecov-token: ${{ steps.has-codecov-token.outputs.defined }}
steps:
- id: has-codecov-token
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: "${{ env.CODECOV_TOKEN != '' }}"
run: echo "::set-output name=defined::true"
lint:
name: ${{ matrix.component }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -59,6 +70,7 @@ jobs:


test:
needs: [checks]
name: test ${{ matrix.os }} rust ${{ matrix.rustc || 'stable' }} ${{ matrix.extra_desc }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow_failure || false }}
Expand All @@ -72,40 +84,50 @@ jobs:
rustc: "1.75.0"
extra_desc: dist-tests
extra_args: --no-default-features --features=dist-tests test_dist_ -- --test-threads 1
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: ubuntu-22.04
rustc: stable
extra_desc: dist-server
extra_args: --features=dist-server
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: ubuntu-22.04
rustc: stable
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: ubuntu-22.04
rustc: beta
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: ubuntu-22.04
rustc: nightly
allow_failure: true
extra_args: --features=unstable
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: ubuntu-22.04
extra_desc: no-default-features
extra_args: --no-default-features
allow_failure: true
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: ubuntu-22.04
cuda: "11.8"
extra_desc: cuda11.8
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: ubuntu-24.04
cuda: "12.8"
# Oldest supported version, keep in sync with README.md
rustc: "1.75.0"
extra_desc: cuda12.8
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: macos-13
no_coverage: true
# # M1 CPU
- os: macos-14
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: windows-2019
cuda: "11.1"
cuda: "11.8"
# Oldest supported version, keep in sync with README.md
rustc: "1.75.0"
extra_args: --no-fail-fast
extra_desc: cuda11.1
extra_desc: cuda11.8
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: windows-2019
cuda: "11.8"
rustc: nightly
Expand All @@ -117,18 +139,21 @@ jobs:
cuda: "11.8"
rustc: beta
extra_desc: cuda11.8
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: windows-2022
cuda: "12.8"
# Oldest supported version, keep in sync with README.md
rustc: "1.75.0"
extra_args: --no-fail-fast
extra_desc: cuda12.8
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: windows-2022
cuda: "12.8"
rustc: nightly
allow_failure: true
extra_args: --features=unstable
extra_desc: cuda12.8
no_coverage: ${{ needs.checks.outputs.has-codecov-token != 'true' }}
- os: windows-2022
cuda: "12.8"
rustc: beta
Expand All @@ -141,6 +166,7 @@ jobs:
BINARY_DIR: "target/debug"
GRCOV_IGNORE_OPTION: '--ignore build.rs --ignore "/*" --ignore "[a-zA-Z]:/*"'
GRCOV_EXCLUDE_OPTION: '--excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()"'
SCCACHE_DEBUG: 1
steps:
- uses: ilammy/msvc-dev-cmd@v1

Expand Down Expand Up @@ -187,7 +213,6 @@ jobs:
echo '[env]
LLVM_PROFILE_FILE = { value = "target/debug/coverage/default-%p-%8m.profraw", relative = true }' >> .cargo/config.toml


- name: Execute tests
run: cargo test --locked --all-targets ${{ matrix.extra_args }}
env:
Expand Down Expand Up @@ -282,7 +307,7 @@ jobs:
if: ${{ !matrix.container }}

- name: Build
run: cargo build --locked --release --bin ${{ matrix.binary || 'sccache' }} --target ${{ matrix.target }} --features=openssl/vendored ${{ matrix.extra_args }}
run: cargo build --locked --release --bin ${{ matrix.binary || 'sccache' }} --target ${{ matrix.target }} --features=vendored-openssl ${{ matrix.extra_args }}
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
DEVELOPER_DIR: ${{ matrix.developer_dir }}
Expand Down Expand Up @@ -322,7 +347,7 @@ jobs:
mem: 8192
usesh: true
sync: rsync
copyback: false
copyback: true
prepare: pkg install -y ca_root_nss curl gmake gtar pot sudo
run: |
#####################################################################################
Expand Down
45 changes: 43 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ opendal = { version = "0.52.0", optional = true, default-features = false }
openssl = { version = "0.10.72", optional = true }
rand = "0.8.4"
regex = "1.10.3"
regex_static = "0.1.1"
reqsign = { version = "0.16.0", optional = true }
reqwest = { version = "0.12", features = [
"json",
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ pub trait CCompilerImpl: Clone + fmt::Debug + Send + Sync + 'static {
T: CommandCreatorSync;
/// Generate a command that can be used to invoke the C compiler to perform
/// the compilation.
#[allow(clippy::too_many_arguments)]
fn generate_compile_commands<T>(
&self,
path_transformer: &mut dist::PathTransformer,
Expand All @@ -208,6 +209,7 @@ pub trait CCompilerImpl: Clone + fmt::Debug + Send + Sync + 'static {
cwd: &Path,
env_vars: &[(OsString, OsString)],
rewrite_includes_only: bool,
hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand Down Expand Up @@ -1157,6 +1159,7 @@ impl<T: CommandCreatorSync, I: CCompilerImpl> Compilation<T> for CCompilation<I>
&self,
path_transformer: &mut dist::PathTransformer,
rewrite_includes_only: bool,
hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand All @@ -1178,6 +1181,7 @@ impl<T: CommandCreatorSync, I: CCompilerImpl> Compilation<T> for CCompilation<I>
cwd,
env_vars,
rewrite_includes_only,
hash_key,
)
}

Expand Down
75 changes: 31 additions & 44 deletions src/compiler/cicc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl CCompilerImpl for Cicc {
cwd: &Path,
env_vars: &[(OsString, OsString)],
_rewrite_includes_only: bool,
_hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand Down Expand Up @@ -118,7 +119,6 @@ where
let mut take_next = false;
let mut outputs = HashMap::new();
let mut extra_dist_files = vec![];
let mut gen_module_id_file = false;
let mut module_id_file_name = Option::<PathBuf>::None;

let mut common_args = vec![];
Expand All @@ -128,6 +128,20 @@ where
match arg {
Ok(arg) => {
let args = match arg.get_data() {
Some(ExtraOutput(o)) => {
take_next = false;
let path = cwd.join(o);
if let Some(flag) = arg.flag_str() {
outputs.insert(
flag,
ArtifactDescriptor {
path,
optional: false,
},
);
}
&mut common_args
}
Some(PassThrough(_)) => {
take_next = false;
&mut common_args
Expand All @@ -146,7 +160,6 @@ where
}
Some(GenModuleIdFileFlag) => {
take_next = false;
gen_module_id_file = true;
&mut common_args
}
Some(ModuleIdFileName(o)) => {
Expand All @@ -158,24 +171,6 @@ where
take_next = false;
&mut unhashed_args
}
Some(UnhashedOutput(o)) => {
take_next = false;
let path = cwd.join(o);
if let Some(flag) = arg.flag_str() {
outputs.insert(
flag,
ArtifactDescriptor {
path,
optional: false,
},
);
}
&mut unhashed_args
}
Some(UnhashedFlag) => {
take_next = false;
&mut unhashed_args
}
None => match arg {
Argument::Raw(ref p) => {
if take_next {
Expand All @@ -200,17 +195,16 @@ where
}

if let Some(module_id_path) = module_id_file_name {
if gen_module_id_file {
outputs.insert(
"--module_id_file_name",
ArtifactDescriptor {
path: module_id_path,
optional: true,
},
);
} else {
extra_dist_files.push(module_id_path);
if module_id_path.exists() {
extra_dist_files.push(module_id_path.clone());
}
outputs.insert(
"--module_id_file_name",
ArtifactDescriptor {
path: module_id_path,
optional: false,
},
);
}

CompilerArguments::Ok(ParsedArguments {
Expand All @@ -236,13 +230,7 @@ where
}

pub async fn preprocess(cwd: &Path, parsed_args: &ParsedArguments) -> Result<process::Output> {
// cicc and ptxas expect input to be an absolute path
let input = if parsed_args.input.is_absolute() {
parsed_args.input.clone()
} else {
cwd.join(&parsed_args.input)
};
std::fs::read(input)
std::fs::read(cwd.join(&parsed_args.input))
.map_err(anyhow::Error::new)
.map(|s| process::Output {
status: process::ExitStatus::default(),
Expand Down Expand Up @@ -329,23 +317,22 @@ pub fn generate_compile_commands(
}

ArgData! { pub
Output(PathBuf),
PassThrough(OsString),
UnhashedFlag,
ExtraOutput(PathBuf),
GenModuleIdFileFlag,
ModuleIdFileName(PathBuf),
Output(PathBuf),
PassThrough(OsString),
UnhashedPassThrough(OsString),
UnhashedOutput(PathBuf),
}

use self::ArgData::*;

counted_array!(pub static ARGS: [ArgInfo<ArgData>; _] = [
take_arg!("--gen_c_file_name", PathBuf, Separated, UnhashedOutput),
take_arg!("--gen_device_file_name", PathBuf, Separated, UnhashedOutput),
take_arg!("--gen_c_file_name", PathBuf, Separated, ExtraOutput),
take_arg!("--gen_device_file_name", PathBuf, Separated, ExtraOutput),
flag!("--gen_module_id_file", GenModuleIdFileFlag),
take_arg!("--include_file_name", OsString, Separated, PassThrough),
take_arg!("--module_id_file_name", PathBuf, Separated, ModuleIdFileName),
take_arg!("--stub_file_name", PathBuf, Separated, UnhashedOutput),
take_arg!("--stub_file_name", PathBuf, Separated, ExtraOutput),
take_arg!("-o", PathBuf, Separated, Output),
]);
Loading