From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carl Dong Subject: bug#37999: clang fails to pickup/supply startfiles to ld Date: Wed, 30 Oct 2019 20:48:55 +0000 Message-ID: Reply-To: Carl Dong Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:54423) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPuuu-0007uI-N9 for bug-guix@gnu.org; Wed, 30 Oct 2019 16:50:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPuur-0001oH-V0 for bug-guix@gnu.org; Wed, 30 Oct 2019 16:50:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42826) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iPuuo-0001gO-LP for bug-guix@gnu.org; Wed, 30 Oct 2019 16:50:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iPuuo-0000nW-IG for bug-guix@gnu.org; Wed, 30 Oct 2019 16:50:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:54261) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iPutw-0006zh-6x for bug-guix@gnu.org; Wed, 30 Oct 2019 16:49:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iPutu-0008Py-PA for bug-guix@gnu.org; Wed, 30 Oct 2019 16:49:07 -0400 Received: from mail4.protonmail.ch ([185.70.40.27]:25891) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iPuts-0008HB-0j for bug-guix@gnu.org; Wed, 30 Oct 2019 16:49:04 -0400 List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: 37999@debbugs.gnu.org Hi all, Our clang toolchain seems to be quite broken at this time. In particular, i= t fails to call `ld` in the right way such that the startfiles are picked up: --8<---------------cut here---------------start------------->8--- $ guix environment --pure --container --ad-hoc clang@6 binutils -- clang++ = -v -Xlinker --verbose ... "/gnu/store/8aj9slzwi5vnmi5iszc5jh3hrvndj29c-profile/bin/ld" =09--eh-frame-hdr =09-m elf_x86_64 =09-dynamic-linker /lib64/ld-linux-x86-64.so.2 =09-o a.out =09crt1.o =09crti.o =09/gnu/store/64xzk1kwk30n7arqgmxs2qy7wzcnc8i3-gcc-7.4.0-lib/lib/gcc/x86_64= -unknown-linux-gnu/7.4.0/crtbegin.o =09-L/gnu/store/64xzk1kwk30n7arqgmxs2qy7wzcnc8i3-gcc-7.4.0-lib/lib/gcc/x86_= 64-unknown-linux-gnu/7.4.0 =09-L/gnu/store/64xzk1kwk30n7arqgmxs2qy7wzcnc8i3-gcc-7.4.0-lib/lib/gcc/x86_= 64-unknown-linux-gnu/7.4.0/../../.. =09-L/gnu/store/zki2b9r9lkdxnb23sqc8xs99xs9s5x03-clang-6.0.1/bin/../lib =09--verbose =09-L/gnu/store/8aj9slzwi5vnmi5iszc5jh3hrvndj29c-profile/lib =09-lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc =09/gnu/store/64xzk1kwk30n7arqgmxs2qy7wzcnc8i3-gcc-7.4.0-lib/lib/gcc/x86_64= -unknown-linux-gnu/7.4.0/crtend.o =09crtn.o ... attempt to open crt1.o failed /gnu/store/8aj9slzwi5vnmi5iszc5jh3hrvndj29c-profile/bin/ld: cannot find crt= 1.o: No such file or directory attempt to open crti.o failed /gnu/store/8aj9slzwi5vnmi5iszc5jh3hrvndj29c-profile/bin/ld: cannot find crt= i.o: No such file or directory ... attempt to open /gnu/store/64xzk1kwk30n7arqgmxs2qy7wzcnc8i3-gcc-7.4.0-lib/l= ib/gcc/x86_64-unknown-linux-gnu/7.4.0/libm.so failed attempt to open /gnu/store/64xzk1kwk30n7arqgmxs2qy7wzcnc8i3-gcc-7.4.0-lib/l= ib/gcc/x86_64-unknown-linux-gnu/7.4.0/libm.a failed attempt to open /gnu/store/64xzk1kwk30n7arqgmxs2qy7wzcnc8i3-gcc-7.4.0-lib/l= ib/gcc/x86_64-unknown-linux-gnu/7.4.0/../../../libm.so failed attempt to open /gnu/store/64xzk1kwk30n7arqgmxs2qy7wzcnc8i3-gcc-7.4.0-lib/l= ib/gcc/x86_64-unknown-linux-gnu/7.4.0/../../../libm.a failed attempt to open /gnu/store/zki2b9r9lkdxnb23sqc8xs99xs9s5x03-clang-6.0.1/bin= /../lib/libm.so failed attempt to open /gnu/store/zki2b9r9lkdxnb23sqc8xs99xs9s5x03-clang-6.0.1/bin= /../lib/libm.a failed attempt to open /gnu/store/8aj9slzwi5vnmi5iszc5jh3hrvndj29c-profile/lib/lib= m.so failed attempt to open /gnu/store/8aj9slzwi5vnmi5iszc5jh3hrvndj29c-profile/lib/lib= m.a failed attempt to open /gnu/store/mx2bgrpxkbdjsmhlxp9a30hbzcilk4cn-binutils-2.32/x= 86_64-unknown-linux-gnu/lib64/libm.so failed attempt to open /gnu/store/mx2bgrpxkbdjsmhlxp9a30hbzcilk4cn-binutils-2.32/x= 86_64-unknown-linux-gnu/lib64/libm.a failed attempt to open /no-ld-lib-path/libm.so failed attempt to open /no-ld-lib-path/libm.a failed attempt to open /gnu/store/mx2bgrpxkbdjsmhlxp9a30hbzcilk4cn-binutils-2.32/x= 86_64-unknown-linux-gnu/lib/libm.so failed attempt to open /gnu/store/mx2bgrpxkbdjsmhlxp9a30hbzcilk4cn-binutils-2.32/x= 86_64-unknown-linux-gnu/lib/libm.a failed /gnu/store/8aj9slzwi5vnmi5iszc5jh3hrvndj29c-profile/bin/ld: cannot find -lm ... --8<---------------cut here---------------end--------------->8--- I believe this is because we have crt1.o, crti.o, and limb.so in the output= of our glibc package, which clang seems unaware of. I don't know exactly how to fix this, but I did some digging in the clang codebase (cfe-6.0.1 to be exact), and found that the crt1.o, crti.o argumen= ts are added in lib/Driver/ToolChains/Gnu.cpp. These arguments are constructed using something like Args.MakeArgString(ToolChain.GetFilePath("crti.o")), which really calls Driver::GetFilePath in lib/Driver/Driver.cpp under the hood. Meaning that w= e just need to make Driver::GetFilePath aware of our glibc path and return th= e correct full path to crt1.o and crti.o. If anyone can help out here it would be much appreciated. Cheers, Carl Dong contact@carldong.me "I fight for the users"