From owner-freebsd-mips@freebsd.org Fri Dec 23 22:13:45 2016 Return-Path: Delivered-To: freebsd-mips@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5C070C8EF26 for ; Fri, 23 Dec 2016 22:13:45 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 35615A79; Fri, 23 Dec 2016 22:13:45 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id E718B10AA47; Fri, 23 Dec 2016 17:13:43 -0500 (EST) From: John Baldwin To: freebsd-mips@freebsd.org Subject: External toolchain friendliness and /usr/lib32 for mips64 Date: Fri, 23 Dec 2016 14:13:38 -0800 Message-ID: <2978934.3KKo4yUUSV@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Fri, 23 Dec 2016 17:13:44 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Dec 2016 22:13:45 -0000 I have a set of patches (currently tied together, but could be split into two chunks) for MIPS builds that do two things: 1) Be more external toolchain-friendly by explicitly specifying the desired endianness and ABI both to the compiler and the linker. This means we don't depend on the default target of a toolchain matching the desired target arch. Previously, I had to explicitly specify a TARGET_CPUTYPE for 32-bit mips when using mips-xtoolchain-gcc, but with the ABI set explicitly simply 'TARGET_ARCH=mips' is sufficient. This also means that you can now use 'mips-xtoolchain-gcc' to build mips64 (without requiring the separate mips64-xtoolchain-gcc), and you can build mipsn32 with gcc from ports (we don't have a binutils or gcc port for mips that defaults to mipsn32 currently). 2) Add build glue for /usr/lib32 on mips64. This builds and installs an o32 set of libraries and rtld (of matching endianness) in /usr/lib32. I have tested the latter with the MALTA64 kernel config (just adding COMPAT_FREEBSD32) under qemu and am able to run 32-bit binaries just fine. Note that for 1), there is still the case that if we build a compiler via the base/ ports, we want the default output to match the host, so we would need a mips64-specific base/gcc separate from the mips one (and we need a mipsn32 set of packages). One annoyance is in the sys/boot/beri ldscripts. In-tree binutils uses 'elf64-trad*mips' for its ABIs on FreeBSD while upstream biutils uses 'elf64-trad*mips-freebsd'. However, the ldscripts are already being linked with a linker that is using 64-bit MIPS (and are only built for "mips64"), so the OUTPUT_FORMAT() isn't really needed and can just be removed. I'd probably want to also remove OUTPUT_ARCH() as well as I think that would be most consistent. The patches are at: https://github.com/freebsd/freebsd/compare/master...bsdjhb:mips_lib32 -- John Baldwin