[Bug 792146]

Chandler Carruth chandlerc at gmail.com
Sun Nov 27 10:48:34 UTC 2011


(In reply to comment #2)
> Looking at current trunk, it looks like something was done about the hardcoded
> list of gcc versions:
> http://llvm.org/viewvc/llvm-project?view=rev&revision=143874
> 
> However, nothing has been done about the hardcoded list of distros and distro
> release files.  There is still
> 
> enum LinuxDistro {
>   ArchLinux,
>   DebianLenny,
>   DebianSqueeze,
>   DebianWheezy,
>   Exherbo,
>   RHEL4,
>   RHEL5,
>   RHEL6,
>   Fedora13,
>   Fedora14,
>   Fedora15,
>   FedoraRawhide,
>   OpenSuse11_3,
>   OpenSuse11_4,
>   OpenSuse12_1,
>   UbuntuHardy,
>   UbuntuIntrepid,
>   UbuntuJaunty,
>   UbuntuKarmic,
>   UbuntuLucid,
>   UbuntuMaverick,
>   UbuntuNatty,
>   UbuntuOneiric,
>   UnknownDistro
> };
> 
> along with code to parse /etc/lsb-release, /etc/redhat-release,
> /etc/debian_version, /etc/SuSE-release, /etc/exherbo-release, and
> /etc/arch-release to detect which of these distros is running.

Much of this code is dead. We don't use the Linux distro detection for
much now other than a few fairly random bits, and I had thought all of
those only cared about distinguishing between suse, ubuntu, debian, and
everything-else.

I'm going to continue cleaning this up as time permits, but what would
help me is if you listed specific actions with Clang which break because
of this. Unless we have something specific that breaks because of this,
I don't think keeping a PR open about the design cruft is all that
useful...

> Maybe a stopgap solution would be to treat unknown Ubuntu releases as
> UbuntuOneiric, unknown Fedora releases as FedoraRawhide, etc. instead of
> categorizing all distros from the future as UnknownDistro.  But I think the
> entire idea of looking at /etc/*-release files to guess the right linker flags
> is a violation of abstraction.

No one is really arguing that it is a good abstraction, but we need to
know the concrete things it breaks. It does actually fix things. My
personal goal is that for large, common Linux distributions no patch or
configuration step is necessary to build a Clang which can compile and
link binaries on that system. Doing this is not easy given the
peculiarities of several distributions' packaging practices (I'm looking
at you Debian/Ubuntu and your multiarch madness). That said, we should
key behavior on the actual detected toolchain of the system, not on the
/etc/...-release files.

-- 
You received this bug notification because you are a member of Ubuntu
Sponsors Team, which is subscribed to a duplicate bug report (896695).
https://bugs.launchpad.net/bugs/792146

Title:
  clang can’t link any programs: cannot find crt1.o, crti.o, crtn.o

Status in The Low Level Virtual Machine Compiler Infrastructure:
  Confirmed
Status in “clang” package in Ubuntu:
  Confirmed
Status in “clang” package in Debian:
  Fix Released

Bug description:
  Binary package hint: clang

  clang in oneiric doesn’t look for crtbegin.o, libgcc.so, or
  libgcc_s.so in the right place, so it can’t link any programs.

  $ echo 'int main() {return 0;}' > foo.c

  $ clang foo.c
  /usr/bin/ld.bfd.real: cannot find crtbegin.o: No such file or directory
  /usr/bin/ld.bfd.real: cannot find -lgcc
  /usr/bin/ld.bfd.real: cannot find -lgcc_s
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

  $ clang -v foo.c
  clang version 2.9 (tags/RELEASE_29/final)
  Target: x86_64-pc-linux-gnu
  Thread model: posix
   "/usr/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name foo.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.21.51.20110421 -momit-leaf-frame-pointer -v -resource-dir /usr/bin/../lib/clang/2.9 -ferror-limit 19 -fmessage-length 80 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-d3WZZO.o -x c foo.c
  clang -cc1 version 2.9 based upon llvm 2.9 hosted on x86_64-pc-linux-gnu
  #include "..." search starts here:
  #include <...> search starts here:
   /usr/local/include
   /usr/bin/../lib/clang/2.9/include
   /usr/include
  End of search list.
   "/usr/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o crtbegin.o -L -L/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/../../.. /tmp/cc-d3WZZO.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed crtend.o /usr/lib/../lib64/crtn.o
  /usr/bin/ld.bfd.real: cannot find crtbegin.o: No such file or directory
  /usr/bin/ld.bfd.real: cannot find -lgcc
  /usr/bin/ld.bfd.real: cannot find -lgcc_s
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

  $ find /usr -name crtbegin.o -o -name libgcc.so -o -name libgcc_s.so
  /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6/crtbegin.o
  /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6/libgcc_s.so
  /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6/32/crtbegin.o
  /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6/32/libgcc_s.so
  /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5/crtbegin.o
  /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5/libgcc_s.so

  $ strace clang foo.c |& grep 'crtbegin\.o'
  stat("/usr/lib/gcc//4.5.2/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.5.2/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.5.1/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.5.1/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.5/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.5/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.4.5/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.4.5/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.4.4/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.4.4/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.4.3/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.4.3/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.4/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.4/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.3.4/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.3.4/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.3.3/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.3.3/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.3.2/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.3.2/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.3/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.3/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.2.4/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.2.4/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.2.3/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.2.3/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.2.2/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.2.2/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.2.1/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.2.1/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/gcc//4.2/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/usr/lib64/gcc//4.2/crtbegin.o", 0x7fff1cfc8600) = -1 ENOENT (No such file or directory)
  stat("/crtbegin.o", 0x7fff1cfc8780)     = -1 ENOENT (No such file or directory)
  stat("/../../../../lib64/crtbegin.o", 0x7fff1cfc8780) = -1 ENOENT (No such file or directory)
  stat("/lib/../lib64/crtbegin.o", 0x7fff1cfc8780) = -1 ENOENT (No such file or directory)
  stat("/usr/lib/../lib64/crtbegin.o", 0x7fff1cfc8780) = -1 ENOENT (No such file or directory)
  stat("/../../../crtbegin.o", 0x7fff1cfc8780) = -1 ENOENT (No such file or directory)
  wait4(28765, /usr/bin/ld.bfd.real: cannot find crtbegin.o: No such file or directory

  Perhaps clang needs to be taught harder about multiarch paths?

  ProblemType: Bug
  DistroRelease: Ubuntu 11.10
  Package: clang 2.9-1
  ProcVersionSignature: Ubuntu 2.6.39-3.10-generic 2.6.39
  Uname: Linux 2.6.39-3-generic x86_64
  NonfreeKernelModules: openafs
  Architecture: amd64
  Date: Thu Jun  2 20:56:07 2011
  EcryptfsInUse: Yes
  InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Alpha amd64 (20101202)
  ProcEnviron:
   LANGUAGE=en_US:en
   PATH=(custom, user)
   LANG=en_US.utf8
   SHELL=/bin/bash
  SourcePackage: clang
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/llvm/+bug/792146/+subscriptions



More information about the Ubuntu-sponsors mailing list