Warnings while compiling to WebAssembly
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 77
- Forks
- 135
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 10
Description
Hi! I am working on compiling ROS2 nodes to WebAssembly using Emscripten so that I can simulate robot control software in the browser. For the most part, this is going smoothly so far but there are a couple warnings that I think should be addressed:
- Conditional compilation in
rcutils_get_platform_library_name
rcutils/src/shared_library.c:289:16: warning: unused parameter 'buffer_size' [-Wunused-parameter]
rcutils/src/shared_library.c:290:8: warning: unused parameter 'debug' [-Wunused-parameter]
It seems when I compile using Clang/Emscripten, none of the #ifdefs are matching my configuration in rcutils_get_platform_library_name, which is a bit unusual since I was under the impression that Emscripten defines __LINUX__ (uppercase). I will investigate this, however, there is also the possibility of checking whether __EMSCRIPTEN__ has been defined.
- Conditional compilation in
rcutils_strerror
rcutils/src/strerror.c:32:10: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
This warning seems very similar to the previous one. It seems again that conditional compilation has gone down the wrong path since the version strerror_r that comes with Emscripten's C standard library returns an int instead of a char*.
For reference, I am using the Emscripten 3.1.0 (Clang 14.0.0) with the following colcon mixin:
{
"build": {
"emscripten": {
"cmake-args": [
"-DCMAKE_TOOLCHAIN_FILE=/path/to/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
"-DCMAKE_STAGING_PREFIX=/path/to/developer/emsdk/upstream/emscripten/cache/sysroot/usr/",
"-DBUILD_SHARED_LIBS=OFF",
"-DBUILD_TESTING=OFF",
"--no-warn-unused-cli"
]
}
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/shared_library.c at rcutils_get_platform_library_name and src/strerror.c at rcutils_strerror, using the reported Emscripten toolchain and warnings as the initial checks. Inspect the platform conditionals and Emscripten's strerror_r behavior; done means the relevant WebAssembly compilation path no longer emits these warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, wasm
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100