Skip to content

Commit

Permalink
Prevent creation of local temp directory (#1494)
Browse files Browse the repository at this point in the history
Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com>
Co-authored-by: Jeff Rasley <jerasley@microsoft.com>
  • Loading branch information
3 people authored Nov 2, 2021
1 parent df5b088 commit 91defd7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions op_builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,16 @@ def has_function(self, funcname, libraries, verbose=False):
oldstderr = os.dup(sys.stderr.fileno())
os.dup2(filestderr.fileno(), sys.stderr.fileno())

# Workaround for behavior in distutils.ccompiler.CCompiler.object_filenames()
# Otherwise, a local directory will be used instead of tempdir
drive, driveless_filename = os.path.splitdrive(filename)
root_dir = driveless_filename[0] if os.path.isabs(driveless_filename) else ''
output_dir = os.path.join(drive, root_dir)

# Attempt to compile the C program into an object file.
cflags = shlex.split(os.environ.get('CFLAGS', ""))
objs = compiler.compile([filename],
output_dir=output_dir,
extra_preargs=self.strip_empty_entries(cflags))

# Attempt to link the object file into an executable.
Expand Down

0 comments on commit 91defd7

Please sign in to comment.