[LLVMbugs] [Bug 8897] New: Clang fails to find crtbegin.o

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jan 3 17:01:59 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=8897

           Summary: Clang fails to find crtbegin.o
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Driver
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: greened at obbligato.org
                CC: llvmbugs at cs.uiuc.edu


I get the following for the Driver/hello.c test on SuSE Linux 10.1:


"/ptmp/dag/build.llvm.trunk.official.opt/x86_64-unknown-linux-gnu/Release+Asserts/bin/clang"
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name hello.c -mrelocation-model static -mdisable-fp-elim
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64
-target-linker-version 2.17 -resource-dir
/ptmp/dag/build.llvm.trunk.official.opt/x86_64-unknown-linux-gnu/Release+Asserts/bin/../lib/clang/2.9
-ferror-limit 19 -fmessage-length 0 -fgnu-runtime -fdiagnostics-show-option -o
/tmp/cc-cppG60.o -x c
/ptmp/dag/llvm-project.official/llvm/trunk/tools/clang/test/Driver/hello.c
 "/opt/cpkg/v6/binutils/2.17/bin/ld" --eh-frame-hdr -m elf_x86_64
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -o
/ptmp/dag/build.llvm.trunk.official.opt/x86_64-unknown-linux-gnu/tools/clang/test/Driver/Output/hello.c.tmp
/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-cppG60.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
/opt/cpkg/v6/binutils/2.17/bin/ld: crtbegin.o: No such file: No such file or
directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I believe this is happening because the gcc used to build clang is not in a
standard location:

/opt/gcc/4.5.1/bin/g++

Or alternatively, the system gcc is not listed in the ToolChains.cpp
GccVersions list:

  const char* GccVersions[] = {"4.5.1", "4.5", "4.4.5", "4.4.4", "4.4.3",
"4.4",
                               "4.3.4", "4.3.3", "4.3.2"};

dag at royale:/ptmp/dag/compiler_ref$ which gcc
/usr/bin/gcc
dag at royale:/ptmp/dag/compiler_ref$ gcc --version
gcc (GCC) 4.1.2 20070115 (prerelease) (SUSE Linux)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

In any case, the driver should not rely on a small set of hardcoded guesses as
to where crtbegin.o is.  A simple solution would be to use the build gcc's
-print-search-dirs to get a list of candidate directories and fall back on the
hardcoded ones as a last resort.  Obviously different handling would be
required if gcc were not the build compiler but for Linux, most of the time it
will be.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list