MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / get_clang_flags

Function get_clang_flags

tools/compile.py:33–80  ·  view source on GitHub ↗
(user_args)

Source from the content-addressed store, hash-verified

31
32
33def 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

Callers 1

get_cflagsFunction · 0.85

Calls 2

get_target_flagsFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected