Closed HenrikBengtsson closed 1 year ago
There's also:
gcc -I"/software/c4/cbi/software/R-4.2.2-gcc10/lib64/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c rowRanksWithTies
.c -o rowRanksWithTies.o
rowRanksWithTies.c: In function ‘SHUFFLE_INT’:
rowRanksWithTies.c:28:10: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t k = i; k < j; k++) {
^
... and
gcc -I"/software/c4/cbi/software/R-4.2.2-gcc10/lib64/R/include" -DNDEBUG -I/usr/local/include -fpic -g -O2 -c validateIndices.c -o validateIndices.o
validateIndices.c: In function ‘validate’:
validateIndices.c:164:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (R_xlen_t i = 0; i < ansNidxs; i++) {
^
validateIndices.c:164:5: note: use option -std=c99 or -std=gnu99 to compile your code
validateIndices.c:192:7: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (R_xlen_t i = 0; i < ansNidxs; i++) {
^
validateIndices.c:204:7: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (R_xlen_t i = 0; i < ansNidxs; i++){
^
make: *** [validateIndices.o] Error 1
The origin of these C99 specifications:
src/naming.c
was introduced in v0.60.1 (2021-08-22)src/validateIndices.c
was modified in v0.60.1 (2021-08-22)src/rowRanksWithTies.c
was modified in v0.55.0 (2019-09-05)Thus, the problem has been there since matrixStats 0.55.0.
I just verified; matrixStats 0.54.0 (2018-07-23) installs with GCC 4.8.5.
I've fixed this the develop branch (commit 67563de)
I consider this more a problem of the compiler flags rather than our source code. Indeed, the source code of the R interpreter requires C99 to compile and uses ‘for’ loop initial declarations just as we did. Additionally, users with gcc 4.8.5 will struggle with all the other R packages which uses features introduced in C99 if they use the same setup. Hence, a better solution is adding -std=c99
to CFLAGS
in the Makeconf
file for the users who struggle with the problem.
Thanks. Yes, we could have done that too. Since we didn't have one, I just decide to "get things done" quickly.
FWIW, not that there are lots of people out there on RHEL/CentOS 7 running modern R version built with modern GCC (via devtoolset SCLs), who still have GCC 4.8.5 as their default. Many of them struggle with installing some R packages, spending hours and days figuring it out, and loading admin support with questions. I figured, matrixStats shouldn't be one of those packages. I only noticed this because I happened to run revdep checks on a machine without SCL support.
Package fails to compile with gcc 4.8.5 (2015), which is the default on RHEL/CentOS 7.9, because:
This shouldn't be hard to fix. It's worth fixing this to remove friction for users on RHEL/CentOS 7.9.
PS. I think this is a regression that happened during the last couple of years.