Skip to content

Rcpp compilation issue on Alpine distribution #448

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

Closed
lostie opened this issue Mar 21, 2016 · 23 comments
Closed

Rcpp compilation issue on Alpine distribution #448

lostie opened this issue Mar 21, 2016 · 23 comments

Comments

@lostie
Copy link
Contributor

lostie commented Mar 21, 2016

"Command failed (1)

Failed to run system command:

'/usr/lib/R/bin/R' --vanilla CMD INSTALL '/tmp/RtmpDPDGNf/Rcpp' --library='/app/packrat/lib/x86_64-alpine-linux-musl/3.2.3' --install-tests --no-docs --no-multiarch --no-demo
The command failed with output:
* installing *source* package 'Rcpp' ...
** package 'Rcpp' successfully unpacked and MD5 sums checked
** libs
x86_64-alpine-linux-musl-g++ -I/usr/lib/R/include -DNDEBUG -I../inst/include/ -Os -fomit-frame-pointer    -fpic  -Os -fomit-frame-pointer  -c Date.cpp -o Date.o
x86_64-alpine-linux-musl-g++ -I/usr/lib/R/include -DNDEBUG -I../inst/include/ -Os -fomit-frame-pointer    -fpic  -Os -fomit-frame-pointer  -c Module.cpp -o Module.o
x86_64-alpine-linux-musl-g++ -I/usr/lib/R/include -DNDEBUG -I../inst/include/ -Os -fomit-frame-pointer    -fpic  -Os -fomit-frame-pointer  -c Rcpp_init.cpp -o Rcpp_init.o
x86_64-alpine-linux-musl-g++ -I/usr/lib/R/include -DNDEBUG -I../inst/include/ -Os -fomit-frame-pointer    -fpic  -Os -fomit-frame-pointer  -c api.cpp -o api.o
api.cpp:40:30: fatal error: execinfo.h: No such file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:141: recipe for target 'api.o' failed
make: *** [api.o] Error 1
ERROR: compilation failed for package 'Rcpp'
* removing '/app/packrat/lib/x87_64-alpine-linux-musl/3.2.3/Rcpp'"

It seems related to #360 (although on a diferrent platform).

The code it is hitting seems to be https://github.com/RcppCore/Rcpp/blob/0.12.3/src/api.cpp#L40

According to the gnulib page it seems that for platforms that the file is missing it should only have a stub (do nothing).

Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc
http://wiki.alpinelinux.org/wiki/Main_Page

Alpine seems to use a different libc as mentioned above

Is that the Alpine distribution be covered by the Rcpp api.cpp to just use a stub?

@eddelbuettel
Copy link
Member

I would encourage you to work up a (minimal) pull request demonstrating (via Travis CI) that nothing breaks on other systems yet that it recognizes your (somewhat exotic) libc variant.

We generally rely on that set of defines list over here at sourceforge. Methinks the required change may just be on one line (but possibly one line in several files).

@thirdwing
Copy link
Member

