Leslie Zhai via llvm-dev
2018-Sep-06 05:04 UTC
[llvm-dev] error: reference to 'Optional' is ambiguous building with gcc-4.9.3
Hi, It failed to build LLVM[1] 8-master with gcc-4.9.3[2] for mips64el: [ 94%] Building CXX object tools/llvm-dwp/CMakeFiles/llvm-dwp.dir/llvm-dwp.cpp.o /home/loongson/zhaixiang/llvm/tools/llvm-dwp/llvm-dwp.cpp: In function ‘int main(int, char**)’: /home/loongson/zhaixiang/llvm/tools/llvm-dwp/llvm-dwp.cpp:700:3: error: reference to ‘Optional’ is ambiguous Optional<buffer_ostream> BOS; ^ In file included from /home/loongson/zhaixiang/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.inc:19:0, from /home/loongson/zhaixiang/llvm/tools/llvm-dwp/llvm-dwp.cpp:30: /home/loongson/zhaixiang/llvm/include/llvm/Support/CommandLine.h:112:3: note: candidates are: llvm::cl::NumOccurrencesFlag Optional Optional = 0x00, // Zero or One occurrence ^ In file included from /home/loongson/zhaixiang/llvm/include/llvm/ADT/STLExtras.h:20:0, from /home/loongson/zhaixiang/llvm/include/llvm/Support/Error.h:18, from /home/loongson/zhaixiang/llvm/tools/llvm-dwp/DWPError.h:4, from /home/loongson/zhaixiang/llvm/tools/llvm-dwp/llvm-dwp.cpp:14: /home/loongson/zhaixiang/llvm/include/llvm/ADT/Optional.h:131:29: note: template<class T> class llvm::Optional template <typename T> class Optional { ^ /home/loongson/zhaixiang/llvm/tools/llvm-dwp/llvm-dwp.cpp:700:26: error: expected primary-expression before ‘>’ token Optional<buffer_ostream> BOS; ^ /home/loongson/zhaixiang/llvm/tools/llvm-dwp/llvm-dwp.cpp:700:28: error: ‘BOS’ was not declared in this scope Optional<buffer_ostream> BOS; ^ tools/llvm-dwp/CMakeFiles/llvm-dwp.dir/build.make:62: recipe for target 'tools/llvm-dwp/CMakeFiles/llvm-dwp.dir/llvm-dwp.cpp.o' failed ----- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< --- So workaround might be: diff --git a/tools/llvm-dwp/llvm-dwp.cpp b/tools/llvm-dwp/llvm-dwp.cpp index 4a1835a..8444a00 100644 --- a/tools/llvm-dwp/llvm-dwp.cpp +++ b/tools/llvm-dwp/llvm-dwp.cpp @@ -14,6 +14,7 @@ #include "DWPError.h" #include "DWPStringPool.h" #include "llvm/ADT/MapVector.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" @@ -697,7 +698,7 @@ int main(int argc, char **argv) { // Create the output file. std::error_code EC; raw_fd_ostream OutFile(OutputFilename, EC, sys::fs::F_None); - Optional<buffer_ostream> BOS; + llvm::Optional<buffer_ostream> BOS; raw_pwrite_stream *OS; if (EC) return error(Twine(OutputFilename) + ": " + EC.message(), Context); 1. $ clang -v Loongson clang version 8.0.0 (git at github.com:llvm-mirror/clang.git 56fc90882612ab774dae937ca8d997c59364f7f8) (git at github.com:llvm-mirror/llvm.git 3419b04cf0c0a57577865f0d17fefb205deed048) (based on LLVM 8.0.0svn) Target: mips64el-redhat-linux Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation: /usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3 Found candidate GCC installation: /usr/lib/gcc/mips64el-redhat-linux/4.9.3 Selected GCC installation: /usr/bin/../lib/gcc/mips64el-redhat-linux/4.9.3 Candidate multilib: .; Selected multilib: .; 2. $ gcc -v Using built-in specs. COLLECT_GCC=/usr/bin/gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/mips64el-redhat-linux/4.9.3/lto-wrapper Target: mips64el-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-arch=loongson3a --enable-languages=c,c++,objc,obj-c++,fortran,go,lto --enable-plugin --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.9.3/obj-mips64el-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.9.3/obj-mips64el-redhat-linux/cloog-install --enable-gnu-indirect-function --with-long-double-128 --build=mips64el-redhat-linux Thread model: posix gcc version 4.9.3 20150626 (Red Hat 4.9.3-8) (GCC) -- Regards, Leslie Zhai