Command to switch lib in gcc to get profiling data

Hi,
I was trying to use the -gp command for the SiFive board to compile my program and produce profiling data. I downloaded the prebuilt RISCV GCC Toolchain for windows from the Sifive website. I used the command:
riscv64-unknown-elf-gcc.exe -pg helloworld.c -o helloworld
Unfortunately I got an error:
“undefined reference to `_mcount’”
I saw in another discussion that this is because glibc isn’t supported in riscv-elf-gcc and to use linux-gcc instead. But in the prebuilt version from Sifive, there doesn’t seem to be a linux-gcc present.
Is there a way of switching libraries form newlib to glibc for e.g. using a command.

gprof increments counters at run-time, and then saves them to a file at program exit. That makes it complicated to implement for embedded targets, as they often don’t have a file system. There are ways to make this work, using semihosting to make the file system writes work, or using gdb to attach to the target break in exit and manually save the data to a file inside gdb. But this stuff all takes work, and no one has done every piece of it yet as far as I know, at least not in the toolchains we build.

You can’t switch from newlib to glibc for embedded work. glibc doesn’t support embedded development.

gprof does work for linux targets. We currently don’t provide pre-built linux cross compilers though. Linux cross compilers are complicated, as every linux system is different, and a cross compiler typically can only work perfectly for one linux system target. We can build linux cross compilers for use with simulators like qemu and spike/pk, and we are planning to do that with our next release

Meanwhile, if you want a linux cross compiler you can try building it from source using github.com/riscv/riscv-gnu-toolchain. This is much harder to do if you are using macos or windows though. It is primarily designed to build on linux.

Or, if you have recent enough linux OS install, then your distro may have a riscv64-linux cross compiler you can install. Unbuntu 18.04 has a gcc-riscv64-linux-gnu package you can install. On a mac or windows machine, you could run linux inside a container (like virtualbox) to do the same thing, or use. Windows Subsystem for Linux on a windows machine,

thanks for the info!