Conversation
Document changes made by Alice and Ren in an attempt to compile .wasm from cpp source file
Create simple cpp program using <algorithms> header to test libcpp headers
Change compilation command from clang to clang++, now the compile script compiles cpp instead of c. Future changes needed to accomodate both Also note due to mysterious reasons absolute path is needed when callling this compile script: scripts/lind_compile <other args>
Add error msg of cpp compilation attempt, which is being fixed right now
Add ignore for llvm external dependencies
Add .cmake to be used for build script to build llvm for .wasm bin result
Add build script for llvm for .wasm compilation result. Note the compiled wasm32 .a archive file must be manually migrated to the sysroot under /build
Modify llvm-project source code needed for compilation. Not tracked in git but documented and Ren will submit another PR for the documentation
Add cosmetic for .md rendering
Yaxuan-w
left a comment
There was a problem hiding this comment.
We need to discuss how we want to standardize cpp testing.
- I'm thinking to have a separate folder under
tests/calledtests/cpp/for all cpp unit test - cpp compilation scripts can be put under
scripts/cppand putlind_compileintoscripts/c, rust version intoscripts/rust(or sth similar)
There was a problem hiding this comment.
cpp compilation needs to be separated from normal c compilation (keep c)
There was a problem hiding this comment.
Totally agree. I also suggest if we have sub dirs to indicate what source code language we are compiling from, can we name the scripts in a more intuitive way? something like scripts/cpp/compile and scripts/rust/compile, instead of "lind_compile"
also, this implies a complete overhaul on the entire lind_compile script for each additional language (such as updating all the echo prompts with -h flag). I think it will be fun to work on.
There was a problem hiding this comment.
I think it is better to not touch the existing path for original lind_compile for clang and .c compilation; I plan to simply create a separate lind_compile_cpp.sh at the same directory level as the lind_compile script and add corresponding tasks to the CI flow.
The existing CI flow worries me as the workflow is very complicated and any changes to the path of original lind_compile might cause issues. The call chain: e3e.yml -> dockerfile.e2e-> Makefile->test_runner.py->check_reports.py
| "--sysroot=${SYSROOT}" | ||
| --target=wasm32-unknown-wasi | ||
| -Wl,--import-memory,--export-memory,--max-memory=67108864,--export="__stack_pointer",--export=__stack_low,--export=__tls_base | ||
| -Wl,--import-memory,--export-memory,--max-memory=67108864,--export="__stack_pointer",--export=__stack_low |
There was a problem hiding this comment.
Need to include --export=__tls_base
| --target=wasm32-unknown-wasi | ||
| -Wl,--import-memory,--export-memory,--max-memory=67108864,--export="__stack_pointer",--export=__stack_low,--export=__tls_base | ||
| -isystem $SYSROOT/include/wasm32-wasi/c++/v1 | ||
| -Wl,--import-memory,--export-memory,--max-memory=67108864,--export="__stack_pointer",--export=__stack_low |
There was a problem hiding this comment.
Need to include --export=__tls_base
|
I think we need to move most of this to the lind-wasm-apps repo. We should add the integrations to compile cpp into the lind_compile script however. It should just check that libcpp is properly installed and fail gracefully with "libcpp not installed" error if not. |
|
@m-hemmings regarding the CI problem: Nick has brought to my attention that the current workaround for libcpp header involves this workflow: git clone llvm-18 ->modification of llvm source code -> compile archive files -> copy over to /build/sysroot -> sysroot provides dependency for clang++ to compile cpp source code. This is problematic. On the one hand, llvm is big and preserving their source code in our repo is confusing; on the other hand, as Alice points out:
However, this implies that, should there be any upgrade of llvm to version beyond 18, we will need to re-create this entire workflow to compile an updated version of the .a archive(s) needed for libcpp header support. I will do my best to document this workflow and, for future improvements, automate the process as far as I can Nick also points out that we are using llvm-16 in lind-wasm-apps repo, see commit 0e78686; while my PR for lind-wasm repo is now using llvm-18, this is consistent with the docker config in this repo. |
Thanks for writing this up. I agree that the current approach puts us in an awkward spot: keeping LLVM source in the repo is heavy and confusing, but moving all of the logic somewhere else also makes the workflow harder to understand and maintain. I think there is a cleaner middle ground. Instead of treating libc++ support as something we rebuild from LLVM source during normal CI, we could treat it as a versioned toolchain artifact. Concretely, I would suggest:
That gives us a few benefits:
On the versioning point, I do think it would help to align on a single LLVM major version across repos if we can. This repo is already pinned to LLVM 18 in Docker, so moving So in short, my suggestion would be:
What does everyone think about that? |
End-to-End Test ReportTest PreviewUnified Test Report grate harness
Cases
wasm harnessTest ReportDeterministic TestsSummary
Test Results by Category
Fail TestsSummary
Test Results by Category
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Add libcpp-test and libcpp-out stages.
Increase verbose printf for debugging.
Add /artifact directory verification.
Adjust script calling relative path.
Add tools to dependency path.
Add verbosity in compile step.
Adjust read-only mount to writable.
Add compilation success flag check.
Add libcpp-out explicit dependency.
Move from /trial to /tests/unit-tests/cpp/
combine libcpp workflow into existing ci; temporarily change trigger to any push for testing purposes.
Change faile-to-upload consequence from error to warn.
Add build target to override default behavior of using prev stage Now report should be generated.
Integrate libcpp compilation into main codebase
2.documentation in .md