Page MenuHomeFreeBSD

Enable /usr/lib32 for o32 binaries on mips64.
ClosedPublic

Authored by jhb on Jan 3 2017, 7:03 PM.

Details

Summary

Build and install an o32 set of libraries on mips64 suitable for running
o32 binaries via COMPAT_FREEBSD32. Enable COMPAT_FREEBSD32 in MALTA64.

Test Plan
  • Run mips o32 binaries under a MALTA64 kernel in qemu.

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 updated this revision to Diff 23581.Jan 3 2017, 7:03 PM
jhb retitled this revision from to Enable /usr/lib32 for o32 binaries on mips64..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added reviewers: jmallett, adrian.
jhb added inline comments.
Makefile.libcompat
43 ↗(On Diff #23581)

I could perhaps move the OBJCOPY bits out of the .ifdef, though if I did that I would probably just make that part MI as it's the same value on amd64 and powerpc as well.

jmallett accepted this revision.Jan 4 2017, 3:46 AM
jmallett edited edge metadata.

This looks good to me, though it'd be nice to see the default ISA thing resolved or confirmed. I also do favour collapsing the target emulation stuff more as possible, but it's not worth holding this up.

Makefile.libcompat
37 ↗(On Diff #23581)

I think this is wrong. Do we in other places use -march=mips64 as the default for 64-bit MIPS? I thought we used MIPS III as the base target ISA for 64-bit MIPS, in which case we'd certainly want likewise for the o32 libs for an otherwise-unspecified 64-bit MIPS system. But then, I'm basically of the belief that TARGET_CPUTYPE ought to be required on MIPS. What does GCC default to?

This revision is now accepted and ready to land.Jan 4 2017, 3:46 AM
jhb added inline comments.Jan 4 2017, 5:33 PM
Makefile.libcompat
37 ↗(On Diff #23581)

I'm not sure what we use as the base as it is some local hack we have to gcc 4.2.1 to set the default ABI. To use an external toolchain I have to set a default CPUTYPE when building (so just using TARGET_ARCH=mips fails to build with external GCC for example). I have a pending patch to set a minimum -march= in bsd.cpu.mk. My guess was to use -march=mips32 for o32 and -march=mips64 for n64/n32. If you have a better suggestion we can use something else.

jmallett added inline comments.Jan 4 2017, 5:59 PM
Makefile.libcompat
37 ↗(On Diff #23581)

It looks like with GCC in base we internally use the ISA "from-abi", except for 32-bit binaries, for which we default to mips3, so we don't end up with MIPS I ISA awfulness. So I suppose we should use -march=mips3 here, to match gnu/usr.bin/cc/Makefile.inc.

jhb added inline comments.Jan 4 2017, 7:56 PM
Makefile.libcompat
37 ↗(On Diff #23581)

Hmmm, ok. In this case we know are building for a 64-bit capable CPU though (e.g. on FreeBSD/amd64 the 32-bit libc can assume SSE2 is present even though it's not available on all i386 CPUs because the lib32 libc will only be present on amd64 CPUs which do always have SSE2). Not sure if there is a minimum -march= setting for 64-bit mips that is above mips3. If not, I'm fine with using mips3.

bdrewery accepted this revision.Jan 4 2017, 8:16 PM
bdrewery edited edge metadata.

This made me notice that hier(7) is missing /usr/lib32, but it is a separate issue.

jmallett added inline comments.Jan 4 2017, 8:55 PM
Makefile.libcompat
37 ↗(On Diff #23581)

MIPS-III is the 32-bit and 64-bit baseline for FreeBSD, so it's appropriate here. We depend on MIPS-III features, and anything above that is optional, and requires a CPUTYPE be specified.

jhb updated this revision to Diff 23675.Jan 6 2017, 8:06 PM
jhb edited edge metadata.
  • Rebase.
  • Use mips3 instead of mips64 as default -march.
  • Pull OBJCOPY override out if .ifdef.
This revision now requires review to proceed.Jan 6 2017, 8:06 PM
jmallett accepted this revision.Jan 6 2017, 8:07 PM
jmallett edited edge metadata.
This revision is now accepted and ready to land.Jan 6 2017, 8:07 PM
imp accepted this revision.Jan 6 2017, 10:16 PM
imp edited edge metadata.

This looks good, modulo one or two nits. The unrelated changes can be lumped in if it's a big hassle. The emulation stuff is OK to go in, but it will likely get grumps from kan@.

Makefile.libcompat
11–16 ↗(On Diff #23675)

Perhaps this should be done as a separate commit, since it is not mips related.

26–28 ↗(On Diff #23675)

likewise.

43 ↗(On Diff #23675)

This undoes, a little, kan@'s moves to not specify the name here because it's inconsistent between internal and external toolchains.

jhb added inline comments.Jan 6 2017, 11:16 PM
Makefile.libcompat
11–16 ↗(On Diff #23675)

Hmm, I can.

43 ↗(On Diff #23675)

No, this works fine with external GCC./binutils. The thing that is different is the internal name in linker scripts (upstream binutils appends "-freebsd" to the OUTPUT_FORMAT() string). The linker emulation names are the same for both.

This revision was automatically updated to reflect the committed changes.