Second phase: configure and setup the compiler based on the specified settings and arguments.
(state)
| 412 | |
| 413 | @ToolchainProfiler.profile_block('setup') |
| 414 | def phase_setup(state): |
| 415 | """Second phase: configure and setup the compiler based on the specified settings and arguments.""" |
| 416 | has_header_inputs = any(get_file_suffix(f) in HEADER_EXTENSIONS for f in options.input_files) |
| 417 | |
| 418 | if options.post_link: |
| 419 | state.mode = Mode.POST_LINK_ONLY |
| 420 | elif has_header_inputs or options.dash_c or options.dash_S or options.syntax_only or options.dash_E or options.dash_M: |
| 421 | state.mode = Mode.COMPILE_ONLY |
| 422 | |
| 423 | if state.mode == Mode.COMPILE_ONLY: |
| 424 | for key in user_settings: |
| 425 | if key not in COMPILE_TIME_SETTINGS: |
| 426 | diagnostics.warning( |
| 427 | 'unused-command-line-argument', |
| 428 | "linker setting ignored during compilation: '%s'" % key) |
| 429 | for arg in state.orig_args: |
| 430 | if arg in LINK_ONLY_FLAGS: |
| 431 | diagnostics.warning( |
| 432 | 'unused-command-line-argument', |
| 433 | "linker flag ignored during compilation: '%s'" % arg) |
| 434 | |
| 435 | if 'USE_PTHREADS' in user_settings: |
| 436 | settings.PTHREADS = settings.USE_PTHREADS |
| 437 | |
| 438 | # Pthreads and Wasm Workers require targeting shared Wasm memory (SAB). |
| 439 | if settings.PTHREADS or settings.WASM_WORKERS: |
| 440 | settings.SHARED_MEMORY = 1 |
| 441 | |
| 442 | if 'DISABLE_EXCEPTION_CATCHING' in user_settings and 'EXCEPTION_CATCHING_ALLOWED' in user_settings: |
| 443 | # If we get here then the user specified both DISABLE_EXCEPTION_CATCHING and EXCEPTION_CATCHING_ALLOWED |
| 444 | # on the command line. This is no longer valid so report either an error or a warning (for |
| 445 | # backwards compat with the old `DISABLE_EXCEPTION_CATCHING=2` |
| 446 | if user_settings['DISABLE_EXCEPTION_CATCHING'] in {'0', '2'}: |
| 447 | diagnostics.warning('deprecated', 'DISABLE_EXCEPTION_CATCHING=X is no longer needed when specifying EXCEPTION_CATCHING_ALLOWED') |
| 448 | else: |
| 449 | exit_with_error('DISABLE_EXCEPTION_CATCHING and EXCEPTION_CATCHING_ALLOWED are mutually exclusive') |
| 450 | |
| 451 | if settings.EXCEPTION_CATCHING_ALLOWED: |
| 452 | settings.DISABLE_EXCEPTION_CATCHING = 0 |
| 453 | |
| 454 | if settings.WASM_EXCEPTIONS: |
| 455 | if user_settings.get('DISABLE_EXCEPTION_CATCHING') == '0': |
| 456 | exit_with_error('DISABLE_EXCEPTION_CATCHING=0 is not compatible with -fwasm-exceptions') |
| 457 | if user_settings.get('DISABLE_EXCEPTION_THROWING') == '0': |
| 458 | exit_with_error('DISABLE_EXCEPTION_THROWING=0 is not compatible with -fwasm-exceptions') |
| 459 | # -fwasm-exceptions takes care of enabling them, so users aren't supposed to |
| 460 | # pass them explicitly, regardless of their values |
| 461 | if 'DISABLE_EXCEPTION_CATCHING' in user_settings or 'DISABLE_EXCEPTION_THROWING' in user_settings: |
| 462 | diagnostics.warning('emcc', 'you no longer need to pass DISABLE_EXCEPTION_CATCHING or DISABLE_EXCEPTION_THROWING when using Wasm exceptions') |
| 463 | settings.DISABLE_EXCEPTION_CATCHING = 1 |
| 464 | settings.DISABLE_EXCEPTION_THROWING = 1 |
| 465 | |
| 466 | if user_settings.get('ASYNCIFY') == '1': |
| 467 | diagnostics.warning('emcc', 'ASYNCIFY=1 is not compatible with -fwasm-exceptions. Parts of the program that mix ASYNCIFY and exceptions will not compile.') |
| 468 | |
| 469 | if user_settings.get('SUPPORT_LONGJMP') == 'emscripten': |
| 470 | exit_with_error('SUPPORT_LONGJMP=emscripten is not compatible with -fwasm-exceptions') |
| 471 |
no test coverage detected