Page MenuHomeFreeBSD

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

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

Details

Summary

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 kern.post.mk 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

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
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 https://github.com/CTSRD-CHERI/cheribsd/commit/8041a7e459d1d6e453d082ff57db2f3f94ca1a3c 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 https://svnweb.freebsd.org/base?view=revision&revision=306297. 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.