GAMS-dev / transfer-r

gamstransfer: data exchange between GAMS and R
2 stars 0 forks source link

Error when compiling (Ubuntu 24.04) #2

Open pat-s opened 1 month ago

pat-s commented 1 month ago

Any idea?

using C++ compiler: 'g++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0'
using C++17
ccache gcc -I"/opt/R/4.4.1/lib/R/include" -DNDEBUG -I./gdx/src -Igdx/src/rtl -I. -I'/opt/R/4.4.1/lib/R/library/Rcpp/include' -I/usr/local/include    -fPIC  -g -O2  -flax-vector-conversions -c gdx/src/rtl/dtoaLoc.c -o gdx/src/rtl/dtoaLoc.o
ccache g++ -std=gnu++17 -I"/opt/R/4.4.1/lib/R/include" -DNDEBUG -I./gdx/src -Igdx/src/rtl -I. -I'/opt/R/4.4.1/lib/R/library/Rcpp/include' -I/usr/local/include   -DNDEBUG -fPIC  -g -O2   -c gdx/src/rtl/p3io.cpp -o gdx/src/rtl/p3io.o
ccache g++ -std=gnu++17 -I"/opt/R/4.4.1/lib/R/include" -DNDEBUG -I./gdx/src -Igdx/src/rtl -I. -I'/opt/R/4.4.1/lib/R/library/Rcpp/include' -I/usr/local/include   -DNDEBUG -fPIC  -g -O2   -c gdx/src/rtl/p3utils.cpp -o gdx/src/rtl/p3utils.o
ccache g++ -std=gnu++17 -I"/opt/R/4.4.1/lib/R/include" -DNDEBUG -I./gdx/src -Igdx/src/rtl -I. -I'/opt/R/4.4.1/lib/R/library/Rcpp/include' -I/usr/local/include   -DNDEBUG -fPIC  -g -O2   -c gdx/src/rtl/sysutils_p3.cpp -o gdx/src/rtl/sysutils_p3.o
ccache g++ -std=gnu++17 -I"/opt/R/4.4.1/lib/R/include" -DNDEBUG -I./gdx/src -Igdx/src/rtl -I. -I'/opt/R/4.4.1/lib/R/library/Rcpp/include' -I/usr/local/include   -DNDEBUG -fPIC  -g -O2   -c gdx/src/rtl/p3platform.cpp -o gdx/src/rtl/p3platform.o
ccache g++ -std=gnu++17 -I"/opt/R/4.4.1/lib/R/include" -DNDEBUG -I./gdx/src -Igdx/src/rtl -I. -I'/opt/R/4.4.1/lib/R/library/Rcpp/include' -I/usr/local/include   -DNDEBUG -fPIC  -g -O2   -c gdx/src/rtl/math_p3.cpp -o gdx/src/rtl/math_p3.o
ccache g++ -std=gnu++17 -I"/opt/R/4.4.1/lib/R/include" -DNDEBUG -I./gdx/src -Igdx/src/rtl -I. -I'/opt/R/4.4.1/lib/R/library/Rcpp/include' -I/usr/local/include   -DNDEBUG -fPIC  -g -O2   -c gdx/src/gdlib/gmsstrm.cpp -o gdx/src/gdlib/gmsstrm.o
gdx/src/gdlib/gmsstrm.cpp:85:70: error: narrowing conversion of '-1' from 'std::char_traits<char>::int_type' {aka 'int'} to 'char' [-Wnarrowing]
   85 | constexpr static char substChar {/*0x1A*/ std::char_traits<char>::eof()};
      |                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
make: *** [/opt/R/4.4.1/lib/R/etc/Makeconf:204: gdx/src/gdlib/gmsstrm.o] Error 1
0x17 commented 1 month ago

Thanks for reporting. You compile on an ARM CPU? Anyways, I can't thoroughly investigate right now. As a quick fix I would recommend assigning 255 or 0xFF to "substChar" to make the build pass. I will take a closer look on Wednesday and see if our code should be modified for machines where char is unsigned by default.

pat-s commented 1 month ago

You compile on an ARM CPU?

Yes, sorry for missing that initially.

As a quick fix I would recommend assigning 255 or 0xFF to "substChar" to make the build pass.

I am building binaries from CRAN sources, so making local modifications is not an option. Not urgent, but would be great to resolve this error in the build chain :)

0x17 commented 1 month ago

Thank you for confirming the platform. I will look into getting the reported compilation failure resolved with the next GDX release. It might take a couple days as I am afk until Wednesday but @abhosekar and I should be able to quickly deploy afterwards.

Thank you for reporting again. I will also comb the rest of GDX (and other projects I maintain) for usages of char that were assuming it to always be signed and test compile with GCC on arm, to make sure you won't get another follow up error.

I am not 100% sure why this didn't show up before on the arm64 macOS builds we do with AppleClang. Something else to look into. 😀

pat-s commented 1 month ago

I am not 100% sure why this didn't show up before on the arm64 macOS builds we do with AppleClang. Something else to look into. 😀

arm64 macOS uses clang instead of gcc and both operate differently in some ways, the reported cased being one of them.

Thanks for fixing it!