FS#63985 - [emscripten] Expects LLVM 10 while packed with version 9

Attached to Project: Community Packages
Opened by Kay (asdf123101) - Wednesday, 02 October 2019, 01:50 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Wednesday, 18 March 2020, 20:07 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description:
emcc expects clang version 10 while the clang comes with the package is of version 9.

emcc -v shows

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.38.46
clang version 9.0.0 (/srcdest/llvm-project)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/emscripten-llvm
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/9.1.0
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/9.1.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
shared:WARNING: LLVM version appears incorrect (seeing "9.0", expected "10.0")
shared:INFO: (Emscripten: Running sanity checks)

Compilation also fails
error: unknown warning option '-Wno-int-in-bool-context'; did you mean '-Wno-gnu-include-next'? [-Werror,-Wunknown-warning-option]


Additional info:
* package version(s): 1.38.46-1

Steps to reproduce: emcc -v
This task depends upon

Closed by  Sven-Hendrik Haase (Svenstaro)
Wednesday, 18 March 2020, 20:07 GMT
Reason for closing:  Fixed
Additional comments about closing:  I don't really know how to fix this properly but the current solution works kind of well.
Comment by magiblot (magiblot) - Wednesday, 02 October 2019, 12:42 GMT
I tried to work this around by defining the environment variable `EMMAKEN_CFLAGS='-Wno-unknown-warning-option'`. Compilation resumed until it failed to find `unwind.h` for `libc++abi-noexcept.a`. Again, I worked this around by copying it from `/usr/include/` to `/usr/lib/emscripten/system/include/`. Then the python script crashed:

```
Traceback (most recent call last):
File "/usr/lib/emscripten/emcc.py", line 3652, in <module>
sys.exit(run(sys.argv))
File "/usr/lib/emscripten/emcc.py", line 2205, in run
final = do_emscripten(final, target + '.mem', js_libraries)
File "/usr/lib/emscripten/emcc.py", line 452, in do_emscripten
emscripten.run(infile, outfile, memfile, js_libraries)
File "/usr/lib/emscripten/emscripten.py", line 2723, in run
shared.Settings.STRUCT_INFO = shared.Cache.get(generated_struct_info_name, generate_struct_info)
File "/usr/lib/emscripten/tools/cache.py", line 133, in get
temp = creator()
File "/usr/lib/emscripten/emscripten.py", line 2720, in generate_struct_info
gen_struct_info.main(['-q', '-c', '-o', out])
File "/usr/lib/emscripten/tools/gen_struct_info.py", line 556, in main
struct_info = inspect_code(header_files, cpp_opts, structs, defines)
File "/usr/lib/emscripten/tools/gen_struct_info.py", line 420, in inspect_code
info = shared.run_js(js_file[1]).splitlines()
File "/usr/lib/emscripten/tools/shared.py", line 1057, in run_js
engine = JS_ENGINES[0]
IndexError: list index out of range
```

So, it seems like this package needs more testing.
Comment by Giumo Clanjor (cjxgm) - Saturday, 05 October 2019, 08:28 GMT
Worked around it with these changes (as in the patch):

- Remove the "-Wno-int-in-bool-context" flag.
- Turn off "-Werror" when building system libs.
- Add include path "/usr/lib/emscripten/system/lib/libunwind/include" when building libcxxabi.
- Add "node" as the default JS engine.
Comment by Sven-Hendrik Haase (Svenstaro) - Sunday, 06 October 2019, 15:20 GMT
This is really weird. Can you guys report this upstream?
Comment by Giumo Clanjor (cjxgm) - Sunday, 06 October 2019, 17:26 GMT
Well, what we said were all workarounds. The upstream binary
distribution (emsdk install latest-upstream) works all fine.
And it bundles with clang 10.0.

As for the JS_ENGINES, when using "emsdk activate latest-upstream",
the "~/.emscripten" will have an entry to set JS_ENGINES to the
bundled nodejs.
Comment by Giumo Clanjor (cjxgm) - Monday, 07 October 2019, 03:37 GMT
LLVM commit SHAs should be fetched from https://chromium.googlesource.com/emscripten-releases/+/refs/heads/master/DEPS
e.g. currently it's 9ecacb0d54fb89dc7e6da66d9ecae934ca5c01d4.
Comment by Sven-Hendrik Haase (Svenstaro) - Tuesday, 08 October 2019, 13:21 GMT
Thanks for the hint. Check rel -2.
Comment by Giumo Clanjor (cjxgm) - Wednesday, 09 October 2019, 04:27 GMT
No more warnings about LLVM versions, but still doesn't work, complaining:

1. cannot find "unwind.h"
2. list index out of range in "JS_ENGINES[0]"

where,

1. can be fixed by the attached patch (which should probably report to upstream). But the emsdk version do not need this change, strange.

2. can be fixed by adding this to prepare() in PKGBUILD to uncomment JS_ENGINES line in settings template:

sed -i 's|^#\s*\(JS_ENGINES\s*=\)|\1|' tools/settings_template_readonly.py
Comment by Sven-Hendrik Haase (Svenstaro) - Wednesday, 09 October 2019, 23:34 GMT
Ok, thanks. Try rel -3.

Can you post your patch upstream?
Comment by Giumo Clanjor (cjxgm) - Thursday, 10 October 2019, 02:32 GMT
After looking deeper into it, I now know why it cannot find "unwind.h".

The emsdk version has bundled lib/clang/10.0.0/include which has unwind.h.
This emscripten package did not bundle that, and the Arch's clang is 8.0.1,
which has only /usr/lib/clang/8.0.1/include.

My patch asks libcxxabi to include the Emscripten-bundled libunwind,
which has unwind.h, but is not exactly the same as the clang's unwind.h.

I think this is still our packaging problem. We should probably:

- Put LLVM binaries into /usr/lib/emscripten-llvm/bin/
- Copy LLVM and clang headers into
/usr/lib/emscripten-llvm/lib/clang/10.0.0/include/
/usr/lib/emscripten-llvm/include/clang-c/
/usr/lib/emscripten-llvm/include/llvm-c/
- Compile clang with some option to look /usr/lib/emscripten-llvm/lib/clang/10.0.0/include/ and such for extra system headers.
- Remember to modify LLVM_ROOT in settings_template_readonly.py.
Comment by Giumo Clanjor (cjxgm) - Thursday, 10 October 2019, 02:36 GMT
rel -3 got LLVM_ROOT wrong.
https://git.archlinux.org/svntogit/community.git/tree/trunk/arch-template.patch?h=packages/emscripten#n13
should be
+LLVM_ROOT = "/usr/lib/emscripten-llvm"

Except for that, it works.
Comment by Sven-Hendrik Haase (Svenstaro) - Thursday, 10 October 2019, 21:30 GMT
Sorry, fixed. Please check.
Comment by Giumo Clanjor (cjxgm) - Saturday, 12 October 2019, 03:58 GMT
rel -4 works.

But like I said, we should probably bundle lib/clang/10.0.0/include somehow like what the emsdk distribution does.
My libcxxabi-include-libunwind.patch was just a workaround to not bundling this.
Comment by Sven-Hendrik Haase (Svenstaro) - Tuesday, 15 October 2019, 02:08 GMT
I'm not sure where those files would be coming from. It seems lib/clang/10.0.0/include is actually llvm-project/clang/lib/Headers? Then, where in the package should this end up at? There is /usr/lib/emscripten/system/include/ but then what would the final path be?

It's a bit confusing, really.

Would be amazing if you could spend the time to make a patch for this to make it more like the emscripten-sdk (which I assume is more correct).

Loading...