How to enable -flto in presence of hand-written assembly files (RiscV backend)?

Hello Everyone
I am currently trying to develop a whole-application analysis at link time by enabling the -flto flag. But as part of my application, I have hand-written assembly files, for which also I use the same flags which I had used to compile the C files, i.e.: -flto, -march=rv64gc -mno-relax. But at the link stage I get the following error:

Hard-float ‘d’ ABI can’t be used for a target that doesn’t support the D instruction set extension (ignoring target-abi)
ld.lld: error: lto.tmp lto.tmp: cannot link object files with different floating-point ABI

The following is the final linking command I use:
clang -mcmodel=medany main.o crc_32.o -fuse-ld=lld -flto -mno-relax --gcc-toolchain=$(RISCV) -march=rv64gc -o kernel_baseline -static -nostdlib -nostartfiles -Wl,-Lbaremetal-linker-riscv -Wl,-Tbaremetal-linker-riscv/linker.x -Wl,--start-group libnolibc.a libboot.a -Wl,--end-group -lm -lgcc

The handwritten assembly file is part of libboot.a. libnolibc.a, main.o, crc32.o are all compiled with -flto, -march=rv64gc and -mno-relax flags.

Any suggestion on how I can go about enabling LTO in the presence of hand-written assembly files would be really helpful.

Thanking you
Sai

The problem isn’t the hand-written assembly, it’s that LTO does not properly preserve the ABI in LLVM IR so the non-assembly files don’t work. This is a long-standing deficiency in LLVM that affects RISC-V most because it has a set of ABIs per OS, unlike other targets that are less parameterised.

Thanks, @jrtc27. The LTO plugin is working now.

-Sai