Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Side by Side Diff: Lib/distutils/unixccompiler.py

Issue 3871: cross and native build of python for mingw32 with distutils
Patch Set: Created 7 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/distutils/tests/test_cygwinccompiler.py ('k') | Lib/plat-generic/regen » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """distutils.unixccompiler 1 """distutils.unixccompiler
2 2
3 Contains the UnixCCompiler class, a subclass of CCompiler that handles 3 Contains the UnixCCompiler class, a subclass of CCompiler that handles
4 the "typical" Unix-style command-line C compiler: 4 the "typical" Unix-style command-line C compiler:
5 * macros defined with -Dname[=value] 5 * macros defined with -Dname[=value]
6 * macros undefined with -Uname 6 * macros undefined with -Uname
7 * include search directories specified with -Idir 7 * include search directories specified with -Idir
8 * libraries specified with -lllib 8 * libraries specified with -lllib
9 * library search directories specified with -Ldir 9 * library search directories specified with -Ldir
10 * compile handled by 'cc' (or similar) executable with -c option: 10 * compile handled by 'cc' (or similar) executable with -c option:
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 library_dirs=None, runtime_library_dirs=None, 148 library_dirs=None, runtime_library_dirs=None,
149 export_symbols=None, debug=0, extra_preargs=None, 149 export_symbols=None, debug=0, extra_preargs=None,
150 extra_postargs=None, build_temp=None, target_lang=None): 150 extra_postargs=None, build_temp=None, target_lang=None):
151 objects, output_dir = self._fix_object_args(objects, output_dir) 151 objects, output_dir = self._fix_object_args(objects, output_dir)
152 fixed_args = self._fix_lib_args(libraries, library_dirs, 152 fixed_args = self._fix_lib_args(libraries, library_dirs,
153 runtime_library_dirs) 153 runtime_library_dirs)
154 libraries, library_dirs, runtime_library_dirs = fixed_args 154 libraries, library_dirs, runtime_library_dirs = fixed_args
155 155
156 lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, 156 lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
157 libraries) 157 libraries)
158
159 lib_opts.append('-L.')
160
158 if not isinstance(output_dir, (str, type(None))): 161 if not isinstance(output_dir, (str, type(None))):
159 raise TypeError("'output_dir' must be a string or None") 162 raise TypeError("'output_dir' must be a string or None")
160 if output_dir is not None: 163 if output_dir is not None:
161 output_filename = os.path.join(output_dir, output_filename) 164 output_filename = os.path.join(output_dir, output_filename)
162 165
163 if self._need_link(objects, output_filename): 166 if self._need_link(objects, output_filename):
164 ld_args = (objects + self.objects + 167 ld_args = (objects + self.objects +
165 lib_opts + ['-o', output_filename]) 168 lib_opts + ['-o', output_filename])
166 if debug: 169 if debug:
167 ld_args[:0] = ['-g'] 170 ld_args[:0] = ['-g']
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 return ["+s", "-L" + dir] 234 return ["+s", "-L" + dir]
232 elif sys.platform[:7] == "irix646" or sys.platform[:6] == "osf1V5": 235 elif sys.platform[:7] == "irix646" or sys.platform[:6] == "osf1V5":
233 return ["-rpath", dir] 236 return ["-rpath", dir]
234 else: 237 else:
235 if self._is_gcc(compiler): 238 if self._is_gcc(compiler):
236 # gcc on non-GNU systems does not need -Wl, but can 239 # gcc on non-GNU systems does not need -Wl, but can
237 # use it anyway. Since distutils has always passed in 240 # use it anyway. Since distutils has always passed in
238 # -Wl whenever gcc was used in the past it is probably 241 # -Wl whenever gcc was used in the past it is probably
239 # safest to keep doing so. 242 # safest to keep doing so.
240 if sysconfig.get_config_var("GNULD") == "yes": 243 if sysconfig.get_config_var("GNULD") == "yes":
241 # GNU ld needs an extra option to get a RUNPATH 244 # GNU ELF ld needs an extra option to get a RUNPATH
242 # instead of just an RPATH. 245 # instead of just an RPATH.
243 return "-Wl,--enable-new-dtags,-R" + dir 246 if sys.platform in ["win32", "cygwin"] or \
247 "mingw" in compiler:
248 return []
249 else:
250 return "-Wl,--enable-new-dtags,-R" + dir
244 else: 251 else:
245 return "-Wl,-R" + dir 252 return "-Wl,-R" + dir
246 else: 253 else:
247 # No idea how --enable-new-dtags would be passed on to 254 # No idea how --enable-new-dtags would be passed on to
248 # ld if this system was using GNU ld. Don't know if a 255 # ld if this system was using GNU ld. Don't know if a
249 # system like this even exists. 256 # system like this even exists.
250 return "-R" + dir 257 return "-R" + dir
251 258
252 def library_option(self, lib): 259 def library_option(self, lib):
253 return "-l" + lib 260 return "-l" + lib
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 # ignoring even GCC's "-static" option. So sue me. 296 # ignoring even GCC's "-static" option. So sue me.
290 if os.path.exists(dylib): 297 if os.path.exists(dylib):
291 return dylib 298 return dylib
292 elif os.path.exists(shared): 299 elif os.path.exists(shared):
293 return shared 300 return shared
294 elif os.path.exists(static): 301 elif os.path.exists(static):
295 return static 302 return static
296 303
297 # Oops, didn't find it in *any* of 'dirs' 304 # Oops, didn't find it in *any* of 'dirs'
298 return None 305 return None
OLDNEW
« no previous file with comments | « Lib/distutils/tests/test_cygwinccompiler.py ('k') | Lib/plat-generic/regen » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+