From nobody Fri Feb 10 09:23:29 2023 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PCpFH013Fz3pL1S for ; Fri, 10 Feb 2023 09:23:31 +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 4PCpFG0lV5z3Pyc for ; Fri, 10 Feb 2023 09:23:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676021010; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ue78fNOGF9/KbhAtM8qESXs22FpahLVk3MIpmHTjKuU=; b=wolb2tr144lm6dsPr6xN4WX1MqDJTAl4tft+ZU2M0tQHzYvM15vOEWxHu3BDaI7Z5HOMSN QZHTJoOnyXNzVIcBnRj5QEo6Lb41PbOqXrQwauVyiFpsh7Ll6AWLoOEb3n3cjBP23o3n+x kESNo3TYqdwZpOOC20J4WzmYLp702XiHJwCOPaFj68K14SayQ+w1bwTANQNtrVrDTIRJeF vxPcqAcwMpoqaR00Hl4tZwPyaf8GBb+LLDE5JwgHJ1aMbkbTiBv25CEZgtUSXNDbyK8rui 6LjHKLBtZtpT/Tq74YuRgsga/zP+7fm33i3vlhxTXMqxqWHUBbc4+l1u0bK0Aw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676021010; a=rsa-sha256; cv=none; b=a2sDCGbKxklsx9LhznwFRkGJLOKRc2As46basneqroG2Kj3jrOImhSFv8Dr4/EpRnOX4KF uj+1WUmWXCG3kP41ZZfr2PUhfxYY0Ci5cr4H41iloyrZYOgkDopAJMPajl3MR96pV/QYZT cX9ep5uGRWPqiiqce1a7rkclXdVd/CR2zv+3A6M+5xJ18sgPUN+JGOPd4JcQHQri4n0nAW rSd/p/A9+sSQ0zTXxKbEi8OrzdL8CzsRNiubK5osXM9X//k/RYAlUW49twH5SdpDCXilP9 v6l9FchfX08BncPk1uVWhrFbgCRz/Yz21Z7hHMyPtH5fdOuouYK2M34ZyUu/0g== 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 4PCpFF4GQ4z1C63 for ; Fri, 10 Feb 2023 09:23:29 +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 31A9NTFC028823 for ; Fri, 10 Feb 2023 09:23:29 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 31A9NTWs028822 for bugs@FreeBSD.org; Fri, 10 Feb 2023 09:23:29 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 269455] Using LTO on powerpc64 generates broken binaries Date: Fri, 10 Feb 2023 09:23:29 +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: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: pkubaj@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 List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D269455 Bug ID: 269455 Summary: Using LTO on powerpc64 generates broken binaries Product: Base System Version: CURRENT Hardware: powerpc OS: Any Status: New Severity: Affects Many People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: pkubaj@FreeBSD.org This is a repost of https://github.com/llvm/llvm-project/issues/46697. I'm creating a PR here, because it turns out that LTO itself works fine when using lld from ports, but is broken with the base lld (lld 15 is also affected). It looks like it has affected powerpc64 ever since the GCC -> LL= VM switch (so LLVM 9), but I never tried linking with ports lld until now. I have a simple test program: int main() { return 0; } and do: root@talos-powerpc64:~ # clang -fuse-ld=3D/usr/local/bin/ld.lld15 -flto tes= t.c root@talos-powerpc64:~ # ./a.out root@talos-powerpc64:~ # clang -flto test.c root@talos-powerpc64:~ # ./a.out Segmentation fault (core dumped) I also deassembled both binaries and did a diff: --- baselld.S 2023-02-09 23:53:53.171611000 +0100 +++ portslld.S 2023-02-09 23:53:58.827662000 +0100 @@ -1,5 +1,5 @@ -a.out2: file format elf64-powerpc +a.out: file format elf64-powerpc Disassembly of section .text: @@ -20,7 +20,7 @@ 10010558: fb df 00 60 std 30, 96(31) 1001055c: 7c be 2b 78 mr 30, 5 ; if (environ =3D=3D NULL) -10010560: e8 a4 80 70 ld 5, -32656(4) +10010560: e8 a4 80 58 ld 5, -32680(4) 10010564: fb 9f 00 50 std 28, 80(31) 10010568: 28 25 00 00 cmpldi 5, 0 1001056c: 7c 7c 1b 78 mr 28, 3 @@ -33,7 +33,7 @@ ; if (environ =3D=3D NULL) 10010588: 40 82 00 0c bf 2, 0x10010594 <_start+0x68> ; environ =3D env; -1001058c: 38 64 80 70 addi 3, 4, -32656 +1001058c: 38 64 80 58 addi 3, 4, -32680 10010590: fb c3 00 00 std 30, 0(3) ; if (argc > 0 && argv[0] !=3D NULL) { 10010594: 2c 1c 00 01 cmpwi 28, 1 @@ -65,7 +65,7 @@ 100105e0: 41 82 00 10 bt 2, 0x100105f0 <_start+0xc4> ; __ps_strings =3D ps_strings; 100105e4: 3c 62 00 01 addis 3, 2, 1 -100105e8: 38 63 80 68 addi 3, 3, -32664 +100105e8: 38 63 80 50 addi 3, 3, -32688 100105ec: f9 03 00 00 std 8, 0(3) ; if (&_DYNAMIC !=3D NULL) 100105f0: 3c 62 ff ff addis 3, 2, -1 @@ -95,8 +95,8 @@ 10010640: 3f 42 00 01 addis 26, 2, 1 ; for (; aux->a_type !=3D AT_NULL; aux++) { 10010644: 7c 63 f2 14 add 3, 3, 30 -10010648: 38 9b 80 78 addi 4, 27, -32648 -1001064c: 38 ba 80 7c addi 5, 26, -32644 +10010648: 38 9b 80 60 addi 4, 27, -32672 +1001064c: 38 ba 80 64 addi 5, 26, -32668 10010650: 38 63 ff f8 addi 3, 3, -8 10010654: 48 00 00 10 b 0x10010664 <_start+0x138> 10010658: 7c a7 2b 78 mr 7, 5 @@ -144,9 +144,9 @@ ; target =3D ((ifunc_resolver_t)ptr)(cpu_features, cpu_featur= es2, 100106e0: 7d 89 03 a6 mtctr 12 100106e4: 39 20 00 00 li 9, 0 -100106e8: 80 7b 80 78 lwz 3, -32648(27) +100106e8: 80 7b 80 60 lwz 3, -32672(27) 100106ec: 39 40 00 00 li 10, 0 -100106f0: 80 9a 80 7c lwz 4, -32644(26) +100106f0: 80 9a 80 64 lwz 4, -32668(26) 100106f4: 4e 80 04 21 bctrl 100106f8: e8 41 00 18 ld 2, 24(1) ; *where =3D target; @@ -169,10 +169,10 @@ 10010734: 4e 80 04 21 bctrl 10010738: e8 41 00 18 ld 2, 24(1) ; exit(main(argc, argv, env)); -1001073c: 3c 62 00 01 addis 3, 2, 1 +1001073c: 3c 62 ff fe addis 3, 2, -2 10010740: 7f a4 eb 78 mr 4, 29 10010744: 7f c5 f3 78 mr 5, 30 -10010748: 39 83 80 50 addi 12, 3, -32688 +10010748: 39 83 7e 30 addi 12, 3, 32304 1001074c: 7f 83 e3 78 mr 3, 28 10010750: 7d 89 03 a6 mtctr 12 10010754: 4e 80 04 21 bctrl @@ -452,6 +452,8 @@ 10010b04: eb e1 ff f8 ld 31, -8(1) 10010b08: 4e 80 00 20 blr ... + +0000000010010b18
: 10010b18: 38 60 00 00 li 3, 0 10010b1c: 90 61 ff f4 stw 3, -12(1) 10010b20: 38 60 00 00 li 3, 0 For some reason, main function is missing when linked with the base lld. Since this issue is non-existent with lld from ports, it must be because of= how we built LLVM. It only affects powerpc64. powerpc and powerpc64le are not affected. If it's necessary to have access to some powerpc64 system for debugging, I = can arrange it. --=20 You are receiving this mail because: You are the assignee for the bug.=