Giter VIP home page Giter VIP logo

Comments (11)

cnaw avatar cnaw commented on September 27, 2024 1

@rtobar These are the CFLAGS for each compilation: one has the lto, the other does not:

4.3.2

  • CFLAGS: -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer

4.2.3

  • CFLAGS: -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection

from rwcs.

rtobar avatar rtobar commented on September 27, 2024 1

Thanks @cnaw for confirming the issue can be bypassed with the -fno-lto option. I'll still follow this up on our side, users shouldn't need to do/remove compilation flags for our package to be installed.

from rwcs.

rtobar avatar rtobar commented on September 27, 2024

@cnaw Thanks for reporting this.

This seems to be a clash between R and wcslib both choosing to name a global variable CAR. C doesn't provide namespaces, so unless you prefix your global names, or make them static so they don't escape your translation unit, they'll prevent others from using those names.

The ideal solution is that this clash doesn't happen. There's no point on trying to change R's internals, that's an uphill battle most probably due to many reasons. But we might have a better chance changing wcslib. I'll check if this is something that an be changed upstream, but worst-case scenario we can patch our embedded sources to prevent the issue.

While I haven't looked into the header differences, if they don't affect the definition of CAR then there must be another explanation as to why this didn't happen before. One possibility is that, in your system, R 4.3 compiles extensions with LTO, but 4.2 doesn't, but I can't tell if the latter is true from your message. Could you confirm that's the case? Thanks!

from rwcs.

rtobar avatar rtobar commented on September 27, 2024

Awesome, that makes sense then.

As a workaround, and if you need to compile for 4.3.2 in your system, you could pass -flto=no (I'm assuming the value "no", maybe it's a different one) in your CXXFLAGS / CXX11FLAGS in your ~/.R/Makevars to override the LTO behaviour and hopefully get a successful compilation.

from rwcs.

cnaw avatar cnaw commented on September 27, 2024

Thanks for the tip. I have been trying with -flto -flto=no and the code still does not compile. This is an example :
Installing package into ‘/home/cnaw/R/x86_64-redhat-linux-gnu-library/4.3’
(as ‘lib’ is unspecified)

  • installing source package ‘Rwcs’ ...
    ** using staged installation
  • Running configure on Linux
  • R_HOME: /usr/lib64/R
  • R_ARCH:
  • R_ARCH_BIN:
  • CC: gcc
  • CFLAGS: -O3 -Wall -mtune=native -march=native -Ofast -std=gnu99 -flto
  • AR:
    checking build system type... x86_64-pc-linux-gnu
    checking host system type... x86_64-pc-linux-gnu
    checking for flex... flex
    configure: Using Flex version 2.6.4.
    checking for gcc... gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... configure: error: in /tmp/RtmpLiPEWb/R.INSTALL19d1173a0d4be/Rwcs/src/wcslib': configure: error: cannot run C compiled programs. If you meant to cross compile, use --host'.
    See `config.log' for more details
    ERROR: configuration failed for package ‘Rwcs’
  • removing ‘/home/cnaw/R/x86_64-redhat-linux-gnu-library/4.3/Rwcs’
    Warning message:
    In i.p(...) :
    installation of package ‘/tmp/RtmpOa1vbt/file19c937957190f/Rwcs_1.7.0.tar.gz’ had non-zero exit status
    ...
    I cannot find the "config.log" to understand what is the error - I have the impression that it is stored in the /tmp file which gets erased. Is there any additional parameter that I should be adding to ~/.R/Makevars ?

from rwcs.

rtobar avatar rtobar commented on September 27, 2024

What about -fno-lto? That's apparently the correct syntax, sorry for the wrong guess earlier.

from rwcs.

rtobar avatar rtobar commented on September 27, 2024

Another update: I edited my ~/.R/Makevars to:

CXXFLAGS=-Wall -O3 -g -flto
CXX11FLAGS=-Wall -O3 -g -flto
CFLAGS=-Wall -O3 -g -flto

and that reproduced the issue. I then edited it like this:

CXXFLAGS=-Wall -O3 -g -flto -fno-lto
CXX11FLAGS=-Wall -O3 -g -flto -fno-lto
CFLAGS=-Wall -O3 -g -flto -fno-lto

and the problem was gone.

from rwcs.

cnaw avatar cnaw commented on September 27, 2024

Thanks, this did make the magic work!
These are the contents of ~/.R/Makevars that make the compilation successful:

CC = gcc
CXX = g++
CXX1X = g++
CXX11 = g++

CXXFLAGS=-Wall -O3 -g -flto -fno-lto
CXX11FLAGS=-Wall -O3 -g -flto -fno-lto
CFLAGS=-Wall -O3 -g -flto -fno-lto -fexceptions -g -grecord-gcc-switches -pipe -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer

I had to do this as a normal user rather than running sudo R.
(any potential future users be aware that CFLAGS is a single line, e.g. -Wp,-U_FORTIFY_SOURCE, etc.)
Thanks a lot for your help! I will close the issue.

from rwcs.

rtobar avatar rtobar commented on September 27, 2024

@cnaw if you have some time, could you try compiling the lto-fix branch of this repository with R 4.3.2 without the extra compilation flags? After that's successful I'll merge to master. Note that I've also asked Mark Callabreta to upstream this change in wcslib itself for good measure.

from rwcs.

cnaw avatar cnaw commented on September 27, 2024

@rtobar I did this as a user:

git clone -b lto-fix https://github.com/asgr/Rwcs.git
tar -zcvf Rwcs_1.70_fix.tar.gz Rwcs
mv ~/.R/Makevars ~/.R/org_Makevars
cd R
R
library(devtools)
install.packages("/home/cnaw/Rwcs_1.70_fix.tar.gz",repos=NULL,type="source")
...

  • CFLAGS: -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
    ...
  • DONE (Rwcs)
    ...
    To have an independent confirmation that the new fixes work I tried again, this time as superuser (yesterday the installation failed as su). With the new fixes it works! Thank you for keeping on top of this!

from rwcs.

rtobar avatar rtobar commented on September 27, 2024

Great, thanks for the confirmation @cnaw, I've merged the fix to master now.

from rwcs.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.