@@ -732,11 +732,19 @@ struct AdditionalStats {
732
732
cache_misses : Option < Vec < ( CCompilerKind , Language , u64 ) > > ,
733
733
}
734
734
735
- fn test_nvcc_cuda_compiles ( client : & SccacheClient , compiler : & Compiler , tempdir : & Path ) {
735
+ fn test_nvcc_cuda_compiles (
736
+ client : & SccacheClient ,
737
+ compiler : & Compiler ,
738
+ tempdir : & Path ,
739
+ with_debug_flags : bool ,
740
+ ) {
736
741
let mut stats = client. stats ( ) . unwrap ( ) ;
737
742
738
- let extra_args = vec ! [ ] ;
739
- let with_debug_flags = false ;
743
+ let extra_args = if with_debug_flags {
744
+ vec ! [ "-G" . into( ) ]
745
+ } else {
746
+ vec ! [ ]
747
+ } ;
740
748
741
749
let Compiler {
742
750
name,
@@ -1406,10 +1414,15 @@ fn test_nvcc_proper_lang_stat_tracking(
1406
1414
client : & SccacheClient ,
1407
1415
compiler : & Compiler ,
1408
1416
tempdir : & Path ,
1417
+ with_debug_flags : bool ,
1409
1418
) {
1410
1419
let mut stats = client. stats ( ) . unwrap ( ) ;
1411
1420
1412
- let extra_args = vec ! [ ] ;
1421
+ let extra_args = if with_debug_flags {
1422
+ vec ! [ "-G" . into( ) ]
1423
+ } else {
1424
+ vec ! [ ]
1425
+ } ;
1413
1426
1414
1427
let Compiler {
1415
1428
name,
@@ -1576,15 +1589,29 @@ fn test_nvcc_proper_lang_stat_tracking(
1576
1589
) ;
1577
1590
}
1578
1591
1579
- fn run_sccache_nvcc_cuda_command_tests ( client : & SccacheClient , compiler : Compiler , tempdir : & Path ) {
1580
- test_nvcc_cuda_compiles ( client, & compiler, tempdir) ;
1581
- test_nvcc_proper_lang_stat_tracking ( client, & compiler, tempdir) ;
1592
+ fn run_sccache_nvcc_cuda_command_tests (
1593
+ client : & SccacheClient ,
1594
+ compiler : Compiler ,
1595
+ tempdir : & Path ,
1596
+ with_debug_flags : bool ,
1597
+ ) {
1598
+ test_nvcc_cuda_compiles ( client, & compiler, tempdir, with_debug_flags) ;
1599
+ test_nvcc_proper_lang_stat_tracking ( client, & compiler, tempdir, with_debug_flags) ;
1582
1600
}
1583
1601
1584
- fn test_clang_cuda_compiles ( client : & SccacheClient , compiler : & Compiler , tempdir : & Path ) {
1602
+ fn test_clang_cuda_compiles (
1603
+ client : & SccacheClient ,
1604
+ compiler : & Compiler ,
1605
+ tempdir : & Path ,
1606
+ with_debug_flags : bool ,
1607
+ ) {
1585
1608
let mut stats = client. stats ( ) . unwrap ( ) ;
1586
1609
1587
- let extra_args = vec ! [ ] ;
1610
+ let extra_args = if with_debug_flags {
1611
+ vec ! [ "-g" . into( ) , "--cuda-noopt-device-debug" . into( ) ]
1612
+ } else {
1613
+ vec ! [ ]
1614
+ } ;
1588
1615
1589
1616
let Compiler {
1590
1617
name,
@@ -1703,9 +1730,16 @@ fn test_clang_proper_lang_stat_tracking(
1703
1730
client : & SccacheClient ,
1704
1731
compiler : & Compiler ,
1705
1732
tempdir : & Path ,
1733
+ with_debug_flags : bool ,
1706
1734
) {
1707
1735
let mut stats = client. stats ( ) . unwrap ( ) ;
1708
1736
1737
+ let extra_args = if with_debug_flags {
1738
+ vec ! [ "-g" . into( ) , "--cuda-noopt-device-debug" . into( ) ]
1739
+ } else {
1740
+ vec ! [ ]
1741
+ } ;
1742
+
1709
1743
let Compiler {
1710
1744
name,
1711
1745
exe,
@@ -1726,7 +1760,7 @@ fn test_clang_proper_lang_stat_tracking(
1726
1760
"-c" ,
1727
1761
INPUT_FOR_CUDA_C ,
1728
1762
OUTPUT ,
1729
- & [ ] ,
1763
+ & extra_args ,
1730
1764
) )
1731
1765
. current_dir ( tempdir)
1732
1766
. envs ( env_vars. clone ( ) )
@@ -1759,7 +1793,7 @@ fn test_clang_proper_lang_stat_tracking(
1759
1793
"-c" ,
1760
1794
INPUT_FOR_CUDA_C ,
1761
1795
OUTPUT ,
1762
- & [ ] ,
1796
+ & extra_args ,
1763
1797
) )
1764
1798
. current_dir ( tempdir)
1765
1799
. envs ( env_vars. clone ( ) )
@@ -1784,7 +1818,13 @@ fn test_clang_proper_lang_stat_tracking(
1784
1818
trace ! ( "compile C++ A" ) ;
1785
1819
client
1786
1820
. cmd ( )
1787
- . args ( compile_cmdline ( name, exe, INPUT , OUTPUT , Vec :: new ( ) ) )
1821
+ . args ( compile_cmdline (
1822
+ name,
1823
+ exe,
1824
+ INPUT ,
1825
+ OUTPUT ,
1826
+ extra_args. clone ( ) ,
1827
+ ) )
1788
1828
. current_dir ( tempdir)
1789
1829
. envs ( env_vars. clone ( ) )
1790
1830
. assert ( )
@@ -1810,7 +1850,13 @@ fn test_clang_proper_lang_stat_tracking(
1810
1850
trace ! ( "compile C++ A" ) ;
1811
1851
client
1812
1852
. cmd ( )
1813
- . args ( compile_cmdline ( name, exe, INPUT , OUTPUT , Vec :: new ( ) ) )
1853
+ . args ( compile_cmdline (
1854
+ name,
1855
+ exe,
1856
+ INPUT ,
1857
+ OUTPUT ,
1858
+ extra_args. clone ( ) ,
1859
+ ) )
1814
1860
. current_dir ( tempdir)
1815
1861
. envs ( env_vars. clone ( ) )
1816
1862
. assert ( )
@@ -1836,9 +1882,10 @@ fn run_sccache_clang_cuda_command_tests(
1836
1882
client : & SccacheClient ,
1837
1883
compiler : Compiler ,
1838
1884
tempdir : & Path ,
1885
+ with_debug_flags : bool ,
1839
1886
) {
1840
- test_clang_cuda_compiles ( client, & compiler, tempdir) ;
1841
- test_clang_proper_lang_stat_tracking ( client, & compiler, tempdir) ;
1887
+ test_clang_cuda_compiles ( client, & compiler, tempdir, with_debug_flags ) ;
1888
+ test_clang_proper_lang_stat_tracking ( client, & compiler, tempdir, with_debug_flags ) ;
1842
1889
}
1843
1890
1844
1891
fn test_hip_compiles ( client : & SccacheClient , compiler : & Compiler , tempdir : & Path ) {
@@ -2303,10 +2350,12 @@ fn test_stats_no_server() {
2303
2350
) ;
2304
2351
}
2305
2352
2306
- #[ test_case( true ; "with preprocessor cache" ) ]
2307
- #[ test_case( false ; "without preprocessor cache" ) ]
2353
+ #[ test_case( true , false ; "preprocessor_cache=true, device_debug=false" ) ]
2354
+ #[ test_case( false , false ; "preprocessor_cache=false, device_debug=false" ) ]
2355
+ #[ test_case( true , true ; "preprocessor_cache=true, device_debug=true" ) ]
2356
+ #[ test_case( false , true ; "preprocessor_cache=false, device_debug=true" ) ]
2308
2357
#[ cfg( any( unix, target_env = "msvc" ) ) ]
2309
- fn test_cuda_sccache_command ( preprocessor_cache_mode : bool ) {
2358
+ fn test_cuda_sccache_command ( preprocessor_cache_mode : bool , with_debug_flags : bool ) {
2310
2359
let _ = env_logger:: try_init ( ) ;
2311
2360
let compilers = find_cuda_compilers ( ) ;
2312
2361
println ! (
@@ -2325,8 +2374,18 @@ fn test_cuda_sccache_command(preprocessor_cache_mode: bool) {
2325
2374
2326
2375
for compiler in compilers {
2327
2376
match compiler. name {
2328
- "nvcc" => run_sccache_nvcc_cuda_command_tests ( & client, compiler, & tempdir_path) ,
2329
- "clang++" => run_sccache_clang_cuda_command_tests ( & client, compiler, & tempdir_path) ,
2377
+ "nvcc" => run_sccache_nvcc_cuda_command_tests (
2378
+ & client,
2379
+ compiler,
2380
+ & tempdir_path,
2381
+ with_debug_flags,
2382
+ ) ,
2383
+ "clang++" => run_sccache_clang_cuda_command_tests (
2384
+ & client,
2385
+ compiler,
2386
+ & tempdir_path,
2387
+ with_debug_flags,
2388
+ ) ,
2330
2389
_ => { }
2331
2390
}
2332
2391
}
0 commit comments