emscripten-core / emscripten-core/emscripten

Error from wasm-ld: Section too large

Open
#10,719 24 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

I'm experiencing an error which seems really obscure - I can't find any other issues about it but I found the error in the LLVM source. Let me try to explain, and hopefully someone might be able to shed some light on it? I know you probably won't have an answer, but any help debugging this would be helpful.

I'm compiling this project: https://github.com/libofx/libofx. That project depends on OpenSP: http://openjade.sourceforge.net/doc/index.htm

Some context: I've successfully compiled all of this before. I've been using a WebAssembly version of libofx for about 2 years. Today I updated Emscripten to generate a fresh build and how hitting these problems (version 1.39.10, git hash 1bd7d547598f3fc74699c172f6c9c59a1e8484f1)

I can successfully compile OpenSP with the following hacks:

```
emconfigure ./configure --disable-doc-build
sed -i -e 's/\/\* \#undef HAVE_NAMESPACE_STD \*\//\#define HAVE_NAMESPACE_STD/g' OpenSP-1.5.2/config.h
sed -i -e 's/\/\* \#undef HAVE_MEMMOVE \*\//\#define HAVE_MEMMOVE 1/g' OpenSP-1.5.2/config.h
sed -i -e 's/\#define ptrdiff_t long/\/*\#define ptrdiff_t long\*\//g' OpenSP-1.5.2/config.h
cd OpenSP-1.5.2 && emmake make
```

Honestly, I came up with those hacks a long time ago and can't remember why they are needed, but it successfully compiles.

Then I try to run `./configure` in libofx but it fails. Here is my call to it:

```
emconfigure ./configure --without-iconv --with-opensp-includes=/Users/james/projects/actual/packages/node-libofx/OpenSP-1.5.2/generic --with-opensp-libs=/Users/james/projects/actual/packages/node-libofx/OpenSP-1.5.2/lib/.libs
```

I'm specifying where exactly OpenSP is. It fails with this error:

```
checking for libosp... no
configure: error: unable to link a test program, is OpenSP installed?
```

If I look in `config.log` I can see what's actually failing:

```
configure:17105: checking for libosp
configure:17140: /Users/james/tmp/emsdk/upstream/emscripten/em++ -o conftest -DIN_LIBOFX -g -O2 -I/Users/james/projects/actual/packages/node-libofx/OpenSP-1.5.2/generic conftest.cpp -L/Users/james/projects/actual/packages/node-libofx/OpenSP-1.5.2/lib/.libs -losp >&5
wasm-ld: error: ParserEventGeneratorKit.o: Section too large
```

If I dig down some more, I can find the direct call to `wasm-ld` that I can run to replicate the error:

```
$ /Users/james/tmp/emsdk/upstream/bin/wasm-ld -o conftest /var/folders/kx/1gnshz117g378t2d7kwqg9_c0000gn/T/emscripten_temp/test_0.o -L/Users/james/projects/actual/packages/node-libofx/OpenSP-1.5.2/lib/.libs /Users/james/projects/actual/packages/node-libofx/OpenSP-1.5.2/lib/.libs/libosp.a -L/Users/james/tmp/emsdk/upstream/emscripten/system/lib -L/Users/james/.emscripten_cache/wasm --allow-undefined --import-memory --import-table -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --export __wasm_call_ctors --export __data_end --export main --export malloc --export free --export setThrew --export __errno_location -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024 --relocatable

wasm-ld: error: ParserEventGeneratorKit.o: Section too large
```
I tested ` ParserEventGeneratorKit.o` and it looks like a valid wasm module:

```
> let b = fs.readFileSync('./OpenSP-1.5.2/lib/.libs/ParserEventGeneratorKit.o')
undefined
> WebAssembly.validate(b)
true
```

This is the place in LLVM that generates the error: https://github.com/llvm/llvm-project/blob/bd4812776bc73ca27bf6c68629a20f03268cdd6e/llvm/lib/Object/WasmObjectFile.cpp#L221

I don't know what to infer from that code. It looks like it's an invalid wasm module, but why it is validating in node?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.