From e19fc817312a0a053f0c23aaffffcd068df0f113 Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Tue, 31 Dec 2019 20:46:36 +0100 Subject: [PATCH] Add /d1trimfile:%SRC_DIR% to make pdbs more relocatable Co-authored-by: Uwe L. Korn --- setuptools/_distutils/compilers/C/msvc.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/setuptools/_distutils/compilers/C/msvc.py b/setuptools/_distutils/compilers/C/msvc.py index 795a47f..a44a370 100644 --- a/setuptools/_distutils/compilers/C/msvc.py +++ b/setuptools/_distutils/compilers/C/msvc.py @@ -407,6 +407,14 @@ class Compiler(base.Compiler): # without asking the user to browse for it src = os.path.abspath(src) + # Anaconda/conda-forge customisation, we want our pdbs to be + # relocatable: + # https://developercommunity.visualstudio.com/comments/623156/view.html + d1trimfile_opts = [] + if 'SRC_DIR' in os.environ and os.path.basename(self.cc) == "cl.exe": + d1trimfile_opts.append("/d1trimfile:" + os.environ['SRC_DIR']) + + if ext in self._c_extensions: input_opt = f"/Tc{src}" elif ext in self._cpp_extensions: @@ -450,7 +458,7 @@ class Compiler(base.Compiler): # how to handle this file? raise CompileError(f"Don't know how to compile {src} to {obj}") - args = [self.cc] + compile_opts + pp_opts + args = [self.cc] + compile_opts + pp_opts + d1trimfile_opts if add_cpp_opts: args.append('/EHsc') args.extend((input_opt, "/Fo" + obj)) -- 2.39.5 (Apple Git-154)