Page MenuHomeFreeBSD

Add a new "riscv-relaxations" linker feature.
ClosedPublic

Authored by jhb on Dec 3 2019, 10:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 22 2024, 3:31 PM
Unknown Object (File)
Dec 25 2023, 10:20 PM
Unknown Object (File)
Dec 20 2023, 5:20 AM
Unknown Object (File)
Dec 14 2023, 10:24 AM
Unknown Object (File)
Nov 8 2023, 6:45 PM
Unknown Object (File)
Nov 6 2023, 5:26 AM
Unknown Object (File)
Nov 4 2023, 4:13 AM
Unknown Object (File)
Oct 7 2023, 5:38 PM

Details

Summary

When the linker doesn't have this feature, add -mno-relax to CFLAGS
on RISC-V.

Define the feature for ld.bfd, but not lld. When lld gains relaxation
support in a newer version, we can enable it for those versions of lld
in bsd.linker.mk.

Test Plan
  • build and booted world + kernel built with clang and lld

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

share/mk/bsd.cpu.mk
380 ↗(On Diff #65185)

Does this also need to go in AFLAGS? I see it's only being set for MIPS's endianness/ABI flags, when a bunch of other flags in here would seem appropriate, so perhaps it's not needed and CFLAGS is passed through, but however the assembler is invoked by the build system, -mno-relax must be present when assembling too.

share/mk/bsd.cpu.mk
380 ↗(On Diff #65185)

In general FreeBSD's build no longer uses as directly but always uses the compiler driver for assembly files, so AFLAGS isn't really used. There is an ACFLAGS for assembly-specific flags to pass to the compiler driver, but that is passed in addition to CFLAGS. I know that GCC requires the extra -Wa that you used, but I don't really expect folks to use lld with GCC on FreeBSD, more to either use GCC + bfd or use clang + lld.

share/mk/bsd.cpu.mk
380 ↗(On Diff #65185)

Yes, I was not commenting on the -Wa,-mno-relax requirement for GCC+LLD, which is a highly unusual combination. So long as the compiler is used as the driver then I'm happy.

There isn't really a precedent for arch-specific linker features, but I don't think it's an issue. Do you know how long it might be before we see support for relaxations in lld? If it's not long, could we not just check for lld directly instead of using a linker feature?

This revision is now accepted and ready to land.Dec 5 2019, 12:07 AM

There isn't really a precedent for arch-specific linker features, but I don't think it's an issue. Do you know how long it might be before we see support for relaxations in lld? If it's not long, could we not just check for lld directly instead of using a linker feature?

I don't know of anyone actively working on it, so it could well be a while, but equally someone could turn up tomorrow out of nowhere with a patch. I also don't know how amenable LLD is to linker relaxation, as the data structures may not like the idea that input sections can change in size (and instructions can move within them, with their associated relocations, as a result). But I suspect it's unlikely to be happening within a year.

This revision was automatically updated to reflect the committed changes.