173
173
lit_config .note ("\t Unset " + var )
174
174
llvm_config .with_environment (var , "" )
175
175
176
+
177
+ # Temporarily modify environment to be the same that we use when running tests
178
+ class test_env :
179
+ def __enter__ (self ):
180
+ self .old_environ = dict (os .environ )
181
+ os .environ .clear ()
182
+ os .environ .update (config .environment )
183
+
184
+ def __exit__ (self , exc_type , exc_value , exc_traceback ):
185
+ os .environ .clear ()
186
+ os .environ .update (self .old_environ )
187
+
188
+
176
189
config .substitutions .append (("%sycl_libs_dir" , config .sycl_libs_dir ))
177
190
if platform .system () == "Windows" :
178
191
config .substitutions .append (
@@ -263,10 +276,11 @@ def open_check_file(file_name):
263
276
264
277
# check if compiler supports CL command line options
265
278
cl_options = False
266
- sp = subprocess .getstatusoutput (config .dpcpp_compiler + " /help" )
267
- if sp [0 ] == 0 :
268
- cl_options = True
269
- config .available_features .add ("cl_options" )
279
+ with test_env ():
280
+ sp = subprocess .getstatusoutput (config .dpcpp_compiler + " /help" )
281
+ if sp [0 ] == 0 :
282
+ cl_options = True
283
+ config .available_features .add ("cl_options" )
270
284
271
285
# check if the compiler was built in NDEBUG configuration
272
286
has_ndebug = False
@@ -321,14 +335,15 @@ def open_check_file(file_name):
321
335
322
336
config .substitutions .append (("%level_zero_options" , level_zero_options ))
323
337
324
- sp = subprocess .getstatusoutput (
325
- config .dpcpp_compiler + " -fsycl " + check_l0_file + level_zero_options
326
- )
327
- if sp [0 ] == 0 :
328
- config .available_features .add ("level_zero_dev_kit" )
329
- config .substitutions .append (("%level_zero_options" , level_zero_options ))
330
- else :
331
- config .substitutions .append (("%level_zero_options" , "" ))
338
+ with test_env ():
339
+ sp = subprocess .getstatusoutput (
340
+ config .dpcpp_compiler + " -fsycl " + check_l0_file + level_zero_options
341
+ )
342
+ if sp [0 ] == 0 :
343
+ config .available_features .add ("level_zero_dev_kit" )
344
+ config .substitutions .append (("%level_zero_options" , level_zero_options ))
345
+ else :
346
+ config .substitutions .append (("%level_zero_options" , "" ))
332
347
333
348
if lit_config .params .get ("test-preview-mode" , False ):
334
349
config .available_features .add ("preview-mode" )
@@ -349,13 +364,14 @@ def open_check_file(file_name):
349
364
file = fp ,
350
365
)
351
366
352
- sp = subprocess .getstatusoutput (
353
- config .dpcpp_compiler
354
- + " -fsycl -fpreview-breaking-changes "
355
- + check_preview_breaking_changes_file
356
- )
357
- if sp [0 ] == 0 :
358
- config .available_features .add ("preview-breaking-changes-supported" )
367
+ with test_env ():
368
+ sp = subprocess .getstatusoutput (
369
+ config .dpcpp_compiler
370
+ + " -fsycl -fpreview-breaking-changes "
371
+ + check_preview_breaking_changes_file
372
+ )
373
+ if sp [0 ] == 0 :
374
+ config .available_features .add ("preview-breaking-changes-supported" )
359
375
360
376
# Check if clang is built with ZSTD and compression support.
361
377
fPIC_opt = "-fPIC" if platform .system () != "Windows" else ""
@@ -418,14 +434,15 @@ def open_check_file(file_name):
418
434
419
435
config .substitutions .append (("%cuda_options" , cuda_options ))
420
436
421
- sp = subprocess .getstatusoutput (
422
- config .dpcpp_compiler + " -fsycl " + check_cuda_file + cuda_options
423
- )
424
- if sp [0 ] == 0 :
425
- config .available_features .add ("cuda_dev_kit" )
426
- config .substitutions .append (("%cuda_options" , cuda_options ))
427
- else :
428
- config .substitutions .append (("%cuda_options" , "" ))
437
+ with test_env ():
438
+ sp = subprocess .getstatusoutput (
439
+ config .dpcpp_compiler + " -fsycl " + check_cuda_file + cuda_options
440
+ )
441
+ if sp [0 ] == 0 :
442
+ config .available_features .add ("cuda_dev_kit" )
443
+ config .substitutions .append (("%cuda_options" , cuda_options ))
444
+ else :
445
+ config .substitutions .append (("%cuda_options" , "" ))
429
446
430
447
# Check for OpenCL ICD
431
448
if config .opencl_libs_dir :
0 commit comments