MCPcopy Index your code
hub / github.com/RustPython/RustPython / compiler_fixup

Function compiler_fixup

Lib/_osx_support.py:358–435  ·  view source on GitHub ↗

This function will strip '-isysroot PATH' and '-arch ARCH' from the compile flags if the user has specified one them in extra_compile_flags. This is needed because '-arch ARCH' adds another architecture to the build, without a way to remove an architecture. Furthermore GCC will

(compiler_so, cc_args)

Source from the content-addressed store, hash-verified

356
357
358def compiler_fixup(compiler_so, cc_args):
359 """
360 This function will strip '-isysroot PATH' and '-arch ARCH' from the
361 compile flags if the user has specified one them in extra_compile_flags.
362
363 This is needed because '-arch ARCH' adds another architecture to the
364 build, without a way to remove an architecture. Furthermore GCC will
365 barf if multiple '-isysroot' arguments are present.
366 """
367 stripArch = stripSysroot = False
368
369 compiler_so = list(compiler_so)
370
371 if not _supports_universal_builds():
372 # OSX before 10.4.0, these don't support -arch and -isysroot at
373 # all.
374 stripArch = stripSysroot = True
375 else:
376 stripArch = '-arch' in cc_args
377 stripSysroot = any(arg for arg in cc_args if arg.startswith('-isysroot'))
378
379 if stripArch or 'ARCHFLAGS' in os.environ:
380 while True:
381 try:
382 index = compiler_so.index('-arch')
383 # Strip this argument and the next one:
384 del compiler_so[index:index+2]
385 except ValueError:
386 break
387
388 elif not _supports_arm64_builds():
389 # Look for "-arch arm64" and drop that
390 for idx in reversed(range(len(compiler_so))):
391 if compiler_so[idx] == '-arch' and compiler_so[idx+1] == "arm64":
392 del compiler_so[idx:idx+2]
393
394 if 'ARCHFLAGS' in os.environ and not stripArch:
395 # User specified different -arch flags in the environ,
396 # see also distutils.sysconfig
397 compiler_so = compiler_so + os.environ['ARCHFLAGS'].split()
398
399 if stripSysroot:
400 while True:
401 indices = [i for i,x in enumerate(compiler_so) if x.startswith('-isysroot')]
402 if not indices:
403 break
404 index = indices[0]
405 if compiler_so[index] == '-isysroot':
406 # Strip this argument and the next one:
407 del compiler_so[index:index+2]
408 else:
409 # It's '-isysroot/some/path' in one arg
410 del compiler_so[index:index+1]
411
412 # Check if the SDK that is used during compilation actually exists,
413 # the universal build requires the usage of a universal SDK and not all
414 # users have that installed by default.
415 sysroot = None

Callers

nothing calls this directly

Calls 13

listClass · 0.85
_supports_arm64_buildsFunction · 0.85
reversedFunction · 0.85
lenFunction · 0.85
enumerateFunction · 0.85
anyFunction · 0.70
startswithMethod · 0.45
indexMethod · 0.45
splitMethod · 0.45
isdirMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected