(user_args)
| 31 | |
| 32 | |
| 33 | def get_clang_flags(user_args): |
| 34 | flags = get_target_flags() |
| 35 | |
| 36 | # if exception catching is disabled, we can prevent that code from being |
| 37 | # generated in the frontend |
| 38 | if settings.DISABLE_EXCEPTION_CATCHING and not settings.WASM_EXCEPTIONS: |
| 39 | flags.append('-fignore-exceptions') |
| 40 | |
| 41 | if settings.INLINING_LIMIT: |
| 42 | flags.append('-fno-inline-functions') |
| 43 | |
| 44 | if settings.PTHREADS: |
| 45 | if '-pthread' not in user_args: |
| 46 | flags.append('-pthread') |
| 47 | elif settings.SHARED_MEMORY: |
| 48 | if '-matomics' not in user_args: |
| 49 | flags.append('-matomics') |
| 50 | if '-mbulk-memory' not in user_args: |
| 51 | flags.append('-mbulk-memory') |
| 52 | |
| 53 | if (settings.MAIN_MODULE or settings.SIDE_MODULE) and '-fPIC' not in user_args: |
| 54 | flags.append('-fPIC') |
| 55 | |
| 56 | if settings.MAIN_MODULE or settings.SIDE_MODULE or settings.LINKABLE or '-fPIC' in user_args: |
| 57 | if not any(a.startswith('-fvisibility') for a in user_args): |
| 58 | # For relocatable code we default to visibility=default in emscripten even |
| 59 | # though the upstream backend defaults visibility=hidden. This matches the |
| 60 | # expectations of C/C++ code in the wild which expects undecorated symbols |
| 61 | # to be exported to other DSO's by default. |
| 62 | flags.append('-fvisibility=default') |
| 63 | |
| 64 | if settings.LTO: |
| 65 | if not any(a.startswith('-flto') for a in user_args): |
| 66 | flags.append('-flto=' + settings.LTO) |
| 67 | # setjmp/longjmp handling using Wasm EH |
| 68 | # For non-LTO, '-mllvm -wasm-enable-eh' added in |
| 69 | # building.llvm_backend_args() sets this feature in clang. But in LTO, the |
| 70 | # argument is added to wasm-ld instead, so clang needs to know that EH is |
| 71 | # enabled so that it can be added to the attributes in LLVM IR. |
| 72 | if settings.SUPPORT_LONGJMP == 'wasm': |
| 73 | flags.append('-mexception-handling') |
| 74 | |
| 75 | else: |
| 76 | # In LTO mode these args get passed instead at link time when the backend runs. |
| 77 | for a in building.llvm_backend_args(): |
| 78 | flags += ['-mllvm', a] |
| 79 | |
| 80 | return flags |
| 81 | |
| 82 | |
| 83 | @memoize |
no test coverage detected