Repository navigation
Conversation
08ddcb3 to
21d4363
Compare
…tic-llvm Newer host glibc headers (C23 const-preserving generic macros in <string.h>, such as strchr/memchr) return const-qualified pointers when given const inputs, triggering -Wincompatible-pointer-types-discards-qualifiers (promoted to an error by -Werror) when compiling C dependencies like @boringssl//:crypto under --config=hermetic-llvm. TAG=agy Signed-off-by: Matt Leon <mattleon@google.com>
…cc_library
Partially link wasmtime using symbol localization via
privately_linked_cc_library bazel macro. Permits multiple runtimes to be
compiled into the same binary without symbol renaming.
Wasmtime exposes wasm_c_api headers and symbols that collide with other
wasm_c_api runtimes (such as V8/wee8) when multiple engines are linked
into the same binary (--define engine=multi). Previously, we patched
Wasmtime's headers and rewrote its compiled library to redefine symbols
to wasmtime_wasm_*. Now, we:
- Compile library sources against unpatched private_deps headers with
linkstatic = True.
- Partially links compiled sources and static archives from private_deps
into a single relocatable object file and localizes all symbols
outside public_symbols ("*proxy_wasm*"):
- Wraps wasmtime-c-api-impl directly via rust_static_library in
wasmtime.BUILD instead of patching out the main.rs.
TAG=agy
Signed-off-by: Matt Leon <mattleon@google.com>
21d4363 to
b8fbb96
Compare
| exported_symbol_flags = exported_symbol_flags, | ||
| out = out_o.path, | ||
| ) | ||
| else: |
There was a problem hiding this comment.
As discussed offline, the branch here on macos vs. ELF leaves out Windows, even though elsewhere we still attempt to support Windows builds (e.g. BUILD lines 212-220). I think this hasn't shown up in CI since the only Windows job in CI currently builds with engine=null.
A minimal adjustment to avoid breaking Windows for single-engine builds could be to have privately_linked_cc_library select the privatized .o on Linux/macOS and fall back to the plain _unprivatized_lib on @platforms//os:windows. Or, we could gate privatization as a whole on @proxy_wasm_cpp_host//bazel:multiengine--WDYT?
| ]) | ||
| command = """ | ||
| set -e | ||
| {cc} -r -nostdlib -Wl,--whole-archive {libs} -Wl,--no-whole-archive -o {out}.tmp |
There was a problem hiding this comment.
This direct cc invocation omits any configured cc_toolchain flags.
| # STB_GLOBAL STV_HIDDEN SHN_COMMON symbol. Demoting a SHN_COMMON | ||
| # symbol to STB_LOCAL causes ld.lld to fail with an invalid relocation | ||
| # against an absolute symbol, and ld.lld -r ignores -d. | ||
| keep_global_patterns = ctx.attr.public_symbols + ["___asan_globals_registered"] |
There was a problem hiding this comment.
AI analysis claims that the current blanket demotion of all non-matching symbols to object-file-local will cause function-local statics in inline functions in headers to be duplicated.
TBH I don't know whether there is much practical impact, but it contributes to an overall impression that these linker tricks could have subtle side effects, which might argue for limiting them to where strictly necessary (i.e. the multi-engine build), and leaving single-engine Wasmtime build as-is?
Partially link wasmtime using symbol localization via privately_linked_cc_library bazel macro. Permits multiple runtimes to be compiled into the same binary without symbol renaming.
Wasmtime exposes wasm_c_api headers and symbols that collide with other wasm_c_api runtimes (such as V8/wee8) when multiple engines are linked into the same binary (--define engine=multi). Previously, we patched Wasmtime's headers and rewrote its compiled library to redefine symbols to wasmtime_wasm_*. Now, we:
TAG=agy
Signed-off-by: Matt Leon mattleon@google.com