Page MenuHomeFreeBSD

Compile hack.c with normal CFLAGS + -shared -nostdlib.

Authored by jhb on Jan 25 2020, 10:23 AM.



Originally, hack.c was compiled into a shard object with just -shared
-nostdlib. This assumed that ${CC} did not require any additional
flags for ABIs, cross-building, etc.

When was created in r89509 by reducing duplication in
kernel Makefile.<arch> files, the -shared flag was moved into a
HACK_EXTRA_FLAGS variable so that sparc64 could override it with
-Wl,-shared. The sparc64 hack was removed in r111650, but
HACK_EXTRA_FLAGS was left in place. Over time, we have started
support toolchains that require flags to support alternate ABIs on
MIPS and PowerPC and started (ab)using HACK_EXTRA_FLAGS to set only
those flags.

I need to fix risc-v to pass -mno-relax to the hack.c build for lld in
llvm 10, and the patches to support cross-build from non-FreeBSD hosts
need to include -target for clang in CFLAGS for hack.c. Rather than
adding more hacks into HACK_EXTRA_FLAGS, just use the full set of
CFLAGS with hack.c.

Test Plan
  • make tinderbox
  • CheriBSD has used a similar-ish change (it copied the expresion from genoffsets.c to strip lto and one other flag, but I don't think those matter for the empty hack.c case)

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jhb created this revision.Jan 25 2020, 10:23 AM
kib accepted this revision.Jan 25 2020, 10:39 AM

BTW I think that pico extension is not correct (as much as extension can be).

This revision is now accepted and ready to land.Jan 25 2020, 10:39 AM
arichardson accepted this revision.Jan 25 2020, 11:27 AM

Yes I agree, removing the LTO option is not necessary.
I think in I just copied from the genassym.o line.

jhb added a comment.Jan 26 2020, 2:17 PM

It used to be .So but was changed to .pico in In this particular case there isn't a .so that it would collide with, so it could go back to .So perhaps, but I'm not going to bother with that anytime soon.

This revision was automatically updated to reflect the committed changes.