|
11 | 11 | import _opcode |
12 | 12 | import os |
13 | 13 | import re |
| 14 | +import shlex |
14 | 15 | import stat |
15 | 16 | import sys |
16 | 17 | import sysconfig |
@@ -469,27 +470,39 @@ def check_sanitizer(*, address=False, hwaddress=False, memory=False, ub=False, |
469 | 470 |
|
470 | 471 |
|
471 | 472 | cflags = sysconfig.get_config_var('CFLAGS') or '' |
472 | | - config_args = sysconfig.get_config_var('CONFIG_ARGS') or '' |
| 473 | + config_args = shlex.split(sysconfig.get_config_var('CONFIG_ARGS') or '') |
| 474 | + |
| 475 | + def configured_with_sanitizer(name): |
| 476 | + with_option = f'--with-{name}-sanitizer' |
| 477 | + without_option = f'--without-{name}-sanitizer' |
| 478 | + enabled = False |
| 479 | + for arg in config_args: |
| 480 | + if arg == without_option or arg == f'{with_option}=no': |
| 481 | + enabled = False |
| 482 | + elif arg == with_option or arg.startswith(f'{with_option}='): |
| 483 | + enabled = True |
| 484 | + return enabled |
| 485 | + |
473 | 486 | memory_sanitizer = ( |
474 | 487 | '-fsanitize=memory' in cflags or |
475 | | - '--with-memory-sanitizer' in config_args |
| 488 | + configured_with_sanitizer('memory') |
476 | 489 | ) |
477 | 490 | hwaddress_sanitizer = ( |
478 | 491 | '-fsanitize=hwaddress' in cflags or |
479 | | - '--with-hwaddress-sanitizer' in config_args |
| 492 | + configured_with_sanitizer('hwaddress') |
480 | 493 | ) |
481 | 494 | address_sanitizer = ( |
482 | 495 | '-fsanitize=address' in cflags or |
483 | | - '--with-address-sanitizer' in config_args or |
| 496 | + configured_with_sanitizer('address') or |
484 | 497 | hwaddress_sanitizer |
485 | 498 | ) |
486 | 499 | ub_sanitizer = ( |
487 | 500 | '-fsanitize=undefined' in cflags or |
488 | | - '--with-undefined-behavior-sanitizer' in config_args |
| 501 | + configured_with_sanitizer('undefined-behavior') |
489 | 502 | ) |
490 | 503 | thread_sanitizer = ( |
491 | 504 | '-fsanitize=thread' in cflags or |
492 | | - '--with-thread-sanitizer' in config_args |
| 505 | + configured_with_sanitizer('thread') |
493 | 506 | ) |
494 | 507 | function_sanitizer = ( |
495 | 508 | '-fsanitize=function' in cflags |
|
0 commit comments