`__heap_base` 好像在 clang 9.0.0 中不见了,有替代品吗?

`__heap_base` seems to be missing in clang 9.0.0, is there a replacement?

我正在尝试使用 clang(无 emscripten)为 WebAssembly 编译我的 C 库,它在 clang 版本 8.0.1 上编译得很好,但在 [=11= 下失败了]版本9.0.0。报告的错误是 wasm-ld: error: ….o: undefined symbol: __heap_base__heap_base 是否已被其他符号替换?

库是开源的,可以找到编译说明here

这似乎是 9.0.0 中的错误。它似乎不会出现在 ToT 或 8.0.0 中。

简单复现案例:

extern void* __heap_base;

void* a = &__heap_base;

void _start() {
}

构建:

$ clang --target=wasm32 test.c -nostdlib -Wl,-no-gc-sections

使用 9.0.0:

wasm-ld: error: /tmp/test-551a5c.o: undefined symbol: __heap_base
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)

这应该在 llvm 错误跟踪器中作为错误打开。

实际上,我相信我找到了罪魁祸首:9.0.0 中的链接器似乎需要 --export=__heap_base-Wl,--export=__heap_base 对应 clang)。这适用于我的项目。