Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in make symbols.rds causes duckdb to fail #13

Closed
jeroen opened this issue Jan 9, 2024 · 1 comment · Fixed by r-wasm/webr#367
Closed

Bug in make symbols.rds causes duckdb to fail #13

jeroen opened this issue Jan 9, 2024 · 1 comment · Fixed by r-wasm/webr#367
Labels
bug an unexpected problem or unintended behavior

Comments

@jeroen
Copy link
Contributor

jeroen commented Jan 9, 2024

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:

symbols.rds: $(OBJECTS)
	@$(ECHO) "tools:::.shlib_objects_symbol_tables()" | \
	  $(R_HOME)/bin/R --vanilla --no-echo --args $(OBJECTS)

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 in webr-vars which worked but gave a warning for every package build, so that is not very elegant either.

/opt/R/4.3.2/lib/R/site-library/rwasm/webr-vars.mk:123: warning: overriding recipe for target 'symbols.rds'
/opt/R/4.3.2/lib/R/share/make/shlib.mk:24: warning: ignoring old recipe for target 'symbols.rds'
@georgestagg
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants