ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.48k stars 2.81k forks source link

OpenBSD Compile Failure on 6.8+ #4212

Closed Jaywalker closed 10 months ago

Jaywalker commented 10 months ago

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

Thank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.

Issue Details

OpenBSD fails to compile since OpenBSD 6.8 to latest (7.4).

This issue was reported on the mailing list here: https://groups.google.com/g/ycm-users/c/eJHzetNm_KM

I have solved the issue by, as the install script is is "Generating ycmd build configuration...", editing the file third_party/ycmd/cpp/absl/absl/time/internal/cctz/src/time_zone_format.cc and commenting out line 23, #define _XOPEN_SOURCE after the file exists but before it gets to the next "Compiling ycmd target: ycm_core..." step.

This is also the solutions provided in the links referenced in the mailing list post: https://github.com/google/flatbuffers/issues/6185 https://github.com/google/flatbuffers/pull/6205

  1. cd .config/nvim/plugged/YouCompleteMe/
  2. python3 install.py --go-completer --ts-completer --clang-completer --system-libclang

Compile to succeed.

The compile failed.

Diagnostic data

Output of vim --version

NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info

Output of YcmDebugInfo

Unavailable without a fix for this issue

Output of YcmDiags

Unavailable without a fix for this issue

Output of git rev-parse HEAD in YouCompleteMe installation directory

79c850b4a674a4f461a670f4515ab953bb89d632

Contents of YCM, ycmd and completion engine logfiles

Unavailable without a fix for this issue

OS version, distribution, etc.

OpenBSD 7.4

Output of build/install commands

[jaywalker@darter ~/.config/nvim/plugged/YouCompleteMe]$ python3 install.py --go-completer --ts-completer --clang-completer --system-libclang
Generating ycmd build configuration...OK
Compiling ycmd target: ycm_core...[  0%] Building CXX object absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/zone_info_source.cc.o
[  0%] Building CXX object absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_format.cc.o
[  1%] Building CXX object absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_if.cc.o
[  3%] Building CXX object absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_impl.cc.o
[  3%] Building CXX object absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_info.cc.o
[  4%] Building CXX object absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_libc.cc.o
[  4%] Building CXX object absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_lookup.cc.o
[  6%] Building CXX object absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_posix.cc.o
In file included from /home/jaywalker/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/cpp/absl/absl/time/internal/cctz/src/time_zone_format.cc:28:
In file included from /home/jaywalker/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/cpp/absl/absl/time/internal/cctz/include/cctz/time_zone.h:29:
In file included from /home/jaywalker/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/cpp/absl/absl/time/internal/cctz/include/cctz/civil_time.h:19:
In file included from /home/jaywalker/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/cpp/absl/absl/time/internal/cctz/include/cctz/civil_time_detail.h:20:
In file included from /usr/include/c++/v1/ostream:140:
In file included from /usr/include/c++/v1/locale:218:
/usr/include/c++/v1/__bsd_locale_fallbacks.h:122:17: error: use of undeclared identifier 'vasprintf'; did you mean 'vsprintf'?
    int __res = vasprintf(__s, __format, __va);
                ^
/usr/include/c++/v1/cstdio:124:9: note: 'vsprintf' declared here
using ::vsprintf _LIBCPP_USING_IF_EXISTS;
        ^
In file included from /home/jaywalker/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/cpp/absl/absl/time/internal/cctz/src/time_zone_format.cc:28:
In file included from /home/jaywalker/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/cpp/absl/absl/time/internal/cctz/include/cctz/time_zone.h:29:
In file included from /home/jaywalker/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/cpp/absl/absl/time/internal/cctz/include/cctz/civil_time.h:19:
In file included from /home/jaywalker/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/cpp/absl/absl/time/internal/cctz/include/cctz/civil_time_detail.h:20:
In file included from /usr/include/c++/v1/ostream:140:
In file included from /usr/include/c++/v1/locale:218:
/usr/include/c++/v1/__bsd_locale_fallbacks.h:122:27: error: cannot initialize a parameter of type 'char *' with an lvalue of type 'char **'
    int __res = vasprintf(__s, __format, __va);
                          ^~~
