clang linker problem

前端 未结 4 750
北荒
北荒 2021-01-04 20:18

I just tried out the latest llvm and clang trunk versions. They compiled without a single warning out of the box but I\'m having trouble linking a hello world example. My Co

4条回答
  •  生来不讨喜
    2021-01-04 21:21

    This horrible HACK "fixes" compiling/linking with clang 3.0(r142716) on Ubuntu 11.10 (x86)

    In file included from /usr/include/stdio.h:28:
    /usr/include/features.h:323:10: fatal error: 'bits/predefs.h' file not found

    /usr/bin/ld: cannot find crt1.o: No such file or directory
    /usr/bin/ld: cannot find crti.o: No such file or directory

    diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
    index 75300b5..3e2be30 100644
    --- a/lib/Driver/Driver.cpp
    +++ b/lib/Driver/Driver.cpp
    @@ -241,6 +241,7 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
       // FIXME: Handle environment options which affect driver behavior, somewhere
       // (client?). GCC_EXEC_PREFIX, LIBRARY_PATH, LPATH, CC_PRINT_OPTIONS.
    
    +  PrefixDirs.push_back("/usr/lib/i386-linux-gnu");
       if (char *env = ::getenv("COMPILER_PATH")) {
         StringRef CompilerPath = env;
         while (!CompilerPath.empty()) {
    diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
    index b066e71..c6ffee8 100644
    --- a/lib/Frontend/InitHeaderSearch.cpp
    +++ b/lib/Frontend/InitHeaderSearch.cpp
    @@ -562,10 +562,12 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
           AddPath("/usr/include/x86_64-linux-gnu", System, false, false, false);
           AddPath("/usr/include/i686-linux-gnu/64", System, false, false, false);
           AddPath("/usr/include/i486-linux-gnu/64", System, false, false, false);
    +      AddPath("/usr/include/i386-linux-gnu/64", System, false, false, false);
         } else if (triple.getArch() == llvm::Triple::x86) {
           AddPath("/usr/include/x86_64-linux-gnu/32", System, false, false, false);
           AddPath("/usr/include/i686-linux-gnu", System, false, false, false);
           AddPath("/usr/include/i486-linux-gnu", System, false, false, false);
    +      AddPath("/usr/include/i386-linux-gnu", System, false, false, false);
         } else if (triple.getArch() == llvm::Triple::arm) {
           AddPath("/usr/include/arm-linux-gnueabi", System, false, false, false);
         }
    

提交回复
热议问题