Andersbakken / rtags

A client/server indexer for c/c++/objc[++] with integration for Emacs based on clang.
http://www.rtags.net
GNU General Public License v3.0
1.83k stars 253 forks source link

Failing to build on OpenBSD #1261

Open watkinsr opened 5 years ago

watkinsr commented 5 years ago

Describe the bug Rtags fails to build on OpenBSD.

To Reproduce Steps to reproduce the behavior: Do: git clone --recursive https://github.com/Andersbakken/rtags.git cd rtags cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 . make

Expected behavior rtags to build successfully.

Screenshots/Backtrace [ 1%] Built target emacs_byte_compile_ac-rtags.el [ 1%] Built target emacs_byte_compile_rtags.el [ 2%] Built target emacs_byte_compile_flycheck-rtags.el [ 3%] Built target emacs_byte_compile_ivy-rtags.el [ 4%] Built target emacs_byte_compile_helm-rtags.el [ 5%] Building CXX object src/CMakeFiles/rtags.dir/ClangIndexer.cpp.o In file included from /home/ryan/rtags/src/ClangIndexer.cpp:17: In file included from /home/ryan/rtags/src/ClangIndexer.h:20: In file included from /home/ryan/rtags/src/Token.h:19: In file included from /home/ryan/rtags/src/rct/rct/Serializer.h:14: /home/ryan/rtags/src/rct/rct/Log.h:156:9: error: class member cannot be redeclared Log operator<<(unsigned long long number) { return addStringStream(number); } ^ /home/ryan/rtags/src/rct/rct/Log.h:150:9: note: previous definition is here Log operator<<(uint64_t number) { return addStringStream(number); } ^ /home/ryan/rtags/src/rct/rct/Log.h:157:9: error: class member cannot be redeclared Log operator<<(long long number) { return addStringStream(number); } ^ /home/ryan/rtags/src/rct/rct/Log.h:151:9: note: previous definition is here Log operator<<(int64_t number) { return addStringStream(number); } ^ /home/ryan/rtags/src/ClangIndexer.cpp:2102:36: error: use of overloaded operator '<<' is ambiguous (with operand types 'Log' and 'size_t' (aka 'unsigned long')) << "targets" << it->second->targets.size()


