andrjohns / QuickJSR

R interface for the QuickJS lightweight javascript engine
Other
18 stars 0 forks source link

Compilation error on Red Hat Linux #5

Closed jameslairdsmith closed 9 months ago

jameslairdsmith commented 9 months ago

I've cloned the repo and pulled the submodule on Linux (Red Hat Enterprise 7.9)

When I try to install it I get the following compilation error.

library(devtools)
#> Loading required package: usethis
install("~/QuickJSR/")
#> Skipping 2 packages not available: Rcpp, R6
#> ── R CMD build ─────────────────────────────────────────────────────────────────
#> * checking for file ‘/home/me/QuickJSR/DESCRIPTION’ ... OK
#> * preparing ‘QuickJSR’:
#> * 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
#> * building ‘QuickJSR_1.1.1.tar.gz’
#> Warning: invalid uid value replaced by that for user 'nobody'
#> Warning: invalid gid value replaced by that for user 'nobody'
#> 
#> Running /opt/R/4.0.5/lib/R/bin/R CMD INSTALL \
#>   /tmp/RtmpvRrgxq/QuickJSR_1.1.1.tar.gz --install-tests 
#> * installing to library ‘/home/me/R/x86_64-pc-linux-gnu-library/4.0’
#> * installing *source* package ‘QuickJSR’ ...
#> ** using staged installation
#> ** libs
#> gcc -std=gnu99 -I"/opt/R/4.0.5/lib/R/include" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/me/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c quickjsr_impl.c -o quickjsr_impl.o
#> g++ -std=gnu++11 -I"/opt/R/4.0.5/lib/R/include" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/me/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c quickjsr.cpp -o quickjsr.o
#> g++ -std=gnu++11 -I"/opt/R/4.0.5/lib/R/include" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/me/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c init.cpp -o init.o
#> gcc -std=gnu99 -I"/opt/R/4.0.5/lib/R/include" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/me/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -funsigned-char -fwrapv -std=c11 -c quickjs/cutils.c -o quickjs/cutils.o
#> gcc -std=gnu99 -I"/opt/R/4.0.5/lib/R/include" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/me/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -funsigned-char -fwrapv -std=c11 -c quickjs/libbf.c -o quickjs/libbf.o
#> gcc -std=gnu99 -I"/opt/R/4.0.5/lib/R/include" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/me/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -funsigned-char -fwrapv -std=c11 -c quickjs/libregexp.c -o quickjs/libregexp.o
#> gcc -std=gnu99 -I"/opt/R/4.0.5/lib/R/include" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/me/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -funsigned-char -fwrapv -std=c11 -c quickjs/libunicode.c -o quickjs/libunicode.o
#> gcc -std=gnu99 -I"/opt/R/4.0.5/lib/R/include" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/me/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -funsigned-char -fwrapv -std=c11 -c quickjs/quickjs.c -o quickjs/quickjs.o
#> quickjs/quickjs.c:113:23: fatal error: stdatomic.h: No such file or directory
#>  #include <stdatomic.h>
#>                        ^
#> compilation terminated.
#> make: *** [quickjs/quickjs.o] Error 1
#> ERROR: compilation failed for package ‘QuickJSR’
#> * removing ‘/home/me/R/x86_64-pc-linux-gnu-library/4.0/QuickJSR’
#> Error in c("(function (command = NULL, args = character(), error_on_status = TRUE, ", : ! System command 'R' failed

Created on 2024-01-26 by the reprex package (v2.0.1)

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.5 (2021-03-31) #> os Red Hat Enterprise Linux #> system x86_64, linux-gnu #> ui X11 #> language (EN) #> collate en_GB.UTF-8 #> ctype en_GB.UTF-8 #> tz Europe/London #> date 2024-01-26 #> pandoc 2.19.2 @ /usr/lib/rstudio-server/bin/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> cachem 1.0.6 2021-08-19 [1] CRAN (R 4.0.5) #> callr 3.7.3 2022-11-02 [1] CRAN (R 4.0.5) #> cli 3.6.1 2023-03-23 [1] CRAN (R 4.0.5) #> crayon 1.5.2 2022-09-29 [1] CRAN (R 4.0.5) #> desc 1.4.2 2022-09-08 [1] CRAN (R 4.0.5) #> devtools * 2.4.3 2021-11-30 [2] CRAN (R 4.0.5) #> digest 0.6.34 2024-01-11 [1] CRAN (R 4.0.5) #> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.0.5) #> evaluate 0.23 2023-11-01 [1] CRAN (R 4.0.5) #> fansi 1.0.3 2022-03-24 [1] CRAN (R 4.0.5) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.0.5) #> fs 1.6.1 2023-02-06 [1] CRAN (R 4.0.5) #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.0.5) #> htmltools 0.5.4 2022-12-07 [1] CRAN (R 4.0.5) #> knitr 1.42 2023-01-25 [1] CRAN (R 4.0.5) #> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.0.5) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.0.5) #> memoise 2.0.1 2021-11-26 [1] CRAN (R 4.0.5) #> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.0.5) #> pkgbuild 1.4.2 2023-06-26 [1] CRAN (R 4.0.5) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.5) #> pkgload 1.3.4 2024-01-16 [1] CRAN (R 4.0.5) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.5) #> processx 3.8.2 2023-06-30 [1] CRAN (R 4.0.5) #> ps 1.7.5 2023-04-18 [1] CRAN (R 4.0.5) #> purrr 1.0.1 2023-01-10 [1] CRAN (R 4.0.5) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.0.5) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.0.5) #> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.0.5) #> R.utils 2.12.1 2022-10-30 [1] CRAN (R 4.0.5) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.0.5) #> remotes 2.4.2.1 2023-07-18 [1] CRAN (R 4.0.5) #> rlang 1.1.1 2023-04-28 [1] CRAN (R 4.0.5) #> rmarkdown 2.20 2023-01-19 [1] CRAN (R 4.0.5) #> rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.0.5) #> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.0.5) #> sessioninfo 1.2.2 2021-12-06 [2] CRAN (R 4.0.5) #> styler 1.8.1 2022-11-07 [1] CRAN (R 4.0.5) #> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.0.5) #> usethis * 2.2.2 2023-07-06 [1] CRAN (R 4.0.5) #> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.0.5) #> vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.0.5) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.0.5) #> xfun 0.37 2023-01-31 [1] CRAN (R 4.0.5) #> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.0.5) #> #> [1] /home/me/R/x86_64-pc-linux-gnu-library/4.0 #> [2] /opt/R/4.0.5/lib/R/library #> #> ────────────────────────────────────────────────────────────────────────────── ```
andrjohns commented 9 months ago

