Skip to content

Commit 685c627

Browse files
committed
Don't build embind as a library
This is partial revert of #8817. It turns out that all users of bind.h have to agree on -fno-rtti. In particular if a user passed -fno-rtti to build their code the bind.cpp needs to be compiled with the same settings. Perhaps we can find a way to avoid this in the future but for now it looks like we are stuck compiling bind.cpp on demand at link time. Fixes: #9122
1 parent 7f9e788 commit 685c627

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

emcc.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
C_ENDINGS = C_ENDINGS + SPECIAL_ENDINGLESS_FILENAMES # consider the special endingless filenames like /dev/null to be C
6666

6767
JS_CONTAINING_ENDINGS = ('.js', '.mjs', '.html')
68+
EXECUTABLE_ENDINGS = JS_CONTAINING_ENDINGS + ('.wasm',)
6869
BITCODE_ENDINGS = ('.bc', '.o', '.obj', '.lo')
6970
DYNAMICLIB_ENDINGS = ('.dylib', '.so') # Windows .dll suffix is not included in this list, since those are never linked to directly on the command line.
7071
STATICLIB_ENDINGS = ('.a',)
@@ -1080,6 +1081,13 @@ def check(input_file):
10801081
# Note the exports the user requested
10811082
shared.Building.user_requested_exports = shared.Settings.EXPORTED_FUNCTIONS[:]
10821083

1084+
compile_only = has_dash_c or has_dash_S or final_suffix not in EXECUTABLE_ENDINGS
1085+
1086+
# If we are using embind and linking, now is the time to link in bind.cpp
1087+
if shared.Settings.EMBIND and not compile_only:
1088+
input_files.append((next_arg_index, shared.path_from_root('system', 'lib', 'embind', 'bind.cpp')))
1089+
next_arg_index += 1
1090+
10831091
# -s ASSERTIONS=1 implies the heaviest stack overflow check mode. Set the implication here explicitly to avoid having to
10841092
# do preprocessor "#if defined(ASSERTIONS) || defined(STACK_OVERFLOW_CHECK)" in .js files, which is not supported.
10851093
if shared.Settings.ASSERTIONS:
@@ -1175,7 +1183,7 @@ def check(input_file):
11751183
shared.Settings.WORKAROUND_IOS_9_RIGHT_SHIFT_BUG = 0
11761184
shared.Settings.WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG = 0
11771185

1178-
if shared.Settings.STB_IMAGE and final_suffix in JS_CONTAINING_ENDINGS:
1186+
if shared.Settings.STB_IMAGE and not compile_only:
11791187
input_files.append((next_arg_index, shared.path_from_root('third_party', 'stb_image.c')))
11801188
next_arg_index += 1
11811189
shared.Settings.EXPORTED_FUNCTIONS += ['_stbi_load', '_stbi_load_from_memory', '_stbi_image_free']
@@ -1204,9 +1212,6 @@ def check(input_file):
12041212
shared.Settings.EXPORTED_FUNCTIONS += ['___cxa_demangle']
12051213
forced_stdlibs.append('libc++abi')
12061214

1207-
if shared.Settings.EMBIND:
1208-
forced_stdlibs.append('libembind')
1209-
12101215
if not shared.Settings.ONLY_MY_CODE and not shared.Settings.MINIMAL_RUNTIME:
12111216
# Always need malloc and free to be kept alive and exported, for internal use and other modules
12121217
shared.Settings.EXPORTED_FUNCTIONS += ['_malloc', '_free']
@@ -1884,9 +1889,6 @@ def compile_source_file(i, input_file):
18841889
temp_files[pos] = (temp_files[pos][0], new_temp_file)
18851890

18861891
# Decide what we will link
1887-
executable_endings = JS_CONTAINING_ENDINGS + ('.wasm',)
1888-
compile_only = final_suffix not in executable_endings or has_dash_c or has_dash_S
1889-
18901892
if compile_only or not shared.Settings.WASM_BACKEND:
18911893
# Filter link flags, keeping only those that shared.Building.link knows
18921894
# how to deal with. We currently can't handle flags with options (like

tools/system_libs.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -932,16 +932,6 @@ def get_default_variation(cls, **kwargs):
932932
)
933933

934934

935-
class libembind(CXXLibrary):
936-
name = 'libembind'
937-
cflags = ['-std=c++11']
938-
depends = ['libc++abi']
939-
never_force = True
940-
941-
def get_files(self):
942-
return [shared.path_from_root('system', 'lib', 'embind', 'bind.cpp')]
943-
944-
945935
class libfetch(CXXLibrary, MTLibrary):
946936
name = 'libfetch'
947937
depends = ['libc++abi']

0 commit comments

Comments
 (0)