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

Function get_cflags

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

Source from the content-addressed store, hash-verified

82
83@memoize
84def get_cflags(user_args):
85 # Flags we pass to the compiler when building C/C++ code
86 # We add these to the user's flags (newargs), but not when building .s or .S assembly files
87 cflags = get_clang_flags(user_args)
88 cflags.append('--sysroot=' + cache.get_sysroot(absolute=True))
89
90 if settings.EMSCRIPTEN_TRACING:
91 cflags.append('-D__EMSCRIPTEN_TRACING__=1')
92
93 if settings.SHARED_MEMORY:
94 cflags.append('-D__EMSCRIPTEN_SHARED_MEMORY__=1')
95
96 if settings.WASM_WORKERS:
97 cflags.append('-D__EMSCRIPTEN_WASM_WORKERS__=1')
98
99 ports.add_cflags(cflags, settings)
100
101 # The rest of this function does a bunch of membership testing on user_args
102 user_args = set(user_args)
103
104 def user_args_contains_any(args):
105 return any(a in user_args for a in args)
106
107 if user_args_contains_any(SIMD_INTEL_FEATURE_TOWER) or user_args_contains_any(SIMD_NEON_FLAGS):
108 if '-msimd128' not in user_args and '-mrelaxed-simd' not in user_args:
109 utils.exit_with_error('passing any of ' + ', '.join(SIMD_INTEL_FEATURE_TOWER + SIMD_NEON_FLAGS) + ' flags also requires passing -msimd128 (or -mrelaxed-simd)!')
110 cflags += ['-D__SSE__=1']
111
112 if user_args_contains_any(SIMD_INTEL_FEATURE_TOWER[1:]):
113 cflags += ['-D__SSE2__=1']
114
115 if user_args_contains_any(SIMD_INTEL_FEATURE_TOWER[2:]):
116 cflags += ['-D__SSE3__=1']
117
118 if user_args_contains_any(SIMD_INTEL_FEATURE_TOWER[3:]):
119 cflags += ['-D__SSSE3__=1']
120
121 if user_args_contains_any(SIMD_INTEL_FEATURE_TOWER[4:]):
122 cflags += ['-D__SSE4_1__=1']
123
124 # Handle both -msse4.2 and its alias -msse4.
125 if user_args_contains_any(SIMD_INTEL_FEATURE_TOWER[5:]):
126 cflags += ['-D__SSE4_2__=1']
127
128 if user_args_contains_any(SIMD_INTEL_FEATURE_TOWER[7:]):
129 cflags += ['-D__AVX__=1']
130
131 if user_args_contains_any(SIMD_INTEL_FEATURE_TOWER[8:]):
132 cflags += ['-D__AVX2__=1']
133
134 if user_args_contains_any(SIMD_NEON_FLAGS):
135 cflags += ['-D__ARM_NEON__=1']
136
137 if '-nostdinc' not in user_args:
138 if not settings.USE_SDL:
139 cflags += ['-Xclang', '-iwithsysroot' + os.path.join('/include', 'fakesdl')]
140 cflags += ['-Xclang', '-iwithsysroot' + os.path.join('/include', 'compat')]
141

Callers

nothing calls this directly

Calls 5

get_clang_flagsFunction · 0.85
user_args_contains_anyFunction · 0.85
appendMethod · 0.80
setFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected