Compiling llvm/clang/compiler-rt 3.2

Hi cfe-dev,

I’m currently trying to compile llvm, clang and compiler-rt from the official 3.2 tag with gcc4.7.0 but unfortunately I’m getting the compiler error detailed below. Is this something anyone has come across before?

Thanks,
Graeme

Compiler Errror

make[4]: Entering directory /home/grarus/build/tools/clang/lib/Basic' llvm[4]: Compiling Builtins.cpp for Release+Asserts build llvm[4]: Compiling ConvertUTF.c for Release+Asserts build llvm[4]: Compiling ConvertUTFWrapper.cpp for Release+Asserts build llvm[4]: Compiling Diagnostic.cpp for Release+Asserts build llvm[4]: Compiling DiagnosticIDs.cpp for Release+Asserts build llvm[4]: Compiling FileManager.cpp for Release+Asserts build llvm[4]: Compiling FileSystemStatCache.cpp for Release+Asserts build llvm[4]: Compiling IdentifierTable.cpp for Release+Asserts build llvm[4]: Compiling LangOptions.cpp for Release+Asserts build llvm[4]: Compiling Module.cpp for Release+Asserts build llvm[4]: Compiling ObjCRuntime.cpp for Release+Asserts build llvm[4]: Compiling SourceLocation.cpp for Release+Asserts build llvm[4]: Compiling SourceManager.cpp for Release+Asserts build llvm[4]: Compiling TargetInfo.cpp for Release+Asserts build llvm[4]: Compiling Targets.cpp for Release+Asserts build llvm[4]: Compiling TokenKinds.cpp for Release+Asserts build llvm[4]: Compiling Version.cpp for Release+Asserts build /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp: In function ‘std::string clang::getClangRepositoryPath()’: /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:36:11: error: request for member ‘empty’ in ‘clang::URL’, which is of non-class type ‘llvm::StringRef()’ /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:38:63: error: assignment of function ‘llvm::StringRef clang::URL()’ /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:38:63: error: cannot convert ‘llvm::StringRef’ to ‘llvm::StringRef()’ in assignment /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:42:13: error: request for member ‘slice’ in ‘clang::URL’, which is of non-class type ‘llvm::StringRef()’ /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:42:26: error: request for member ‘find’ in ‘clang::URL’, which is of non-class type ‘llvm::StringRef()’ /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:45:22: error: request for member ‘find’ in ‘clang::URL’, which is of non-class type ‘llvm::StringRef()’ /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:47:15: error: request for member ‘substr’ in ‘clang::URL’, which is of non-class type ‘llvm::StringRef()’ /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:49:10: error: could not convert ‘clang::URL’ from ‘llvm::StringRef (*)()’ to ‘std::string {aka std::basic_string<char>}’ /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp: In function ‘std::string clang::getLLVMRepositoryPath()’: /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:63:22: error: request for member ‘find’ in ‘clang::URL’, which is of non-class type ‘llvm::StringRef()’ /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:65:15: error: request for member ‘substr’ in ‘clang::URL’, which is of non-class type ‘llvm::StringRef()’ /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:67:10: error: could not convert ‘clang::URL’ from ‘llvm::StringRef (*)()’ to ‘std::string {aka std::basic_string<char>}’ /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp: In function ‘std::string clang::getClangRevision()’: /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:72:3: error: return-statement with no value, in function returning ‘std::string {aka std::basic_string<char>}’ [-fpermissive] /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:76:1: warning: no return statement in function returning non-void [-Wreturn-type] /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp: In function ‘std::string clang::getLLVMRevision()’: /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:80:3: error: return-statement with no value, in function returning ‘std::string {aka std::basic_string<char>}’ [-fpermissive] /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:84:1: warning: no return statement in function returning non-void [-Wreturn-type] /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp: In function ‘std::string clang::getLLVMRepositoryPath()’: /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:68:1: warning: control reaches end of non-void function [-Wreturn-type] /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp: In function ‘std::string clang::getClangRepositoryPath()’: /home/grarus/llvm/tools/clang/lib/Basic/Version.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type] /bin/rm: cannot remove /home/grarus/build/tools/clang/lib/Basic/Release+Asserts/Version.d.tmp’: No such file or directory
make[4]: *** [/home/grarus/build/tools/clang/lib/Basic/Release+Asserts/Version.o] Error 1

Code Snippet from Version.cpp

#include “clang/Basic/Version.h”
#include “clang/Basic/LLVM.h”
#include “llvm/Support/raw_ostream.h”
#include “llvm/Config/config.h”
#include
#include

namespace clang {

std::string getClangRepositoryPath() {
#if defined(CLANG_REPOSITORY_STRING)
return CLANG_REPOSITORY_STRING;
#else
#ifdef SVN_REPOSITORY
StringRef URL(SVN_REPOSITORY);
#else
StringRef URL("");
#endif

// If the SVN_REPOSITORY is empty, try to use the SVN keyword. This helps us
// pick up a tag in an SVN export, for example.
static StringRef SVNRepository("$URL: http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_32/final/lib/Basic/Version.cpp $");
if (URL.empty()) {
URL = SVNRepository.slice(SVNRepository.find(’:’),
SVNRepository.find("/lib/Basic"));
}

// Strip off version from a build from an integration branch.
URL = URL.slice(0, URL.find("/src/tools/clang"));

// Trim path prefix off, assuming path came from standard cfe path.
size_t Start = URL.find(“cfe/”);
if (Start != StringRef::npos)
URL = URL.substr(Start + 4);

return URL;
#endif
}

Looks like a vexing parse problem. Try changing ‘StringRef URL(SVN_REPOSITORY)’ to ‘StringRef URL = SVN_REPOSITORY’.

If that works, please let us know so we can fix it for 3.3!

Jordan

Looks like a vexing parse problem. Try changing ‘StringRef URL(SVN_REPOSITORY)’ to ‘StringRef URL = SVN_REPOSITORY’.

That will just break in a different way. The problem seems to be that SVN_REPOSITORY is defined but expands to no tokens.

It does indeed look to be a problem with these variables being defined but with no value. The issue also effects the SVN_REVISION, LLVM_REVISION and LLVM_REPOSITORY variables.

I don’t have these explicitly set so I’m guessing the build procedure sets them. For now I’ve worked around by using an empty string instead.