Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
272 views
in Technique[技术] by (71.8m points)

gcc - Why does R package `qtlbim` installation fail locally but succeed in a docker container?

I'm struggling to understand why I'm able to install an R package, qtlbim from Github when running a docker rocker container but unable to install the same package when running R on my desktop (outside docker).

I see this in the terminal when running R in the rocker container:

remotes::install_github("fboehm/qtlbim")
Downloading GitHub repo fboehm/qtlbim@HEAD
Running `R CMD build`...
* checking for file ‘/tmp/Rtmprg1Xz8/remotes1086cb13f8a/fboehm-qtlbim-d9077cf/DESCRIPTION’ ... OK
* preparing ‘qtlbim’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* looking to see if a ‘data/datalist’ file should be added
* building ‘qtlbim_2.0.7.tar.gz’
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘qtlbim’ ...
** using staged installation
** libs
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c GlobalVars.c -o GlobalVars.o
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c GlobalVars_SingleTrait.c -o GlobalVars_SingleTrait.o
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c MatrixUtils.c -o MatrixUtils.o
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c MultipleTraitsMCMC.c -o MultipleTraitsMCMC.o
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RMultipleTraitsMCMCSetup.c -o RMultipleTraitsMCMCSetup.o
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c ROutputManager.c -o ROutputManager.o
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RSingleTraitMCMCSetup.c -o RSingleTraitMCMCSetup.o
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c SingleTraitMCMC.c -o SingleTraitMCMC.o
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c SingleTraitMCMCSamplingRoutines.c -o SingleTraitMCMCSamplingRoutines.o
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c StatUtils.c -o StatUtils.o
gcc -shared -L/usr/local/lib/R/lib -L/usr/local/lib -o qtlbim.so GlobalVars.o GlobalVars_SingleTrait.o MatrixUtils.o MultipleTraitsMCMC.o RMultipleTraitsMCMCSetup.o ROutputManager.o RSingleTraitMCMCSetup.o SingleTraitMCMC.o SingleTraitMCMCSamplingRoutines.o StatUtils.o -L/usr/local/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/00LOCK-qtlbim/00new/qtlbim/libs
** R
** data
** demo
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (qtlbim)

but I then see this when trying to install in a R session outside docker:

remotes::install_github("CRAN/qtlbim")
Using github PAT from envvar GITHUB_PAT
Downloading GitHub repo CRAN/qtlbim@HEAD
?  checking for file ‘/tmp/RtmpUF0v2l/remotes34e8051627d66/cran-qtlbim-afb635d/DESCRIPTION’ ...
─  preparing ‘qtlbim’:
?  checking DESCRIPTION meta-information ...
─  cleaning src
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  looking to see if a ‘data/datalist’ file should be added
─  building ‘qtlbim_2.0.7.tar.gz’
   
Installing package into ‘/home/fred/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
* installing *source* package ‘qtlbim’ ...
** using staged installation
** libs
gcc -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3BoT6Y/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c GlobalVars.c -o GlobalVars.o
gcc -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3BoT6Y/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c GlobalVars_SingleTrait.c -o GlobalVars_SingleTrait.o
gcc -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3BoT6Y/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c MatrixUtils.c -o MatrixUtils.o
gcc -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3BoT6Y/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c MultipleTraitsMCMC.c -o MultipleTraitsMCMC.o
gcc -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3BoT6Y/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RMultipleTraitsMCMCSetup.c -o RMultipleTraitsMCMCSetup.o
gcc -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3BoT6Y/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c ROutputManager.c -o ROutputManager.o
gcc -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3BoT6Y/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RSingleTraitMCMCSetup.c -o RSingleTraitMCMCSetup.o
gcc -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3BoT6Y/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c SingleTraitMCMC.c -o SingleTraitMCMC.o
gcc -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3BoT6Y/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c SingleTraitMCMCSamplingRoutines.c -o SingleTraitMCMCSamplingRoutines.o
gcc -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-3BoT6Y/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c StatUtils.c -o StatUtils.o
gcc -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o qtlbim.so GlobalVars.o GlobalVars_SingleTrait.o MatrixUtils.o MultipleTraitsMCMC.o RMultipleTraitsMCMCSetup.o ROutputManager.o RSingleTraitMCMCSetup.o SingleTraitMCMC.o SingleTraitMCMCSamplingRoutines.o StatUtils.o -L/usr/lib/R/lib -lR
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:34: multiple definition of `Y'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:77: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:73: multiple definition of `AMU'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:30: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:43: multiple definition of `GVALUE'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:79: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:56: multiple definition of `QCHR'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:13: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:52: multiple definition of `COEF'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:9: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:83: multiple definition of `MAIN'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:40: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:75: multiple definition of `GAMMA'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:32: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:95: multiple definition of `GAMMA_EPISTASIS'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:54: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:93: multiple definition of `EPISTATIC'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:52: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:103: multiple definition of `GAMMA_GBYE'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:64: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:67: multiple definition of `GBYE_FIX'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:24: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:77: multiple definition of `VE'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:34: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:87: multiple definition of `VMAIN'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:44: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:97: multiple definition of `VEPISTASIS'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_SingleTrait.c:56: first defined here
/usr/bin/ld: MultipleTraitsMCMC.o:/tmp/RtmpBf0FKz/R.INSTALL45ef74784e70f/qtlbim/src/GlobalVars_MultipleTraits.h:105: multiple definition of `V_GBYE_FIX'; GlobalVars_SingleTrait.o:/tmp/RtmpBf0FK

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your code is falling victim to a change in gcc that turned what had been a warning into an error. In short, you cannot define a global variable in multiple 'compilation units' anymore but have to define it just once and then use extern to refer to it. (And Brian Ripley, who follows development version of gcc and clang had forced all CRAN maintainers with similar setups to make these changes way back in December 2019, several months before gcc-10 was released. We also had a similar need for change in Debian and Ubuntu when the default changed. It is a bit of a pain, but likely worth it...)

Now, there is an override for this: adding -fcommon should help you here. See this page for details: https://gcc.gnu.org/gcc-10/porting_to.html

Edit: Indeed, quick proof is here:

edd@rob:/tmp/qtlbim(master)$ cat src/Makevars 
PKG_CFLAGS = -fcommon
edd@rob:/tmp/qtlbim(master)$ ls -l src/*so
-rwxrwxr-x 1 edd edd 191400 Jan 24 12:09 src/qtlbim.so
edd@rob:/tmp/qtlbim(master)$ lsb_release --all
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.10
Release:        20.10
Codename:       groovy
edd@rob:/tmp/qtlbim(master)$ 

The last few lines of R CMD INSTALL . end in

[... earlier lines and warnings omitted ...]
ccache gcc -Wl,-S -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o qtlbim.so GlobalVars.o GlobalVars_SingleTrait.o MatrixUtils.o MultipleTraitsMCMC.o RMultipleTraitsMCMCSetup.o ROutputManager.o RSingleTraitMCMCSetup.o SingleTraitMCMC.o SingleTraitMCMCSamplingRoutines.o StatUtils.o -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/00LOCK-qtlbim/00new/qtlbim/libs
** R
** data
** demo
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (qtlbim)
edd@rob:/tmp/qtlbim(master)$ 

(and you can ignore that I use ccache).

Edit 2: And having come this far I just made a minimal PR at your repo with that change. You may need to the same for src/Makevars.win and should be able to just copy the file. You can test at win-builder or RHub.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...