Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Automatically register init functions for RcppModules (closes #704)#705

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
eddelbuettel merged 2 commits intomasterfromfeature/module-routine-registraiton
Jun 2, 2017

Conversation

@jjallaire
Copy link
Member

Addresses#704

RcppModules include a native routine "boot" function of the form_rcpp_module_boot_*. These functions are not discovered bytools::package_native_routine_registration_skeleton so generally need to be hand-added toinit.c.

This also implies that our current auto-generation of native routine registrations forRcppExports.cpp won't register these functions and will therefore fail to create a loadable package. 2 alternatives here:

  1. When we see an Rcpp module simply don't attempt to generate native routine registrations (sort of like we do now when we seeinit.c).

  2. Generate native routine registrations for the Rcpp modules.

Happily, we already parse for Rcpp module declarations (sincesourceCpp supports exporting modules) so it's a very straightforward change to generate the_rcpp_module_boot_* functions, which is what we do in this PR.

eddelbuettel reacted with hooray emoji
@eddelbuettel
Copy link
Member

Nicely done.

@eddelbuettel
Copy link
Member

Shame on me for not escalating this in March when I adjusted the example we unit test.

@codecov-io
Copy link

codecov-io commentedJun 2, 2017
edited
Loading

Codecov Report

Merging#705 intomaster willincrease coverage by0.03%.
The diff coverage is100%.

Impacted file tree graph

@@            Coverage Diff             @@##           master     #705      +/-   ##==========================================+ Coverage   89.54%   89.57%   +0.03%==========================================  Files          66       66                Lines        3587     3588       +1     ==========================================+ Hits         3212     3214       +2+ Misses        375      374       -1
Impacted FilesCoverage Δ
src/attributes.cpp98.4% <100%> (ø)⬆️
R/Rcpp.package.skeleton.R84.43% <100%> (+0.5%)⬆️

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updatef8d1e93...7f872ca. Read thecomment docs.

@eddelbuettel
Copy link
Member

eddelbuettel commentedJun 2, 2017
edited
Loading

Notquite there yet.

After fresh install from this branch:

/tmp$ Rscript -e"Rcpp::Rcpp.package.skeleton('foo', module = TRUE)"  Creating directories ...Creating DESCRIPTION ...Creating NAMESPACE ...Creating Read-and-delete-me ...Saving functions and data ...Makinghelp files ...Done.Further steps are describedin'./foo/Read-and-delete-me'.Adding Rcpp settings>> added Imports: Rcpp>> added LinkingTo: Rcpp>> added useDynLib directive to NAMESPACE>> added import(methods, Rcpp) directive to NAMESPACE>> added example src file using Rcpp attributes>> compiled Rcpp attributes>>do NOT modify by hand either RcppExports.cpp or RcppExports.R>> added Rd filefor rcpp_hello_world>> copied the example module file /tmp$ R CMD INSTALL foo* installing to library ‘/usr/local/lib/R/site-library’* installing*source* package ‘foo’ ...** libsccache g++ -I/usr/share/R/include -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c Num.cpp -o Num.occache g++ -I/usr/share/R/include -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c RcppExports.cpp -o RcppExports.occache g++ -I/usr/share/R/include -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c rcpp_hello_world.cpp -o rcpp_hello_world.occache g++ -I/usr/share/R/include -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c rcpp_module.cpp -o rcpp_module.occache g++ -I/usr/share/R/include -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c stdVector.cpp -o stdVector.og++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o foo.so Num.o RcppExports.o rcpp_hello_world.o rcpp_module.o stdVector.o -L/usr/lib/R/lib -lRinstalling to /usr/local/lib/R/site-library/foo/libs** R** preparing packagefor lazy loading**help*** installinghelp indices** building package indices** testingif installed package can be loadedError: package or namespace load failedfor‘foo’in .doLoadActions(where, attach): errorin load action .__A__.1forpackage foo: loadModule(module ="NumEx", what = TRUE, env = ns, loadNow = TRUE): Unable to load module"NumEx": Failed to initialize module pointer: Errorin FUN(X[[i]], ...): no such symbol _rcpp_module_boot_NumExin package fooError: loading failedExecution haltedERROR: loading failed* removing ‘/usr/local/lib/R/site-library/foo’/tmp$

@jjallaire
Copy link
MemberAuthor

jjallaire commentedJun 2, 2017 via email

I think the problem is that compileAttributes is called withinRcpp::package.skeleton *before* the module code is added. I'll change theorder and it should resolve things.
On Fri, Jun 2, 2017 at 12:17 PM, Dirk Eddelbuettel ***@***.*** > wrote: Not *quite* there yet. After fresh install from this branch: /tmp$ Rscript -e "Rcpp::Rcpp.package.skeleton('foo', module = TRUE)" Creating directories ... Creating DESCRIPTION ... Creating NAMESPACE ... Creating Read-and-delete-me ... Saving functions and data ... Making help files ... Done. Further steps are described in './foo/Read-and-delete-me'. Adding Rcpp settings >> added Imports: Rcpp >> added LinkingTo: Rcpp >> added useDynLib directive to NAMESPACE >> added import(methods, Rcpp) directive to NAMESPACE >> added example src file using Rcpp attributes >> compiled Rcpp attributes >> do NOT modify by hand either RcppExports.cpp or RcppExports.R >> added Rd file for rcpp_hello_world >> copied the example module file /tmp$ R CMD INSTALL foo* installing to library ‘/usr/local/lib/R/site-library’* installing *source* package ‘foo’ ...** libs ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c Num.cpp -o Num.o ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c RcppExports.cpp -o RcppExports.o ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c rcpp_hello_world.cpp -o rcpp_hello_world.o ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c rcpp_module.cpp -o rcpp_module.o ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c stdVector.cpp -o stdVector.o g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o foo.so Num.o RcppExports.o rcpp_hello_world.o rcpp_module.o stdVector.o -L/usr/lib/R/lib -lR installing to /usr/local/lib/R/site-library/foo/libs** R** preparing package for lazy loading** help*** installing help indices** building package indices** testing if installed package can be loaded Error: package or namespace load failed for ‘foo’ in .doLoadActions(where, attach): error in load action .__A__.1 for package foo: loadModule(module = "NumEx", what = TRUE, env = ns, loadNow = TRUE): Unable to load module "NumEx": Failed to initialize module pointer: Error in FUN(X[[i]], ...): no such symbol _rcpp_module_boot_NumEx in package foo Error: loading failed Execution halted ERROR: loading failed* removing ‘/usr/local/lib/R/site-library/foo’ /tmp$ — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#705 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAGXx0vLz4Cagygyt4M5_uiBGskIPcnDks5sADWbgaJpZM4NudVA> .

@jjallaire
Copy link
MemberAuthor

jjallaire commentedJun 2, 2017 via email

Okay, just pushed a fix
On Fri, Jun 2, 2017 at 1:20 PM, JJ Allaire ***@***.***> wrote: I think the problem is that compileAttributes is called within Rcpp::package.skeleton *before* the module code is added. I'll change the order and it should resolve things. On Fri, Jun 2, 2017 at 12:17 PM, Dirk Eddelbuettel < ***@***.***> wrote:> Not *quite* there yet.>> After fresh install from this branch:>> /tmp$ Rscript -e "Rcpp::Rcpp.package.skeleton('foo', module = TRUE)" Creating directories ...> Creating DESCRIPTION ...> Creating NAMESPACE ...> Creating Read-and-delete-me ...> Saving functions and data ...> Making help files ...> Done.> Further steps are described in './foo/Read-and-delete-me'.>> Adding Rcpp settings> >> added Imports: Rcpp> >> added LinkingTo: Rcpp> >> added useDynLib directive to NAMESPACE> >> added import(methods, Rcpp) directive to NAMESPACE> >> added example src file using Rcpp attributes> >> compiled Rcpp attributes> >> do NOT modify by hand either RcppExports.cpp or RcppExports.R> >> added Rd file for rcpp_hello_world> >> copied the example module file> /tmp$ R CMD INSTALL foo* installing to library ‘/usr/local/lib/R/site-library’* installing *source* package ‘foo’ ...** libs> ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c Num.cpp -o Num.o> ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c RcppExports.cpp -o RcppExports.o> ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c rcpp_hello_world.cpp -o rcpp_hello_world.o> ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c rcpp_module.cpp -o rcpp_module.o> ccache g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wextra -Wno-empty-body -Wno-unused -c stdVector.cpp -o stdVector.o> g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o foo.so Num.o RcppExports.o rcpp_hello_world.o rcpp_module.o stdVector.o -L/usr/lib/R/lib -lR> installing to /usr/local/lib/R/site-library/foo/libs** R** preparing package for lazy loading** help*** installing help indices** building package indices** testing if installed package can be loaded> Error: package or namespace load failed for ‘foo’ in .doLoadActions(where, attach):> error in load action .__A__.1 for package foo: loadModule(module = "NumEx", what = TRUE, env = ns, loadNow = TRUE): Unable to load module "NumEx": Failed to initialize module pointer: Error in FUN(X[[i]], ...): no such symbol _rcpp_module_boot_NumEx in package foo>> Error: loading failed> Execution halted> ERROR: loading failed* removing ‘/usr/local/lib/R/site-library/foo’> /tmp$>> —> You are receiving this because you authored the thread.> Reply to this email directly, view it on GitHub> <#705 (comment)>, or mute> the thread> <https://github.com/notifications/unsubscribe-auth/AAGXx0vLz4Cagygyt4M5_uiBGskIPcnDks5sADWbgaJpZM4NudVA>> .>

@eddelbuettel
Copy link
Member

Works like a charm now.

@eddelbuetteleddelbuettel changed the titleAutomatically register init functions for RcppModulesAutomatically register init functions for RcppModules (closes #704)Jun 2, 2017
compileAttributes(root)
message(" >> compiled Rcpp attributes")
}

Copy link
Member

@eddelbuetteleddelbuettelJun 2, 2017
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe I am short of coffee butif (attributes) { relies onattributes==TRUE. We could have a case ofmodules=TRUE (as in#704)and alsoattributes=FALSE, no? Needless complication?

@jjallaire
Copy link
MemberAuthor

I think it's a little more involved than first appears, if we do this:

Rcpp::Rcpp.package.skeleton('foo', module = TRUE, attributes = FALSE)

Then theattributes = FALSE causes us to generate init.c (which will in turn cause compileAttributes to do no registration). So calling compileAttributes in that case won't actually change the output, but rather will generate an RcppExports.cpp that has nothing in it.

I'd say if the user asks for modules and no attributes then they mean no auto-generation behavior and they'll futz with init.c manually themselves.

@eddelbuettel
Copy link
Member

Agreed. Let's go with this now and clean up spillage should it occur.Rcpp.package.skeleton() is already used less than it used to given the 'make me a package' feature in a certain IDE. And use of modules is even less common. And modules with attributes=FALSE ... may just never happen.

@eddelbuetteleddelbuettel merged commitc73730a intomasterJun 2, 2017
@BenoitLondon
Copy link

Thanks for the fix! Do you know when you will release it? I wanted to know if I should use master or wait for the release.

@eddelbuettel
Copy link
Member

@BenoitLondon See myrecent post to the rcpp-devel list with pointers to the drat repo. You can install Rcpp 0.12.11.2 from there. (Master works too but the git repo could be unstable.)

@BenoitLondon
Copy link

Thanks

@eddelbuetteleddelbuettel deleted the feature/module-routine-registraiton branchJune 14, 2017 20:54
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@eddelbuetteleddelbuetteleddelbuettel left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@jjallaire@eddelbuettel@codecov-io@BenoitLondon

[8]ページ先頭

©2009-2025 Movatter.jp