From owner-freebsd-ppc@freebsd.org Tue Dec 15 18:48:22 2015 Return-Path: Delivered-To: freebsd-ppc@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 D4991A48637 for ; Tue, 15 Dec 2015 18:48:22 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: from asp.reflexion.net (outbound-mail-211-151.reflexion.net [208.70.211.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 985C514C1 for ; Tue, 15 Dec 2015 18:48:22 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: (qmail 5154 invoked from network); 15 Dec 2015 18:48:26 -0000 Received: from unknown (HELO mail-cs-02.app.dca.reflexion.local) (10.81.19.2) by 0 (rfx-qmail) with SMTP; 15 Dec 2015 18:48:26 -0000 Received: by mail-cs-02.app.dca.reflexion.local (Reflexion email security v7.80.0) with SMTP; Tue, 15 Dec 2015 13:48:20 -0500 (EST) Received: (qmail 9098 invoked from network); 15 Dec 2015 18:48:20 -0000 Received: from unknown (HELO iron2.pdx.net) (69.64.224.71) by 0 (rfx-qmail) with SMTP; 15 Dec 2015 18:48:20 -0000 X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network Received: from [192.168.1.8] (c-76-115-7-162.hsd1.or.comcast.net [76.115.7.162]) by iron2.pdx.net (Postfix) with ESMTPSA id 623DF1C43BC; Tue, 15 Dec 2015 10:48:17 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: powerpc64: powerpc64-gcc, gcc49, gcc5 bind -m32 -mcpu=powerpc a.out to /libexec/ld-elf32.so.1 instead of /libexec/ld-elf.so.1 From: Mark Millard Date: Tue, 15 Dec 2015 10:48:20 -0800 Cc: FreeBSD PowerPC ML , FreeBSD Toolchain Content-Transfer-Encoding: quoted-printable Message-Id: <436094AA-A35B-4586-8B88-38B8E31A009E@dsl-only.net> References: <0FA30C32-6F18-43CC-A2F7-3E424FF59021@dsl-only.net> To: freebsd-ports@freebsd.org X-Mailer: Apple Mail (2.2104) X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Dec 2015 18:48:22 -0000 [This is mostly a re-titling of an earlier freebsd-pcc/freebsd-toolchain = message to correctly identify the problem. I also added the = freebsd-ports list and some content.] On 2015-Dec-15, at 4:36 AM, Konstantin Belousov = wrote: > On Mon, Dec 14, 2015 at 11:06:51PM -0800, Mark Millard wrote: >=20 > # more main.c > int main() > { > return 0; > } >=20 > . . . >> By contrast powerpc64-gcc binds the a.out produced to = /libexec/ld-elf32.so.1 instead: >>=20 >> # ls -l `which gcc` >> lrwxr-xr-x 1 root wheel 48 Dec 5 05:38 /usr/bin/gcc -> = /usr/local/bin/powerpc64-portbld-freebsd11.0-gcc >>=20 >> # gcc --version >> gcc (FreeBSD Ports Collection for powerpc64) 5.2.0 >> Copyright (C) 2015 Free Software Foundation, Inc. >> This is free software; see the source for copying conditions. There = is NO >> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR = PURPOSE. >>=20 >> # gcc -m32 -mcpu=3Dpowerpc main.c >> # file a.out >> a.out: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 = (FreeBSD), dynamically linked, interpreter /libexec/ld-elf32.so.1, = FreeBSD-style, for FreeBSD 11.0 (1100091), not stripped >=20 > This is a bug in gcc, most likely in the spec file. All FreeBSD > ABIs use either /libexec/ld-elf.so.1 or (for older versions) > /usr/libexec/ld-elf.so.1. If 32 bit code on powerpc64 is supposed to use /libexec/ld-elf.so.1 just = like the 64 bit code is supposed to then. . . Looks like lang/gcc49 has the same -m32 -mcpu=3Dpowerpc ld-elf32.so.1 = problem as powerpc64-gcc: # grep ld-elf = /usr/obj/portswork/usr/ports/lang/gcc49/work/gcc-4.9-20151202/gcc/config/r= s6000/freebsd64.h #define FREEBSD_DYNAMIC_LINKER32 "/libexec/ld-elf32.so.1" #define FREEBSD_DYNAMIC_LINKER64 "/libexec/ld-elf.so.1" # grep ld-elf = /usr/obj/portswork/usr/ports/lang/gcc49/work/stage/usr/local/lib/gcc49/gcc= /powerpc64-portbld-freebsd11.0/4.9.4/plugin/include/config/rs6000/freebsd6= 4.h #define FREEBSD_DYNAMIC_LINKER32 "/libexec/ld-elf32.so.1" #define FREEBSD_DYNAMIC_LINKER64 "/libexec/ld-elf.so.1" Since powerpc64-gcc is a variant build of gcc5 and also has the above = sort of freebsd64.h content, lang/gcc5 likely has the problem too. (By contrast the powerpc64 system clang (3.7) binds its -m32 = -mcpu-powerpc a.out output file to /libexec/ld-elf.so.1 .) Just for reference, my new patch-gcc-freebsd-powerpc64 variant looks = like the following (tabs likely not preserved): # svnlite diff /usr/ports/devel/powerpc64-gcc Index: /usr/ports/devel/powerpc64-gcc/files/patch-gcc-freebsd-powerpc64 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /usr/ports/devel/powerpc64-gcc/files/patch-gcc-freebsd-powerpc64 = (revision 403711) +++ /usr/ports/devel/powerpc64-gcc/files/patch-gcc-freebsd-powerpc64 = (working copy) @@ -1,5 +1,5 @@ ---- gcc/config/rs6000/freebsd64.h 2015-11-28 09:06:13.019999000 = -0800 -+++ gcc/config/rs6000/freebsd64.h 2015-11-28 09:16:10.459373000 = -0800 +--- freebsd64.h.orig 2015-01-05 04:33:28.000000000 -0800 ++++ freebsd64.h 2015-12-15 09:52:34.634200000 -0800 @@ -65,6 +65,13 @@ #define INVALID_64BIT "-m%s not supported in this configuration" #define INVALID_32BIT INVALID_64BIT @@ -27,3 +27,21 @@ if (rs6000_isa_flags & OPTION_MASK_EABI) \ { \ rs6000_isa_flags &=3D ~OPTION_MASK_EABI; \ +@@ -154,7 +167,7 @@ + { "link_os_freebsd_spec32", LINK_OS_FREEBSD_SPEC32 }, = \ + { "link_os_freebsd_spec64", LINK_OS_FREEBSD_SPEC64 }, +=20 +-#define FREEBSD_DYNAMIC_LINKER32 "/libexec/ld-elf32.so.1" ++#define FREEBSD_DYNAMIC_LINKER32 "/libexec/ld-elf.so.1" + #define FREEBSD_DYNAMIC_LINKER64 "/libexec/ld-elf.so.1" +=20 + #define LINK_OS_FREEBSD_SPEC_DEF32 "\ +@@ -304,7 +317,7 @@ +=20 + /* rs6000.h gets this wrong for FreeBSD. We use the GCC defaults = instead. */ + #undef WCHAR_TYPE +-#define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int") ++#define WCHAR_TYPE "int" + #undef WCHAR_TYPE_SIZE + #define WCHAR_TYPE_SIZE 32 +=20 The same sort of changes should apply to gcc49 and gcc5. The WCHAR_TYPE change fixes the powerpc (non-64) base type used for = notations like L". . ." to match FreeBSD's powerpc/powerpc64 context. = Otherwise lib32 in buildworld gets compile errors from the type = mismatches --and lots of extra warnings as well. =3D=3D=3D Mark Millard markmi at dsl-only.net On 2015-Dec-15, at 4:36 AM, Konstantin Belousov = wrote: On Mon, Dec 14, 2015 at 11:06:51PM -0800, Mark Millard wrote: > # more main.c > int main() > { > return 0; > } >=20 >=20 >=20 > # ls -l `which cc` > -r-xr-xr-x 7 root wheel 54137976 Dec 14 00:06 /usr/bin/cc >=20 > # cc --version > FreeBSD clang version 3.7.0 (tags/RELEASE_370/final 246257) 20150906 > Target: powerpc64-unknown-freebsd11.0 > Thread model: posix >=20 > # cc -m32 -mcpu=3Dpowerpc main.c > # file a.out > a.out: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 = (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, = FreeBSD-style, for FreeBSD 11.0 (1100091), not stripped >=20 >=20 >=20 > By contrast powerpc64-gcc binds the a.out produced to = /libexec/ld-elf32.so.1 instead: >=20 > # ls -l `which gcc` > lrwxr-xr-x 1 root wheel 48 Dec 5 05:38 /usr/bin/gcc -> = /usr/local/bin/powerpc64-portbld-freebsd11.0-gcc >=20 > # gcc --version > gcc (FreeBSD Ports Collection for powerpc64) 5.2.0 > Copyright (C) 2015 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There = is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR = PURPOSE. >=20 > # gcc -m32 -mcpu=3Dpowerpc main.c > # file a.out > a.out: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 = (FreeBSD), dynamically linked, interpreter /libexec/ld-elf32.so.1, = FreeBSD-style, for FreeBSD 11.0 (1100091), not stripped >=20 This is a bug in gcc, most likely in the spec file. All FreeBSD ABIs use either /libexec/ld-elf.so.1 or (for older versions) /usr/libexec/ld-elf.so.1. >=20 > Context details: >=20 > # freebsd-version -ku; uname -aKU > 11.0-CURRENT > 11.0-CURRENT > FreeBSD FBSDG5C0 11.0-CURRENT FreeBSD 11.0-CURRENT #1 r291891M: Wed = Dec 9 09:15:33 PST 2015 = root@FBSDG5C0:/usr/obj/xtoolchain/powerpc.powerpc64/usr/src/sys/GENERIC64v= tsc-NODEBUG powerpc 1100091 1100091 >=20 > # pkg info powerpc64-gcc > powerpc64-gcc-5.2.0_1 > Name : powerpc64-gcc > Version : 5.2.0_1 > Installed on : Wed Dec 9 02:18:14 2015 PST > Origin : devel/powerpc64-gcc > Architecture : freebsd:11:powerpc:64 > Prefix : /usr/local > Categories : devel > . . . >=20 > =3D=3D=3D > Mark Millard > markmi at dsl-only.net >=20 > _______________________________________________ > freebsd-toolchain@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain > To unsubscribe, send any mail to = "freebsd-toolchain-unsubscribe@freebsd.org"