From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758734AbcAKJpW (ORCPT ); Mon, 11 Jan 2016 04:45:22 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:60241 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757491AbcAKJpV (ORCPT ); Mon, 11 Jan 2016 04:45:21 -0500 Message-ID: <56937977.1040203@huawei.com> Date: Mon, 11 Jan 2016 17:44:23 +0800 From: "Wangnan (F)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Jiri Olsa CC: , , , , , , Namhyung Kim Subject: Re: [PATCH 1/6] perf tools: Add -lutil in python lib list for broken python-config References: <1452263041-225488-1-git-send-email-wangnan0@huawei.com> <1452263041-225488-2-git-send-email-wangnan0@huawei.com> <20160111092841.GC15415@krava.brq.redhat.com> In-Reply-To: <20160111092841.GC15415@krava.brq.redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.56937995.0083,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: ce86273b30dc6545846e6da1ce336613 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/1/11 17:28, Jiri Olsa wrote: > On Fri, Jan 08, 2016 at 02:23:56PM +0000, Wang Nan wrote: >> On some system the perf-config is broken, causes link failure like this: >> >> /usr/lib64/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_forkpty': >> /opt/wangnan/yocto-build/tmp-eglibc/work/x86_64-oe-linux/python/2.7.3-r0.3.1/Python-2.7.3/./Modules/posixmodule.c:3816: undefined reference to `forkpty' >> /usr/lib64/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_openpty': >> /opt/wangnan/yocto-build/tmp-eglibc/work/x86_64-oe-linux/python/2.7.3-r0.3.1/Python-2.7.3/./Modules/posixmodule.c:3756: undefined reference to `openpty' >> collect2: error: ld returned 1 exit status >> make[1]: *** [/home/wangnan/kernel-hydrogen/tools/perf/out/perf] Error 1 >> make: *** [all] Error 2 >> >> $ python-config --libs >> -lpthread -ldl -lpthread -lutil -lm -lpython2.7 > so your 'python-config --libs' shows -lutil and you still get the build failure? > > after your fix I can see double -lutil in PYTHON_EMBED_LIBADD, > which is probably not a problem but could be ommited I think In my python-config: # python-config -lpthread -ldl -lpthread -lutil -lm -lpython2.7 There are multiple -lpthread already. In fact multiple '-l' options is not a problem at all. Please see below. >> In this case a '-lutil' should be appended to -lpython2.7. >> >> (I know we have --start-group and --end-group. I can see them in >> command line of collect2 by strace. However it doesn't work. Seems >> I have a broken environment?) > hum, how is this related to start/end -group options? Please check man page of ld: --start-group archives --end-group The archives should be a list of archive files. They may be either explicit file names, or -l options. The specified archives are searched repeatedly until no new undefined references are created. Normally, an archive is searched only once in the order that it is specified on the command line. If a symbol in that archive is needed to resolve an undefined symbol referred to by an object in an archive that appears later on the command line, the linker would not be able to resolve that reference. By grouping the archives, they all be searched repeatedly until all possible references are resolved. Using this option has a significant performance cost. It is best to use it only when there are unavoidable circular references between two or more archives. Without --start/end-group, if we provide -l in this order: ... -la -lb -lc ... and libb.a requires a symbol in liba.a, link would fail. The simplest way to avoid this is to add another -la after -lb: ... -la -lb -la -lc ... In my environment it works as if we don't provide -Wl--start-group and -Wl,--end-group. I don't know why. Thank you.