From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BF0AF385C426; Sun, 19 Apr 2020 14:42:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF0AF385C426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587307357; bh=tSqlr3X6Y8U2sIx2hKexJfwX7cnQW1y5Igb0KueIIiw=; h=From:To:Subject:Date:From; b=Ab9b4gLOfSqUvVzqNN9TR46ljqzQeiaaZZWcjOlcZgKBBOIJ+XoddX71XHbmeAymP OqjRHYu7KWGtZNXq1Mqz5PbuHBgr4P2LWebAlb6gW51s1Ouhk9P5zXLchn3CJ23l2/ j4bZvVaoITZpwkrJIAdJiRSMBCZIzHqV/v51p/Zk= From: "yyc1992 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/94659] New: Missing symbol with LTO and target_clones Date: Sun, 19 Apr 2020 14:42:37 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: 9.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yyc1992 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Apr 2020 14:42:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94659 Bug ID: 94659 Summary: Missing symbol with LTO and target_clones Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: yyc1992 at gmail dot com CC: marxin at gcc dot gnu.org Target Milestone: --- This is basically the same as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D80732 except now it only hap= pens with LTO enabled. It seems that if a function with `target_clones` attribute isn't used in the final library and if LTO is enabled, the function will be missing from the resulting library. Only the `.resolver` symbol appears. The test code is ``` // b.c __attribute__((target_clones("default,avx"))) int f1() { return 2; } ``` when compiled with `gcc -g -flto -O3 -fPIC b.c -shared -o libb-lto.so`, the exported symbols available are, ``` $ objdump -T libb-lto.so libb-lto.so: file format elf64-x86-64 DYNAMIC SYMBOL TABLE: 0000000000000000 w D *UND* 0000000000000000=20=20=20=20=20=20=20=20=20= =20=20=20=20 _ITM_deregisterTMCloneTable 0000000000000000 w D *UND* 0000000000000000 __gmon_start__ 0000000000000000 w D *UND* 0000000000000000=20=20=20=20=20=20=20=20=20= =20=20=20=20 _ITM_registerTMCloneTable 0000000000000000 w DF *UND* 0000000000000000 GLIBC_2.2.5 __cxa_finalize 0000000000001730 g DF .text 000000000000002b Base f1.resolver ``` Compared to the output lilbrary from `gcc -g -O3 -fPIC b.c -shared -o libb.= so` ``` $ objdump -T libb.so libb.so: file format elf64-x86-64 DYNAMIC SYMBOL TABLE: 0000000000000000 w D *UND* 0000000000000000=20=20=20=20=20=20=20=20=20= =20=20=20=20 _ITM_deregisterTMCloneTable 0000000000000000 w D *UND* 0000000000000000 __gmon_start__ 0000000000000000 w D *UND* 0000000000000000=20=20=20=20=20=20=20=20=20= =20=20=20=20 _ITM_registerTMCloneTable 0000000000000000 w DF *UND* 0000000000000000 GLIBC_2.2.5 __cxa_finalize 0000000000001730 w DF .text 000000000000002b Base f1.resolver 0000000000001730 g iD .text 000000000000002b Base f1 ``` The exported symbol has the wrong name for the LTO version. `dlsym` result confirms the difference. If the function is used somewhere else in the library, the resulting symbol will then looks the same as the non-LTO version.=