Page MenuHomeFreeBSD

Add 32-bit mips support to base/binutils and base/gcc.
ClosedPublic

Authored by jhb on May 2 2018, 4:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 18, 2:38 PM
Unknown Object (File)
Sat, Nov 16, 7:52 PM
Unknown Object (File)
Fri, Nov 15, 6:19 AM
Unknown Object (File)
Tue, Nov 5, 3:36 AM
Unknown Object (File)
Wed, Oct 30, 2:24 PM
Unknown Object (File)
Wed, Oct 30, 2:21 PM
Unknown Object (File)
Wed, Oct 30, 1:53 PM
Unknown Object (File)
Sep 20 2024, 6:28 AM

Details

Summary
NOTE: This is a WIP set of patches that is still under testing, but is a snapshot of what I have so far. I do think it is probably getting close but I may need more changes to get base/gcc fully working.
  • When cross-building packages, set ARCH to the target arch instead of the arch of the build host. This fixes bsd.ssp.mk on MIPS which was trying to enable SSP on MIPS cross-built packages because the host ARCH was amd64. A new HOST_ARCH variable is added to set the --build triple for configure scripts, but I believe most other uses of ARCH in ports are really about the target, not the build host so this is the more correct general direction.
  • Some updates to base/binutils and base/gcc to use ARCH as the target architecture.
  • Drop the extra arguments to GCC to set include and library paths and only set --sysroot.
  • Move the --sysroot flags into CC, CXX, CPP (which is now set to XCPP) and LD instead of passing it in CFLAGS, etc. The base/gcc build uses ends up using the CFLAGS when building native binaries for the build host which fails when tripping over the --sysroot. I think this might have accidentally worked before because the powerpc64 headers in /usr/include/machine were "close enough" to the amd64 headers, but with 32-bit MIPS this failed hard.
  • Add the GCC MIPS patch from devel/powerpc64-gcc to base/gcc to add MIPS support to base/gcc.
  • Add a MIPS plist for base/binutils.
  • Set helper variables for the base/gcc plist to tag architecture-specific headers (e.g. for intrinsincs) and use these to tag powerpc and MIPS specific headers. (It would be nicer if we could have a "base" pkg-plist and then arch-specific pkg-list.<arch> if there is a clean way to do this.)
  • Drop the include-fixed headers.
  • Strip /usr/local/include from the default list of include paths.
  • Use libc++'s include path for C++.
Test Plan
  • cross-built ports-mgmt/pkg, base/binutils, and base/gcc
  • installed cross-built packages into a MIPS qemu instance
  • tested simple hello world compiles with installed toolchain (C works, C++ does not yet)

Diff Detail

Repository
rP FreeBSD ports repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

So this actually now works for me (I hadn't tested the C++ fixes when I uploaded this). I think most of the patches (ones trying to adjust CFLAGS) can be removed from base/gcc now due to the change to move --sysroot out of CFLAGS/CXXFLAGS and will test that next. Beyond that I think the only other test is to do a buildworld inside of QEMU mips (which will take a weekend or more), so I would like to start getting review feedback. I do believe that while the ARCH change is kind of a big change, it only affects ports built via CROSS_TOOLCHAIN which we only support for base/* and ports-mgmt/pkg right now. (I tried building devel/gdb using CROSS_* but we don't support building packages that have build dependencies via CROSS_* yet so it failed, but it was otherwise working until it couldn't find a suitable MIPS libexpat)

This builds OK for me and the changes make sense. I can test building powerpc64 stuff if you like.

I first need to check if that does not break "simple" cross building, but a part from that it looks fine. I'll try to check asap.

Mk/bsd.port.mk
1104–1110 ↗(On Diff #42067)

Adding spaces into CC, CXX, CPP, and LD will break many port builds as I found when bringing in ccache support.

Mk/bsd.port.mk
1104–1110 ↗(On Diff #42067)

Hmm, it seemed to work for the 3 that matter in this case (base/* and ports-mgmt/pkg). It also worked for devel/gdb up until the point that it didn't have the necessary dependency packages. Note that this change only kicks in when using CROSS_TOOLCHAIN, so it is only applicable to the few packages we want to cross-build.

After some test cross building still works for me :)

Mk/bsd.port.mk
1104–1110 ↗(On Diff #42067)

It is supposed to work and if a port is not respecting that it should be fixed.
Given this is only working with CROSS_TOOLCHAIN then why this is fine.

Not that iirc most of the time the case that breaks with space are issue in the port's Makefile and not in upstream code, so trivial to fix.
IMHO this should not block this review to be committed.

This revision is now accepted and ready to land.May 4 2018, 5:23 PM
This revision was automatically updated to reflect the committed changes.