/usr/include/stdio.h:269:21: note: passing argument to parameter here
int      vsprintf(char *, const char *, __va_list);
                        ^
[  8%] Building CXX object absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_fixed.cc.o
/home/jaywalker/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/cpp/absl/absl/time/internal/cctz/src/time_zone_format.cc:651:10: error: use of undeclared identifier 'strptime'
    dp = strptime(dp, fmt, tm);
         ^
3 errors generated.
*** Error 1 in . (absl/absl/time/CMakeFiles/absl_time_zone.dir/build.make:90 'absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_format.cc.o')
*** Error 1 in target 'absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_format.cc.o'
*** Error 2 in . (CMakeFiles/Makefile2:2542 'absl/absl/time/CMakeFiles/absl_time_zone.dir/all')
*** Error 2 in . (CMakeFiles/Makefile2:2682 'ycm/CMakeFiles/ycm_core.dir/rule')
*** Error 2 in /tmp/ycm_build_wo_hdv4w (Makefile:962 'ycm_core': /usr/bin/make -s -f CMakeFiles/Makefile2 ycm_core)

FAILED

ERROR: the build failed.

NOTE: it is *highly* unlikely that this is a bug but rather that this is a problem with the configuration of your system or a missing dependency. Please carefully read CONTRIBUTING.md and if you're sure that it is a bug, please raise an issue on the issue tracker, including the entire output of this script (with --verbose) and the invocation line used to run it.

The installation failed; please see above for the actual error. In order to get more information, please re-run the command, adding the --verbose flag. If you think this is a bug and you raise an issue, you MUST include the *full verbose* output.

For example, run:/usr/local/bin/python3 /home/jaywalker/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/build.py --go-completer --ts-completer --clang-completer --system-libclang --verbose
bstaletic commented 10 months ago

I do not have an openbsd system to check, but maybe a newer version of abseil would fix the issue.

Jaywalker commented 10 months ago

I can confirm that the latest version of abseil has a patch that fixes it, specifically here: https://github.com/abseil/abseil-cpp/blob/master/absl/time/internal/cctz/src/time_zone_format.cc#L22

I didn't try recompiling with the latest version, just tested with that line in place to verify that it does indeed work like I expected it to, and I can confirm it does!

I'll leave selecting the proper version of abseil to update to in your hands. Just ensure that it has the #if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__) && !defined(__OpenBSD__) and not simply #if !defined(_XOPEN_SOURCE). Of note, it looks like this may also be an issue on FreeBSD too if that line is to be believed.

bstaletic commented 10 months ago

Thanks f9r checking. I will make a pull request for ycmd tonight.

In the mean time, if you have a new version of abseil on installed system-wide, there is a workaround.

EXTRA_CMAKE_ARGS=-DUSE_SYSTEM_ABSEIL=ON ./install.py --go-completer --ts-completer

I am using a phone right now, so excuse any typos.

dhharris commented 8 months ago

I experienced a similar issue on FreeBSD. The provided workaround allowed me to compile it, but I have no clue why it required EXTRA_CMAKE_ARGS=-DUSE_SYSTEM_ABSEIL=ON because I have the latest version of YCM code.

Excerpt from the errors, all from the abseil lib.

In file included from /usr/local/lib/gcc12/include/c++/bits/postypes.h:40,
                 from /usr/local/lib/gcc12/include/c++/bits/char_traits.h:39,
                 from /usr/local/lib/gcc12/include/c++/string:40,
                 from /usr/home/hugh/.bundle/YouCompleteMe/third_party/ycmd/cpp/absl/absl/time/internal/cctz/include/cctz/time_zone.h:27,
                 from /usr/home/hugh/.bundle/YouCompleteMe/third_party/ycmd/cpp/absl/absl/time/internal/cctz/src/time_zone_format.cc:28:
/usr/local/lib/gcc12/include/c++/cwchar:166:11: error: 'vfwscanf' has not been declared in '::'
  166 |   using ::vfwscanf;
      |           ^~~~~~~~
/usr/local/lib/gcc12/include/c++/cwchar:172:11: error: 'vswscanf' has not been declared in '::'
  172 |   using ::vswscanf;
      |           ^~~~~~~~