From musl source code (http://git.musl-libc.org/cgit/musl/tree/include), there seems no execinfo.h.

I know GLIBC defines several macros (https://github.com/lattera/glibc/blob/master/include/features.h#L358), so we know we are using GLIBC.

I am not sure there are such macros in musl.

@eddelbuettel
Copy link
Member

@thirdwing take a step back -- @lostie correctly pointed to line 40 for execinfo.h but on line 37 we have the very test he needs to expand. Should not be hard, may however also be needed somewhere else.

@lostie
Copy link
Contributor Author

lostie commented Mar 21, 2016

I don't seem to be able to push my changes to the remote 😢

Here's a suggested patch: https://gist.github.com/lostie/425d11dff9c06cc9ff89

@thirdwing
Copy link
Member

Hi @lostie

I think there is another place need to be changed line260 . Maybe more.

This change means we will only have the full backtrace info using GLIBC.

@eddelbuettel
Copy link
Member

I don't seem to be able to push my changes to the remote 😢

Welcome to git(hub). You are supposed to fork a repo after which you can push to your copy after which you can (once happy) propose a pull request back to our repo. Which we, who have write access to our repo, may or may not accept.

There are lots of tutorials for all of this.

@eddelbuettel
Copy link
Member

This was taken care of in #449.

@ghost
Copy link

ghost commented May 18, 2016

I still have this issue with Rcpp 0.12.5

trying URL 'http://cloud.r-project.org/src/contrib/Rcpp_0.12.5.tar.gz'
Content type 'application/x-gzip' length 2397088 bytes (2.3 MB)
==================================================
downloaded 2.3 MB

* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/include/R -DNDEBUG -I../inst/include/ -Os -fomit-frame-pointer    -fpic  -Os -fomit-frame-pointer  -c Date.cpp -o Date.o
g++ -I/usr/include/R -DNDEBUG -I../inst/include/ -Os -fomit-frame-pointer    -fpic  -Os -fomit-frame-pointer  -c Module.cpp -o Module.o
g++ -I/usr/include/R -DNDEBUG -I../inst/include/ -Os -fomit-frame-pointer    -fpic  -Os -fomit-frame-pointer  -c Rcpp_init.cpp -o Rcpp_init.o
g++ -I/usr/include/R -DNDEBUG -I../inst/include/ -Os -fomit-frame-pointer    -fpic  -Os -fomit-frame-pointer  -c api.cpp -o api.o
api.cpp:40:30: fatal error: execinfo.h: No such file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:139: recipe for target 'api.o' failed
make: *** [api.o] Error 1
ERROR: compilation failed for package ‘Rcpp’

@thirdwing
Copy link
Member

@albap Hi, you need to modify the Makevars first.

@ghost
Copy link

ghost commented May 18, 2016

@thirdwing
How can I do that?
Is it something that could be automated on Alpine Linux?

@thirdwing
Copy link
Member

You need -D__MUSL__ in the PKG_CXXFLAGS to install Rcpp on Alpine.

You can add the following line

PKG_CXXFLAGS = -D__MUSL__

into Makevars (https://github.com/RcppCore/Rcpp/blob/master/src/Makevars) in the package.

@ghost
Copy link

ghost commented May 18, 2016

So I can't just install.package("ggplot2") (and maybe other packages) on Alpine?
I'll have to do manually, download the source code, edit Makevars.....
This is a bit inconvenient, could there be a way to set -D__MUSL__ for my entire R and have packages recognize it?

@thirdwing
Copy link
Member

You can try with a ~/.R/Makevars with content

CXXFLAGS = -D__MUSL__

@eddelbuettel
Copy link
Member

@thirdwing 's suggestion is what I would do but possibly with += rather than =:

CXXFLAGS  += -D__MUSL__
CXX1XFLAGS += -D__MUSL__

to ensure C++ and C++11 have it set. That will affect all R builds across all packages; and at least Rcpp should take advantage of it.

@jirutka
Copy link

jirutka commented May 20, 2016

Can we set it in system-wide Makeconf instead of Makevars? What’s difference between them?

@thirdwing
Copy link
Member

Not everyone has the permission to change system-wide configurations.

@kevinushey
Copy link
Contributor

Basically, when R compiles code in a package, it calls make and reads in the system Makeconf, and then applies (potentially amending or overriding) any variables set in the appropriate Makevars files. If you're able to just edit the Makeconf file, that should be sufficient.

Reading the file at R.home("bin")/config is somewhat helpful (it shows how R looks up and uses the various Makefiles)

@jirutka
Copy link

jirutka commented May 20, 2016

Not everyone has the permission to change system-wide configurations.

That’s not what I’ve asked. I’m maintainer of the R package in Alpine Linux, so I’m about to add CXXFLAGS and CXX1XFLAGS as the default for the package.

@kevinushey, thanks, so I’m gonna add these to the Makeconf.

@sgerrand
Copy link

Is it something that could be automated on Alpine Linux?

@albap @jirutka: 📝 This change now exists in each of the Alpine packages for R which I maintain - https://github.com/sgerrand/alpine-pkg-R/releases. I've updated the value of R_XTRA_CPPFLAGS, so packages like Rcpp now compile out of the box.

Try it out:

wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-R/master/sgerrand.rsa.pub
apk --no-cache -X http://apkproxy.heroku.com/sgerrand/alpine-pkg-R add R R-dev R-doc

@eddelbuettel
Copy link
Member

Thanks for the update. As it happens, we'll probably release a new Rcpp version within a few days so if you have some cycles to spare, could you try the current master branch here (with version 0.12.5.7 likely to become 0.12.6 'real soon now') ?

@jirutka
Copy link

jirutka commented Jul 14, 2016

@sgerrand I wonder, why do you maintain sgerrand/alpine-pkg-R when we already have R package in official Alpine repository?

@sgerrand
Copy link

sgerrand commented Jul 14, 2016

@sgerrand I wonder, why do you maintain sgerrand/alpine-pkg-R when we already have R package in official Alpine repository?

Mainly because that package predated my packaging efforts, it is still only
in the edge branch and not publicly released.

@eddelbuettel
Copy link
Member

This is all getting a little too inside-baseball for Rcpp so I am going to lock this discussion here.

As it stands, Rcpp appears to be twice compiled right for Alpine we're all a happy family now.

@RcppCore RcppCore locked and limited conversation to collaborators Jul 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants