Cyclic dependencies in HaikuPorts

I trying to compile various packages for riscv64 on real hardware and I often get cyclic dependencies error. For example CMake that it used by a lot of packages depends on itself:

> PYTHONHOME=/boot/system/ python haikuporter --no-source-packages --all-dependencies cmake
Warning: deactivating creation of source packages as 'git' is not available
Checking if any dependency-infos need to be updated ...
        updating dependency infos of cmake-3.20.2
Looking for stale dependency-infos ...
======================================================================
dev-util::cmake-3.20.2
======================================================================
The following build dependencies were found:
        /Haiku-nvme/data/haikuports/repository/ca_root_certificates-2021_01_19.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/patch-2.7.6.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libffi-3.2.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/rhash-1.4.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/diffutils-3.7.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libffi_devel-3.2.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/autoconf_archive-2021.02.19.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/gzip-1.10.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/rhash_devel-1.4.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/make-4.3.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/gawk-5.1.0.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/gmp-6.2.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/ncurses6-6.2.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/zlib-1.2.11.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/sed-4.8.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/nghttp2-1.43.0.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/gmp_devel-6.2.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/mpc_devel-1.2.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/tar-1.34.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/help2man-1.48.3.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/ncurses5-6.2.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/perl-5.32.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/bzip2-1.0.8.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/ncurses6_devel-6.2.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/zlib_devel-1.2.11.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/nghttp2_devel-1.43.0.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/pkgconf-1.5.3.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/mpc-1.2.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/m4-1.4.18.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/sqlite-3.34.1.0.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/bzip2_devel-1.0.8.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libuv-1.40.0.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/coreutils-8.29.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/openssl_devel-1.1.1k.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libiconv-1.16.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libpcre-8.44.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/sqlite_devel-3.34.1.0.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libuv_devel-1.40.0.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/openssl-1.1.1k.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/groff-1.22.4.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libiconv_devel-1.16.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libpcre_devel-8.44.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/readline-8.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/readline_devel-8.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/mpfr-4.1.0.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libedit-20210419_3.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libedit_devel-20210419_3.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/mpfr_devel-4.1.0.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/bison-3.7.6.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libtool_libltdl-2.4.6.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/autoconf-2.69.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/findutils-4.8.0.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/flex-2.6.4.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/gettext_libintl-0.19.8.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/grep-3.6.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/binutils-2.31.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/automake-1.16.3.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/texinfo-6.7.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/cmake-3.20.2.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/bash-5.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/gettext-0.19.8.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/gcc_syslibs-11.1.0_2021_04_27.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/libtool-2.4.6.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/curl-7.76.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/curl_devel-7.76.1.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/gcc-11.1.0_2021_04_27.DependencyInfo
        /Haiku-nvme/data/haikuports/repository/python-2.7.18.DependencyInfo
Error: Port cmake-3.20.2 depends on itself

Any ideas how to fix this? Anybody tried to build all packages from zero?

Not sure why you need to call python here?

Could you try with --get-dependencies? (it gave me the same error when I try with --all-dependencies)

Because python2 is needed (python3 is not yet available) and it have broken built-in pythonhome path.

It will not work because there are currently no already built packages for riscv64.

Looks like you have a long way to go to get all the dependencies up and running :slight_smile:

Did the python3_bootstrap work? I think it should probably be similar for a haikuports recipe as well and get you a python3 for riscv64.

It compiles modules for x86_64 Linux instead of Haiku riscv64 and then fails.

1 Like

I guess that should be fixed. It took a long time to setup the recipe but I don’t think getting that part working should be that hard.

2 Likes

Could you download CMake from the source and compile? There aren’t too many changes in the patchset file. It’s certainly not ideal, but might get you some progress.

I tried to compile CMake directly without HaikuPorter and I got this:

In file included from /boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/mutex:45,
                 from /Haiku-nvme/data/haikuports/dev-util/cmake/work-3.20.2/sources/cmake-3.20.2/Source/cmUVHandlePtr.cxx::
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable:68:13: error: '__gthread_cond_t' does not name a type; did you mean '__gthread_once_t'?
     typedef __gthread_cond_t  __native_type;
             ^~~~~~~~~~~~~~~~
             __gthread_once_t
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable:73:5: error: '__native_type' does not name a type; did you mean '__false_type'?
     __native_type   _M_cond;
     ^~~~~~~~~~~~~
     __false_type
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable:77:13: error: '__native_type' does not name a type; did you mean '__false_type'?
     typedef __native_type*   native_handle_type;
             ^~~~~~~~~~~~~
             __false_type
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable:159:5: error: 'native_handle_type' does not name a type; did you mean 'uv_handle_type'?
     native_handle_type
     ^~~~~~~~~~~~~~~~~~
     uv_handle_type
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable: In member function 'std::cv_status std::condition_variable::__wait_until_impl(std::unique_lock<std::mutex>&, const std::chrono::time_point<std::chrono::_V2::system_clock, _Dur2>&)':
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable:172:2: error: '__gthread_time_t' was not declared in this scope
  __gthread_time_t __ts =
  ^~~~~~~~~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable:172:2: note: suggested alternative: '__gthread_once_t'
  __gthread_time_t __ts =
  ^~~~~~~~~~~~~~~~
  __gthread_once_t
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable:178:28: error: '_M_cond' was not declared in this scope
  __gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(),
                            ^~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable:179:7: error: '__ts' was not declared in this scope
      &__ts);
       ^~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable:179:7: note: suggested alternative: '__ns'
      &__ts);
       ^~~~
       __ns
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable:178:2: error: there are no arguments to '__gthread_cond_timedwait' that depend on a template parameter, so a declaration of '__gthread_cond_timedwait' must be available [-fpermissive]
  __gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(),
  ^~~~~~~~~~~~~~~~~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/condition_variable:178:2: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
In file included from /boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/mutex:46,
                 from /Haiku-nvme/data/haikuports/dev-util/cmake/work-3.20.2/sources/cmake-3.20.2/Source/cmUVHandlePtr.cxx::
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread: At global scope:
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:74:13: error: '__gthread_t' does not name a type; did you mean 'uv_thread_t'?
     typedef __gthread_t   native_handle_type;
             ^~~~~~~~~~~
             uv_thread_t
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:79:7: error: 'native_handle_type' does not name a type; did you mean 'uv_handle_type'?
       native_handle_type _M_thread;
       ^~~~~~~~~~~~~~~~~~
       uv_handle_type
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:85:28: error: expected ')' before '__id'
       id(native_handle_type __id) : _M_thread(__id) { }
         ~                  ^~~~~
                            )
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:178:5: error: 'native_handle_type' does not name a type; did you mean 'uv_handle_type'?
     native_handle_type
     ^~~~~~~~~~~~~~~~~~
     uv_handle_type
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread: In constructor 'std::thread::id::id()':
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:82:23: error: class 'std::thread::id' does not have any field named '_M_thread'
       id() noexcept : _M_thread() { }
                       ^~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread: In function 'bool std::operator==(std::thread::id, std::thread::id)':
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:283:16: error: 'class std::thread::id' has no member named '_M_thread'
     return __x._M_thread == __y._M_thread;
                ^~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:283:33: error: 'class std::thread::id' has no member named '_M_thread'
     return __x._M_thread == __y._M_thread;
                                 ^~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread: In function 'bool std::operator<(std::thread::id, std::thread::id)':
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:295:16: error: 'class std::thread::id' has no member named '_M_thread'
     return __x._M_thread < __y._M_thread;
                ^~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:295:32: error: 'class std::thread::id' has no member named '_M_thread'
     return __x._M_thread < __y._M_thread;
                                ^~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread: In member function 'std::size_t std::hash<std::thread::id>::operator()(const std::thread::id&) const':
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:318:43: error: 'const class std::thread::id' has no member named '_M_thread'
       { return std::_Hash_impl::hash(__id._M_thread); }
                                           ^~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread: In function 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::thread::id)':
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:328:23: error: 'class std::thread::id' has no member named '_M_thread'
  return __out << __id._M_thread;
                       ^~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread: In function 'std::thread::id std::this_thread::get_id()':
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:349:25: error: '__gthread_self' was not declared in this scope
       return thread::id(__gthread_self());
                         ^~~~~~~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:349:25: note: suggested alternative: 'uv_thread_self'
       return thread::id(__gthread_self());
                         ^~~~~~~~~~~~~~
                         uv_thread_self
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread: In function 'void std::this_thread::yield()':
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:357:7: error: '__gthread_yield' was not declared in this scope
       __gthread_yield();
       ^~~~~~~~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:357:7: note: suggested alternative: '__gthread_once'
       __gthread_yield();
       ^~~~~~~~~~~~~~~
       __gthread_once
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread: In function 'void std::this_thread::sleep_for(const std::chrono::duration<_Rep1, _Period1>&)':
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:374:2: error: '__gthread_time_t' was not declared in this scope
  __gthread_time_t __ts =
  ^~~~~~~~~~~~~~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:374:2: note: suggested alternative: '__gthread_once_t'
  __gthread_time_t __ts =
  ^~~~~~~~~~~~~~~~
  __gthread_once_t
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:379:22: error: '__ts' was not declared in this scope
  while (::nanosleep(&__ts, &__ts) == -1 && errno == EINTR)
                      ^~~~
