Closed jeroen closed 6 months ago
Surprisingly, it looks like R can read the symbols from object files output by emcc
, at least the names:
$ cat obj.c
int f() {
return 0;
}
$ emcc -c obj.c -o obj.o
$ clang -c obj.c -o host.o
$ echo "tools:::read_symbols_from_object_file('host.o')" | R --vanilla --quiet
> tools:::read_symbols_from_object_file('host.o')
name type value size
[1,] "_f" "T" "0" "0"
>
$ echo "tools:::read_symbols_from_object_file('obj.o')" | R --vanilla --quiet
> tools:::read_symbols_from_object_file('obj.o')
name type value size
[1,] "f" "T" "1" "0"
>
So, perhaps this could be made to work!
I suppose we could patch the R source as part of the webR build process to use $(R_HOST_EXE)
for this particular rule, since we already set that Makevar for other purposes elsewhere. That would silence the override error I think.
The duckdb package does something rare where it invokes the rule
make symbols.rds
which fails because it tries to execute an R command in webr instead of host-R. See for example build log.This rule is defined in a base R in share/make/shlib.mk as follows:
I am not sure what would be the correct way to override this. Perhaps we just need to replace it with a dummy rule because reading symbols from the wasm objects probably won't work anyway, even if we run the script in host-R.
I tried creating a dummy rule for
symbols.rds
inwebr-vars
which worked but gave a warning for every package build, so that is not very elegant either.