@@ -79,6 +79,8 @@ gnu_linker_flags = {
79
79
'workarounds' : []
80
80
}
81
81
82
+ nv_linker_flags = gnu_linker_flags
83
+
82
84
clang_linker_flags = {
83
85
'debug' : [],
84
86
'release' : [],
@@ -88,12 +90,13 @@ clang_linker_flags = {
88
90
msvc_linker_flags = {
89
91
'debug' : ['/debug' ],
90
92
'release' : [],
91
- 'workarounds' : []
93
+ 'workarounds' : ['/nologo' ]
92
94
}
93
95
94
96
linker_to_flags = {
95
97
'gcc' : gnu_linker_flags ,
96
98
'link' : msvc_linker_flags ,
99
+ 'nvcc' : nv_linker_flags ,
97
100
'clang++' : clang_linker_flags
98
101
}
99
102
@@ -248,7 +251,7 @@ def libs(env, CCX, host_backend, device_backend):
248
251
return result
249
252
250
253
251
- def linker_flags (LINK , mode , platform , device_backend ):
254
+ def linker_flags (LINK , mode , platform , device_backend , arch ):
252
255
"""Returns a list of command line flags needed by the linker"""
253
256
result = []
254
257
@@ -324,6 +327,7 @@ def nv_compiler_flags(mode, device_backend, arch, cdp):
324
327
# the weird -gencode flag is formatted like this:
325
328
# -gencode=arch=compute_10,code=\"sm_20,compute_20\"
326
329
result .append ('-gencode=arch={0},\\ "code={1},{2}\\ "' .format (virtual_arch , machine_arch , virtual_arch ))
330
+
327
331
if mode == 'debug' :
328
332
# turn on debug mode
329
333
# XXX make this work when we've debugged nvcc -G
@@ -435,16 +439,25 @@ for (host,device) in itertools.product(host_backends, device_backends):
435
439
436
440
env .Append (NVCCFLAGS = nv_compiler_flags (env ['mode' ], device , env ['arch' ], env ['cdp' ]))
437
441
438
- env .Append (LINKFLAGS = linker_flags (env .subst ('$LINK' ), env ['mode' ], env ['PLATFORM' ], device ))
439
-
440
- env .Append (LIBPATH = lib_paths (env , host , device ))
441
-
442
442
env .Append (LIBS = libs (env , env .subst ('$CXX' ), host , device ))
443
443
444
444
# XXX this probably doesn't belong here
445
+ # XXX ideally we'd integrate this into site_scons
445
446
if 'cudadevrt' in env ['LIBS' ]:
446
447
# nvcc is required to link against cudadevrt
447
448
env .Replace (LINK = 'nvcc' )
449
+
450
+ if os .name == 'nt' :
451
+ # the nv linker uses the same command line as the gnu linker
452
+ env ['LIBDIRPREFIX' ] = '-L'
453
+ env ['LIBLINKPREFIX' ] = '-l'
454
+ env ['LIBLINKSUFFIX' ] = ''
455
+ env .Replace (LINKCOM = '$LINK -o $TARGET $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' )
456
+
457
+ # we Replace instead of Append, to avoid picking-up MSVC-specific flags on Windows
458
+ env .Replace (LINKFLAGS = linker_flags (env .subst ('$LINK' ), env ['mode' ], env ['PLATFORM' ], device , env ['arch' ]))
459
+
460
+ env .Append (LIBPATH = lib_paths (env , host , device ))
448
461
449
462
# assemble the name of this configuration's targets directory
450
463
targets_dir = 'targets/{0}_host_{1}_device_{2}' .format (host , device , env ['mode' ])
0 commit comments