On Sun, Aug 25, 2019 at 9:40 AM Jim Wilson <j...@sifive.com> wrote: > The problem with the linux toolchain support for -msave-restore is > that we forgot to add a version script to export the symbols. I made > the obvious change to add a RISC-V specific libgcc version script, and > now everything in the g++ and gfortran testsuites are linking, but the > execution tests are all timing out. So there is still something > wrong. I need to do some more work here.
Following up on this, I found a linker bug where it was emitting error messages for non-pic code in shared libraries, but wasn't exiting with an error, so bad shared libraries were being produced without killing the build. I wrote and committed a binutils patch to fix that. The underlying problem is that the save/restore functions were always called as non-pic, even for a shared library. But fixing that produced shared libraries that failed again, which turned out because the save/restore functions use the alternate link register t0/x5 which is clobbered by plts, so we can't call them in shared libraries at all. I wrote and committed a gcc patch to disable -msave-restore when -fpic is used, and emit a warning message if the user explicitly turned on -msave-restore. Since we can't use the save/restore functions in shared libraries, we don't need to export them or support pic calls to them, and I dropped those patches. With these changes I'm now able to do -msave-restore testing with a linux toolchain. Testing with and without your patch for a riscv64-linux toolchain, I see 11 extra gcc failures, 2 extra g++ failures, and 8 extra gfortran failures. I didn't look at the details. I suspect that most of these are failing for the same reason, and there is only a couple of minor bugs that need to be fixed to make your patch work. Jim