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