What version of gcc do you have installed? I can see that the header was only added in gcc 4.9.

I've updated the package to check the compiler version and disable the atomics if the compiler is too old. Can you try pulling the repo and installing again?

jameslairdsmith commented 9 months ago

GCC info: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44).

I'm aware that's an old gcc version. As an alternative, we do have the option of using RH devtoolset. I'd just need to know what makevars I should change to the devtoolset paths?

jameslairdsmith commented 9 months ago

I've updated the package to check the compiler version and disable the atomics if the compiler is too old. Can you try pulling the repo and installing again?

Still the same error I'm afraid.

andrjohns commented 9 months ago

I'd just need to know what makevars I should change to the devtoolset paths?

I don't use RHEL so I can't help you there, but it's just the normal procedure you would use for changing the compiler for R or an R package for your platform

Still the same error I'm afraid.

Found another header where it was included and pushed another change, can you try again? If it fails again, can you post the install log?

jameslairdsmith commented 9 months ago

It works if I do this with the CC makevar.

library(devtools)
library(withr)

with_makevars(list(CC="/opt/rh/devtoolset-8/root/usr/bin/cc"),{
  install(".")
})
jameslairdsmith commented 9 months ago

Found another header where it was included and pushed another change, can you try again? If it fails again, can you post the install log?

Unfortunately still no luck with this. There might be another header to track down, I'm not sure.

jameslairdsmith commented 9 months ago

Install log:

==> R CMD INSTALL --preclean --no-multiarch --with-keep.source QuickJSR

* installing to library ‘/home/333573/R/x86_64-pc-linux-gnu-library/4.0’
* installing *source* package ‘QuickJSR’ ...
** using staged installation
gcc -std=gnu99 -I"/usr/include/R" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/333573/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c quickjsr_impl.c -o quickjsr_impl.o
** libs
g++ -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/333573/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c quickjsr.cpp -o quickjsr.o
g++ -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/333573/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c init.cpp -o init.o
gcc -std=gnu99 -I"/usr/include/R" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/333573/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -funsigned-char -fwrapv -std=c11 -c quickjs/cutils.c -o quickjs/cutils.o
gcc -std=gnu99 -I"/usr/include/R" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/333573/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -funsigned-char -fwrapv -std=c11 -c quickjs/libbf.c -o quickjs/libbf.o
gcc -std=gnu99 -I"/usr/include/R" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/333573/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -funsigned-char -fwrapv -std=c11 -c quickjs/libregexp.c -o quickjs/libregexp.o
gcc -std=gnu99 -I"/usr/include/R" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/333573/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -funsigned-char -fwrapv -std=c11 -c quickjs/libunicode.c -o quickjs/libunicode.o
gcc -std=gnu99 -I"/usr/include/R" -DNDEBUG -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM  -DCONFIG_VERSION=\"2024-01-13\" -I'/home/333573/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -funsigned-char -fwrapv -std=c11 -c quickjs/quickjs.c -o quickjs/quickjs.o
quickjs/quickjs.c:113:23: fatal error: stdatomic.h: No such file or directory
 #include <stdatomic.h>
                       ^
compilation terminated.
make: *** [quickjs/quickjs.o] Error 1
ERROR: compilation failed for package ‘QuickJSR’
* removing ‘/home/333573/R/x86_64-pc-linux-gnu-library/4.0/QuickJSR’

Exited with status 1.
andrjohns commented 9 months ago

Pushed another update, I checked locally with a CentOS 7 docker container and gcc 4.8.5 and it builds for me now

jameslairdsmith commented 9 months ago

Yes, looks like the install is happening properly now (with or without the custom Makevars set). Thanks a lot for your help and such a speedy response!

andrjohns commented 9 months ago

Great to hear! An updated version of QuickJSR just hit CRAN with these fixes included