Skip to content

Commit 91defd7

Browse files
aphedgestjruwasejeffra
authored
Prevent creation of local temp directory (#1494)
Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com> Co-authored-by: Jeff Rasley <jerasley@microsoft.com>
1 parent df5b088 commit 91defd7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

op_builder/builder.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,16 @@ def has_function(self, funcname, libraries, verbose=False):
210210
oldstderr = os.dup(sys.stderr.fileno())
211211
os.dup2(filestderr.fileno(), sys.stderr.fileno())
212212

213+
# Workaround for behavior in distutils.ccompiler.CCompiler.object_filenames()
214+
# Otherwise, a local directory will be used instead of tempdir
215+
drive, driveless_filename = os.path.splitdrive(filename)
216+
root_dir = driveless_filename[0] if os.path.isabs(driveless_filename) else ''
217+
output_dir = os.path.join(drive, root_dir)
218+
213219
# Attempt to compile the C program into an object file.
214220
cflags = shlex.split(os.environ.get('CFLAGS', ""))
215221
objs = compiler.compile([filename],
222+
output_dir=output_dir,
216223
extra_preargs=self.strip_empty_entries(cflags))
217224

218225
# Attempt to link the object file into an executable.

0 commit comments

Comments
 (0)