/home/ryan/rtags/src/rct/rct/Log.h:150:9: note: candidate function
    Log operator<<(uint64_t number) { return addStringStream(number); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:151:9: note: candidate function
    Log operator<<(int64_t number) { return addStringStream(number); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:164:9: note: candidate function
    Log operator<<(uint32_t number) { return addStringStream(number); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:165:9: note: candidate function
    Log operator<<(int32_t number) { return addStringStream(number); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:166:9: note: candidate function
    Log operator<<(uint16_t number) { return addStringStream(number); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:167:9: note: candidate function
    Log operator<<(int16_t number) { return addStringStream(number); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:168:9: note: candidate function
    Log operator<<(uint8_t number) { return addStringStream<uint16_t>(number); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:169:9: note: candidate function
    Log operator<<(int8_t number) { return addStringStream(number); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:170:9: note: candidate function
    Log operator<<(float number) { return addStringStream(number); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:171:9: note: candidate function
    Log operator<<(double number) { return addStringStream(number); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:172:9: note: candidate function
    Log operator<<(long double number) { return addStringStream(number); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:173:9: note: candidate function
    Log operator<<(char ch) { return write(&ch, 1); }
        ^
/home/ryan/rtags/src/rct/rct/Log.h:174:9: note: candidate function
    Log operator<<(bool b) { return write(b ? "true" : "false"); }
        ^
/home/ryan/rtags/src/rct/rct/Value.h:656:12: note: candidate function
inline Log operator<<(Log log, const Value &value)
           ^
3 errors generated.
*** Error 1 in . (src/CMakeFiles/rtags.dir/build.make:63 'src/CMakeFiles/rtags.dir/ClangIndexer.cpp.o': cd /home/ryan/rtags/src && /usr/bin/...)
*** Error 1 in . (CMakeFiles/Makefile2:1465 'src/CMakeFiles/rtags.dir/all')
*** Error 1 in /home/ryan/rtags (Makefile:141 'all')

**Environment (please complete the following information):**
 - OS/Version: OpenBSD 6.4
 - RTags(rdm,rc): 2.20
 - Emacs: [e.g. 24.5] 26.1
 - LLVM/Clang: [e.g. 4.3]: 6.0
rkanavath commented 5 years ago

updating rct code can fix build on openbsd..

rkanavath commented 5 years ago

@cslux , attaching local diff from rct submodule. Feedback or improvements are welcome. ig wordexp can be dropped in favour of glob, that will be a bit cleaner diff for openbsd and other platforms as well.

diff --git a/rct/Log.h b/rct/Log.h
index 4b2453a..3de7bcb 100644
--- a/rct/Log.h
+++ b/rct/Log.h
@@ -141,7 +141,7 @@ public:
     Log(LogLevel level = LogLevel::Error, Flags<LogOutput::LogFlag> flags = LogOutput::DefaultFlags);
     Log(const Log &other);
     Log &operator=(const Log &other);
-#if defined(OS_Darwin)
+#if defined(OS_Darwin) || defined(__OpenBSD__)
 #ifndef __i386__
     Log operator<<(long number) { return addStringStream(number); }
 #endif
diff --git a/rct/MemoryMonitor.cpp b/rct/MemoryMonitor.cpp
index 543d6aa..b0b6a0a 100644
--- a/rct/MemoryMonitor.cpp
+++ b/rct/MemoryMonitor.cpp
@@ -69,6 +69,12 @@ static inline uint64_t usageFreeBSD()
 #warning "implement me"
     return 0;
 }
+#elif (__OpenBSD__)
+static inline uint64_t usageOpenBSD()
+{
+#warning "implement me"
+    return 0;
+}
 #elif defined(OS_DragonFly)
 static inline uint64_t usageDragonFly()
 {
@@ -122,6 +128,8 @@ uint64_t MemoryMonitor::usage()
     return usageLinux();
 #elif defined(OS_FreeBSD)
     return usageFreeBSD();
+#elif defined(__OpenBSD__)
+    return usageOpenBSD();
 #elif defined(OS_DragonFly)
     return usageDragonFly();
 #elif defined(OS_Darwin)
diff --git a/rct/Path.cpp b/rct/Path.cpp
index 9b00914..708f2bd 100644
--- a/rct/Path.cpp
+++ b/rct/Path.cpp
@@ -7,8 +7,10 @@
 #  include <Windows.h>
 #  include <Shellapi.h>
 #  include "WindowsUnicodeConversion.h"
+#elif defined(__OpenBSD__)
+#include <glob.h>
 #else
-#  include <wordexp.h>
+ #include <wordexp.h>
 #endif
 #include <limits.h>
 #include <stdio.h>
@@ -262,14 +264,23 @@ bool Path::resolve(ResolveMode mode, const Path &cwd, bool *changed)
     if (isEmpty())
         return false;
     if (startsWith('~')) {
+
+#elif defined(__OpenBSD__)
+        glob_t exp_result;
+        if (glob(constData(), 0, NULL, &exp_result) == false) {
+            operator=(exp_result.gl_pathv[0]);
+            if (changed)
+                *changed = true;
+        }
+#else
         wordexp_t exp_result;
         wordexp(constData(), &exp_result, 0);
         operator=(exp_result.we_wordv[0]);
         wordfree(&exp_result);
         if (changed)
             *changed = true;
-    }
 #endif
+    }
     if (*this == ".")
         clear();
     if (mode == MakeAbsolute || !sRealPathEnabled) {
casch-at commented 5 years ago

Hey @rkanavath! Looks good to me! Could you create a PR on the rct project, please?

Thanks, Christian

casch-at commented 5 years ago

@rkanavath

wordexp can be dropped in favour of glob,

Can you do that? Or just create an issue on the rct project?

Thanks, Christian

rkanavath commented 5 years ago

@cslux done in in https://github.com/Andersbakken/rct/pull/80.

you might need to update git tag on submodule once that pr is merged.

josefig commented 3 years ago

I cannot compile it on OpenBSD -current (6.8) :

prometeo ~/Documents/projects/rtags> cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 . -- The C compiler identification is Clang 10.0.1 -- The CXX compiler identification is Clang 10.0.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- llvm-config executable found: /usr/bin/llvm-config -- Using Clang version 10.0.1 from /usr/lib with CXXFLAGS -I/usr/include -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -- Found LibClang: /usr/local/lib/libclang.so.8.1
-- Performing Test LIBCLANG_COMPILES -- Performing Test LIBCLANG_COMPILES - Failed CMake Error at src/CMakeLists.txt:103 (message): Failed to compile small clang test app.

It's likely that the include file <clang-c/Index.h> could not be found!

Maybe you need to install the clang development package (delete the CMakeCache.txt file before trying to run cmake again after installation)?

See CMakeFiles/CMakeError.log for more info.

-- Configuring incomplete, errors occurred! See also "/home/josefig/Documents/projects/rtags/CMakeFiles/CMakeOutput.log". See also "/home/josefig/Documents/projects/rtags/CMakeFiles/CMakeError.log".

josefig commented 3 years ago

I cannot compile it on OpenBSD -current (6.8) :

prometeo ~/Documents/projects/rtags> cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 . -- The C compiler identification is Clang 10.0.1 -- The CXX compiler identification is Clang 10.0.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- llvm-config executable found: /usr/bin/llvm-config -- Using Clang version 10.0.1 from /usr/lib with CXXFLAGS -I/usr/include -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -- Found LibClang: /usr/local/lib/libclang.so.8.1 -- Performing Test LIBCLANG_COMPILES -- Performing Test LIBCLANG_COMPILES - Failed CMake Error at src/CMakeLists.txt:103 (message): Failed to compile small clang test app.

It's likely that the include file <clang-c/Index.h> could not be found!

Maybe you need to install the clang development package (delete the CMakeCache.txt file before trying to run cmake again after installation)?

See CMakeFiles/CMakeError.log for more info.

-- Configuring incomplete, errors occurred! See also "/home/josefig/Documents/projects/rtags/CMakeFiles/CMakeOutput.log". See also "/home/josefig/Documents/projects/rtags/CMakeFiles/CMakeError.log".

Sorry, my problem was the include path, now it worked. Thanks!