/boot/system/develop/tools/lib/gcc/riscv64-unknown-haiku/8.3.0/include/c++/thread:379:22: note: suggested alternative: '__n'
  while (::nanosleep(&__ts, &__ts) == -1 && errno == EINTR)
                      ^~~~
                      __ns
Makefile:392: recipe for target 'cmUVHandlePtr.o' failed
make: *** [cmUVHandlePtr.o] Error 1
---------------------------------------------
Error when bootstrapping CMake:
Problem while running make
---------------------------------------------
Log of errors: /Haiku-nvme/data/haikuports/dev-util/cmake/work-3.20.2/sources/cmake-3.20.2/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------

Are libstdc++ threads supposed to work on Haiku?

Yes. They do on x86 and x86_64 at least, I believe WebKit uses them. libstdc++ just uses pthreads internally.

That is why you need to start from haikuports.cross packages, which are cross compiled from another system where the dependencies are available. There is no way to build things starting just from haikuports recipes.

The bootstrapping process is briefly documented here: Bootstrapping Haiku — Haiku internals documentation

The main thing here is ueing “haikuporter --do-bootstrap” in your running Haiku image. I don’t remember what the switch does exactly. You don’t need to specify a specific package. It will rely on some prebuilt cross compiled packages to get started, and will rebuild everything.

2 Likes

When this was confirmed to work for the last time? I feel that haikuports.cross and haikuporter --do-bootstrap are no longer consistent anymore because of CMake, Python and other packages changes.

I think the last time the full process was run was sometimes in 2012 or 2013 when introducing the package management system to Haiku.

Since then they have been partial runs, of only the cross-compiling part for ARM and SPARC, and of the Haiku part probably by @korli when he worked on running gcc2 apps on a 64bit system (this required building packages for gcc2 as a secondary architecture, but I’m not sure how much of the bootstrap was used there).

I would remove the GUI subpackage and the Qt dependency in the cmake recipe, maybe it’s enough to avoid a cycle.

1 Like

Tried that here, still didn’t solve the issue

It was used again with the change of time_t to 64bit on x86_64, see https://git.haiku-os.org/haiku/commit/?id=9690e94af285564ee0d80f5768c5dfca9642a489

It would be nice to run it for each release to ensure that it is not broken.

6 Likes

Updated python_bootstrap: haikuports.cross/python_bootstrap-3.9.1.recipe at master · haikuports/haikuports.cross · GitHub

AFAICT it cross-compiles modules now. Also I hope I never have to cross-compile python ever again…

9 Likes

I fixed c++ threads by adjusting GCC headers (copy bits/gthr-posix.h to bits/gthr.h). After that fix CMake compiles and runs fine.

6 Likes