/usr/local/lib/gcc12/include/c++/cwchar:176:11: error: 'vwscanf' has not been declared in '::'
  176 |   using ::vwscanf;
      |           ^~~~~~~
/usr/local/lib/gcc12/include/c++/cwchar:193:11: error: 'wcstof' has not been declared in '::'
  193 |   using ::wcstof;
      |           ^~~~~~
/usr/local/lib/gcc12/include/c++/cwchar:283:14: error: 'wcstof' has not been declared in 'std'
  283 |   using std::wcstof;
      |              ^~~~~~
/usr/local/lib/gcc12/include/c++/cwchar:286:14: error: 'vfwscanf' has not been declared in 'std'
  286 |   using std::vfwscanf;
      |              ^~~~~~~~
/usr/local/lib/gcc12/include/c++/cwchar:289:14: error: 'vswscanf' has not been declared in 'std'
  289 |   using std::vswscanf;
      |              ^~~~~~~~
/usr/local/lib/gcc12/include/c++/cwchar:292:14: error: 'vwscanf' has not been declared in 'std'
  292 |   using std::vwscanf;
      |              ^~~~~~~
[  8%] Linking CXX static library libabsl_spinlock_wait.a
In file included from /usr/local/lib/gcc12/include/c++/bits/localefwd.h:42,
                 from /usr/local/lib/gcc12/include/c++/string:43:
/usr/local/lib/gcc12/include/c++/cctype:87:11: error: 'isblank' has not been declared in '::'
   87 |   using ::isblank;
      |           ^~~~~~~
[  8%] Built target absl_spinlock_wait
In file included from /usr/local/lib/gcc12/include/c++/string:53:
/usr/local/lib/gcc12/include/c++/bits/basic_string.h: In function 'float std::__cxx11::stof(const std::wstring&, std::size_t*)':
/usr/local/lib/gcc12/include/c++/bits/basic_string.h:4141:36: error: 'wcstof' is not a member of 'std'; did you mean 'wcstol'?
 4141 |   { return __gnu_cxx::__stoa(&std::wcstof, "stof", __str.c_str(), __idx); }
      |                                    ^~~~~~
      |                                    wcstol
[ 10%] Linking CXX static library libabsl_exponential_biased.a
[ 10%] Built target absl_exponential_biased
[ 11%] Linking CXX static library libabsl_log_severity.a
[ 11%] Built target absl_log_severity
[ 13%] Building CXX object _deps/absl-build/absl/base/CMakeFiles/absl_raw_logging_internal.dir/internal/raw_logging.cc.o
gmake[3]: *** [_deps/absl-build/absl/time/CMakeFiles/absl_time_zone.dir/build.make:90: _deps/absl-build/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_format.cc.o] Error 1
gmake[3]: *** Waiting for unfinished jobs....
bstaletic commented 8 months ago

That looks odd. At time_zone.h:27 abseil just #includes <string>. That said, since 20240116.1, there was an update to cctz on abseil master, though not in the files that are mentioned in your errors.

What release of abseil is on your system?

dhharris commented 8 months ago

I am using an older version.

abseil-20230125.3
Name           : abseil
Version        : 20230125.3
Installed on   : Wed Mar  6 21:40:50 2024 CET
Origin         : devel/abseil
Architecture   : FreeBSD:13:amd64
Prefix         : /usr/local
Categories     : devel
Licenses       : APACHE20
Maintainer     : danfe@FreeBSD.org
WWW            : https://abseil.io/
Comment        : Abseil Common Libraries (C++)

I'm guessing the freebsd package hasn't been updated yet?

bstaletic commented 8 months ago

That makes me think there might be a new reason abseil is not compiling on FreeBSD. I have two suggestions:

  1. Just keep using EXTRA_CMAKE_ARGS=-DUSE_SYSTEM_ABSEIL=ON. It's not going anywhere and I would assume FreeBSD does test whatever version of abseil they decide to ship, so I would not expect any breaks there.
  2. If you're up for it, test latest abseil LTS and report a bug to them, or even submit a pull request. YCM can update once a patch lands into abseil LTS.