From owner-freebsd-bugs@freebsd.org Fri Jan 15 21:50:17 2021 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D30214F3A76 for ; Fri, 15 Jan 2021 21:50:17 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4DHZbs5SkCz3sJ5 for ; Fri, 15 Jan 2021 21:50:17 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id BB83A4F3F8A; Fri, 15 Jan 2021 21:50:17 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BB4BA4F3C4D for ; Fri, 15 Jan 2021 21:50:17 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DHZbs4r9Vz3sFS for ; Fri, 15 Jan 2021 21:50:17 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9925D23C03 for ; Fri, 15 Jan 2021 21:50:17 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 10FLoHS1011919 for ; Fri, 15 Jan 2021 21:50:17 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 10FLoHYU011917 for bugs@FreeBSD.org; Fri, 15 Jan 2021 21:50:17 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 252720] powerpc64 gcc toolchain thinks it is little-endian Date: Fri, 15 Jan 2021 21:50:17 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 12.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: jmmv@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jan 2021 21:50:17 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D252720 Bug ID: 252720 Summary: powerpc64 gcc toolchain thinks it is little-endian Product: Base System Version: 12.1-RELEASE Hardware: powerpc OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: jmmv@FreeBSD.org I recently got a PowerMac G5 (powerpc64 big-endian). I was able to install 12.1-RELEASE successfully (the powerpc64 build; there is no powerpc64le dua= lity in 12) on it. I was also able to download the sources for stable/12, do a w= hole buildworld, and then an installworld. Everything was flawless! But after the upgrade to 12.2-STABLE from sources, I am unable to buildworld again and other things seem randomly broken (pkg cannot load its database a= ny longer). buildworld fails like: =3D=3D=3D> kerberos5/tools/make-roken (obj,all,install) objcopy --strip-debug --add-gnu-debuglink=3Dmake-roken.debug make-roken.fu= ll make-roken objcopy: unsupported e_type *** [make-roken] Error code 1 I dug around a bit and found that libelf seems to have been compiled for a little-endian target: when it checks the e_type of the binary, it gets 0x200 when in reality it should be getting a 0x2. And indeed, after some more poking, it seems that the gcc toolchain that sh= ips with 12.1-RELEASE thinks it's targeting a little endian machine: g5:~> cat test.c=20 #include int main(void) { #if __BYTE_ORDER__ =3D=3D __ORDER_LITTLE_ENDIAN__ printf("little!\n"); #elif __BYTE_ORDER__ =3D=3D __ORDER_BIG_ENDIAN__ printf("big!\n"); #else printf("what?\n"); #endif } With the 12.1-RELEASE toolchain: g5:~> /usr/bin/cc --version cc (GCC) 4.2.1 20070831 patched [FreeBSD] Copyright (C) 2007 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. g5:~> /usr/bin/cc test.c && ./a.out little! ^^^ THIS IS WRONG! ^^^ With the gcc9 compiler installed from pkg: g5:~> /usr/local/bin/gcc9 --version gcc9 (FreeBSD Ports Collection) 9.3.0 Copyright (C) 2019 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. g5:~> /usr/local/bin/gcc9 test.c && ./a.out big! ^^^ THIS IS RIGHT ^^^ After the upgrade to stable/12, the compiler still thinks it's targeting a little-endian machine. What's interesting, though, is that the binaries that the compiler produces _are_ big-endian -- or else nothing would run. However, the __BYTE_ORDER__ macro is wrong. Any thoughts on where the problem may be and how to get out of this situati= on? It looks like I cannot use the base system's compiler to buildworld to upgr= ade (or for that matter, to build anything). --=20 You are receiving this mail because: You are the assignee for the bug.=