Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build issue #206

Open
nateskulic opened this issue Jan 22, 2025 · 20 comments
Open

Build issue #206

nateskulic opened this issue Jan 22, 2025 · 20 comments
Labels

Comments

@nateskulic
Copy link

Hi!

I wanted to try to build this (in the form of an rpm package).

It stops during a cmake build, right after the pcre2 target.

I think it might have to do with pybind11... I tried using the system provided pybind11, but it couldn't find that for some reason (maybe that is best as a separate issue).

Keep getting an error I can't seem to get any debug on, or get past.

Tried the latest release (4.7.1) and the latest checkout (as of 20250121).

Wondering if you have any clues.

The error follows:

[ 45%] Completed 'pcre2'
/usr/bin/cmake -E make_directory $HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build/CMakeFiles
/usr/bin/cmake -E touch $HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build/CMakeFiles/pcre2-complete
/usr/bin/cmake -E touch $HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build/pcre2-prefix/src/pcre2-stamp/pcre2-done
gmake[2]: Leaving directory '$HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build'
[ 45%] Built target pcre2
gmake[1]: Leaving directory '$HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build'
gmake: *** [Makefile:139: all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.HxXc7c (%build)

($HOME is my home)

Using the following to setup cmake:

/usr/bin/cmake -S . -B redhat-linux-build -DCMAKE_C_FLAGS_RELEASE:STRING=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE:STRING=-DNDEBUG -DCMAKE_Fortran_FLAGS_RELEASE:STRING=-DNDEBUG -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_INSTALL_DO_STRIP:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr -DINCLUDE_INSTALL_DIR:PATH=/usr/include -DLIB_INSTALL_DIR:PATH=/usr/lib64 -DSYSCONF_INSTALL_DIR:PATH=/etc -DSHARE_INSTALL_PREFIX:PATH=/usr/share -DLIB_SUFFIX=64 -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Release -DWITH_X11_FEATURES=OFF -DWITH_DESKTOP=ON -DBUILD_TAGLIB=OFF -DBUILD_RUBBERBAND=OFF -DBUILD_PYBIND11=ON -DBUILD_XZ=ON -DBUILD_OPENBLAS=OFF -DBUILD_FMT=OFF -DBUILD_LIBARCHIVE=OFF -DWITH_PY=ON -DBUILD_QQC2_BREEZE_STYLE=ON -DBUILD_VOSK=OFF -DBUILD_CATCH2=OFF -DBUILD_WHISPERCPP_VULKAN=ON -DBUILD_FFMPEG=ON -DBUILD_BERGAMOT=OFF -DBUILD_RHVOICE=OFF -DBUILD_RHVOICE_MODULE=OFF -DDOWNLOAD_LIBSTT=OFF -DBUILD_ESPEAK_MODULE=OFF -DBUILD_WHISPERCPP_CUBLAS=OFF -DBUILD_WHISPERCPP_HIPBLAS=OFF
@mkiol
Copy link
Owner

mkiol commented Jan 23, 2025

Nice!

The cmake command looks fine. I checked it on my system and it works. Most likely, the problem lies in a missing dependency that was not checked at the configuration stage (aka cmake stage). The root cause is printed somewhere above the lines you pasted. It is definitely not a problem with pcre2.

Can you try also with -DBUILD_QQC2_BREEZE_STYLE=OFF?

@nateskulic
Copy link
Author

Just attempted with -DBUILD_QQC2_BREEZE_STYLE=off; same stop point and error.

You are probably right in regards to missing dependency. I've been attempting to match up requirements with the arch PKGBUILD, but probably missed something. This is a build machine, so excessive amount of dependencies and devel packages are already installed.

Also tried export VERBOSE=1 and export V=1 to see if make/gmake would pick up something.

I'm not sure which Makefile the line number is coming from (dammit, make). If it was the one at the root of build, annotated below:

# The main all target
all: cmake_check_build_system
        $(CMAKE_COMMAND) -E cmake_progress_start $HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build/CMakeFiles $HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build//CMakeFiles/progress.marks
        $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all # <<< failing line (139)
        $(CMAKE_COMMAND) -E cmake_progress_start $HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build/CMakeFiles 0

@mkiol
Copy link
Owner

mkiol commented Jan 23, 2025

I've been attempting to match up requirements with the arch PKGBUILD, but probably missed something.

Rather, it is a problem in the cmake script. All dependencies should be verified during the "cmake" step, but not in "make", so it's a bug on my side.

Can you share entire output from cmake and make run?

@nateskulic
Copy link
Author

Aha, yes, definitely a cmake dependency check missing.

Log attached; it's the output of rpmbuild. Any rpmbuild lines are prefixed with + . Both cmake and make are called in this log.

dsnote.log

@mkiol
Copy link
Owner

mkiol commented Jan 24, 2025

I honestly don't know what went wrong. This log of multi-threaded build is very difficult to read. Can you try with only one thread by adding -j1 to make step?

I suspect this may be the cause (but I am most likely wrong):

-- Found Vulkan: /lib64/libvulkan.so (found version "1.3.283") found components: glslangValidator missing components: glslc

What is the result with -DBUILD_WHISPERCPP_VULKAN=OFF?

@nateskulic
Copy link
Author

nateskulic commented Jan 24, 2025

Flag is now -DBUILD_WHISPERCPP_VULKAN=OFF; same error.

Tried installing glslc, as it was supposedly missing; same error.

-j1 caused an error:

checking whether we are cross compiling... configure: error: in `$HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build/external/rnnoise'
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

Digging more, I flipped on -DCMAKE_BUILD_PARALLEL_LEVEL=1, also passing --parallel 1 and -j1 to cmake --build, and it slowed the build down, failing at a different [earlier] point:

[  8%] Built target whispercppopenblas
gmake[1]: Leaving directory '$HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build'
gmake: *** [Makefile:139: all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.9nkLuE (%build)

Setting it to -j2 to -j5 resulted in the same error, more or less. -j6 brings us to the PCRE stop point. Tried variations of these flags (including -DCMAKE_BUILD_PARALLEL_LEVEL=2) to see if it would move different or past, to no avail.

@mkiol
Copy link
Owner

mkiol commented Jan 25, 2025

Thanks for checking.

When using j1, build stops exactly when an error occurs. In parallel build, multiple targets are compiled at the same time, so entire build stops when all parallel tasks are finished. Therefore output log is messy.

So output of j1 tells us what went wrong. It seems that the problem is related to rnnoise. Can you check what is in the log file config.log?

See `config.log' for more details

@nateskulic
Copy link
Author

This is the contents of rnnoise config.log:

Configured with: ../configure --enable-bootstrap --enable-host-pie --enable-host-bind-now --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.rockylinux.org/ --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-plugin --enable-initfini-array --without-isl --enable-multilib --with-linker-hash-style=gnu --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_64=x86-64-v2 --with-arch_32=x86-64 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.5.0 20240719 (Red Hat 11.5.0-2) (GCC)
... rest of stderr output deleted ...
configure:2610: $? = 0
configure:2599: gcc -V >&5
gcc: error: unrecognized command-line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:2610: $? = 1
configure:2599: gcc -qversion >&5
gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:2610: $? = 1
configure:2630: checking whether the C compiler works
configure:2652: gcc -Dpitch_downsample=rnnoise_pitch_downsample     -Dpitch_search=rnnoise_pitch_search     -Dremove_doubling=rnnoise_remove_doubling     -D_celt_lpc=rnnoise__celt_lpc     -Dcelt_iir=rnnoise_celt_iir     -D_celt_autocorr=rnnoise__celt_autocorr     -Dcompute_gru=rnnoise_compute_gru     -Dcompute_dense=rnnoise_compute_dense  -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  conftest.c  >&5
configure:2656: $? = 0
configure:2704: result: yes
configure:2707: checking for C compiler default output file name
configure:2709: result: a.out
configure:2715: checking for suffix of executables
configure:2722: gcc -o conftest -Dpitch_downsample=rnnoise_pitch_downsample     -Dpitch_search=rnnoise_pitch_search     -Dremove_doubling=rnnoise_remove_doubling     -D_celt_lpc=rnnoise__celt_lpc     -Dcelt_iir=rnnoise_celt_iir     -D_celt_autocorr=rnnoise__celt_autocorr     -Dcompute_gru=rnnoise_compute_gru     -Dcompute_dense=rnnoise_compute_dense  -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  conftest.c  >&5
configure:2726: $? = 0
configure:2748: result:
configure:2770: checking whether we are cross compiling
configure:2778: gcc -o conftest -Dpitch_downsample=rnnoise_pitch_downsample     -Dpitch_search=rnnoise_pitch_search     -Dremove_doubling=rnnoise_remove_doubling     -D_celt_lpc=rnnoise__celt_lpc     -Dcelt_iir=rnnoise_celt_iir     -D_celt_autocorr=rnnoise__celt_autocorr     -Dcompute_gru=rnnoise_compute_gru     -Dcompute_dense=rnnoise_compute_dense  -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  conftest.c  >&5
/usr/bin/ld: /tmp/ccirbkrv.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status
configure:2782: $? = 1
configure:2789: ./conftest
$HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build/external/rnnoise/configure: line 2791: ./conftest: No such file or directory
configure:2793: $? = 127
configure:2800: error: in `$HOME/rpmbuild/BUILD/dsnote-20250121/redhat-linux-build/external/rnnoise':
configure:2802: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

Looks like it's saying to add an fPIE flag, which I may do. Currently, using mostly system provided/packager recommended default flags for compilation/etc (CC/LDFLAGS/etc).

@mkiol
Copy link
Owner

mkiol commented Jan 26, 2025

I don't know what is wrong :/

I compared with the config.log generated on my system and there are differences in the linker flags.

your system:

configure:2778: gcc -o conftest -Dpitch_downsample=rnnoise_pitch_downsample     -Dpitch_search=rnnoise_pitch_search     -Dremove_doubling=rnnoise_remove_doubling     -D_celt_lpc=rnnoise__celt_lpc     -Dcelt_iir=rnnoise_celt_iir     -D_celt_autocorr=rnnoise__celt_autocorr     -Dcompute_gru=rnnoise_compute_gru     -Dcompute_dense=rnnoise_compute_dense  -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  conftest.c  >&5

my:

configure:3220: gcc -o conftest -Dpitch_downsample=rnnoise_pitch_downsample     -Dpitch_search=rnnoise_pitch_search     -Dremove_doubling=rnnoise_remove_doubling     -D_celt_lpc=rnnoise__celt_lpc     -Dcelt_iir=rnnoise_celt_iir     -D_celt_autocorr=rnnoise__celt_autocorr     -Dcompute_gru=rnnoise_compute_gru     -Dcompute_dense=rnnoise_compute_dense   conftest.c  >&5

It looks like you are adding the following additional flags: -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1. I have no idea what they are for, but perhaps these flags are causing the problem.

@nateskulic
Copy link
Author

nateskulic commented Jan 26, 2025

I believe these are default hardening for redhat distributions.

/usr/lib/rpm/redhat/redhat-hardened-ld contains:

*self_spec:
+ %{!static:%{!shared:%{!r:-pie}}}

Which I believe may be adding the -pie flag if not building a shared/static library.

/usr/lib/rpm/redhat/redhat-annobin-cc1 contains:

*cc1_options:
+ %{!-fno-use-annobin:%{!iplugindir*:%:find-plugindir()} -fplugin=annobin}

-Wl,OPTION: Pass OPTION as an option to the linker. If OPTION contains commas, it is split into multiple options at the commas.

  • -z,now may be "BIND_NOW", resolving all symbols before execution.
  • -z,relro is "Hardening ELF binaries using Relocation Read-Only (RELRO)" (makes the dynamic relocation offset table read-only after initial relocation) See redhat and blog
  • --as-needed is "don't link against/with unused libraries provided"

I think rnnoise's configure is not picking up the intended flags for some reason; maybe something autotools related.
I'll see what i can do to dig out the failing conftest.c, because it's not showing me it, and I can't find it.

@nateskulic
Copy link
Author

Also, being no fan of autotools, I would suggest integrating as much as possible with the cmake build system of this project.

For example, for rnnoise, see this CMakeLists.txt

While I can imagine it can't be done for every dependency, I can see it being reasonable for small libraries — reducing the dependency on autotools insanity.

@mkiol
Copy link
Owner

mkiol commented Jan 27, 2025

For example, for rnnoise, see this CMakeLists.txt
While I can imagine it can't be done for every dependency, I can see it being reasonable for small libraries — reducing the dependency on autotools insanity.

Sounds like something I can do. This project already has plenty of patches, so one more won't make a difference.

I think rnnoise's configure is not picking up the intended flags for some reason; maybe something autotools related.

I tried to inject all the flags from your compilation and was not able to reproduce the error. Do you know how, in a not-too-painful way, I could reproduce exactly the environment and toolchain that are used in your build?

@nateskulic
Copy link
Author

nateskulic commented Jan 28, 2025

I just tested this:

Prerequisites:

  • A way to run virtual machines (e.g. virtualbox, or libvirt and virtual machine manager)

Reproduction steps:

  1. Install rocky 9.5 in a VM with network access. The minimal iso is sufficient.

    • Make sure to enable the root account and ssh access during install.
    • I suggest at least 20-30gb of disk. Standard partition layout is fine.
  2. Sign in as root. All steps after this are inside the virtual machine.

    • you can typically access the machine with ssh root@ip where ip is probably 192.168.122.xxx
    • you may want to copy/set up ssh keys to ssh/scp into the VM easier.
  3. Install some packages to start things off by running dnf install rpmdevtools yum-utils epel-release

  4. Enable the Code ready builder repository (for devel packages, among others) by running
    dnf config-manager --set-enabled crb

  5. Run rpmdev-setuptree to setup the ~/rpmbuild folder.

  6. Download the attached dsnote.spec.txt file to ~/rpmbuild/SPECS (make sure to remove the .txt extension).

  7. Download dsnote source release tar.gz to ~/rpmbuild/SOURCES. If master release, folder in source tar must be renamed to dsnote-{version}, where {version} matches the version in the rpm spec file (e.g. dsnote-master to dsnote-YYYYMMDD). Release archives are usually named/structured correctly and don't require renaming. (For example, curl -o dsnote-4.7.1.tar.gz https://github.com/mkiol/dsnote/archive/refs/tags/v4.7.1.tar.gz)

  8. Install dependencies to build dsnote by running yum-builddep ~/rpmbuild/SPECS/dsnote.spec

  9. Run rpmbuild -bb ~/rpmbuild/SPECS/dsnote.spec to build rpm, subsequently reporting error.

Spec file attached. It's incomplete; missing lines for runtime "Requires" (as I haven't gotten to that point yet), and there is probably some BuildRequires packages missing.

I've currently uncommented the %cmake_build macro; it normally expands to cmake --build -j16 ....... Note: rpmbuild will complain if you leave macro markers in comments.

Hope its not too painful. 🙂

@mkiol
Copy link
Owner

mkiol commented Jan 29, 2025

This is a very cool manual :) You explained everything perfectly. I'll try it out over the weekend and let you know the results.

@mkiol mkiol added the build label Jan 29, 2025
@mkiol
Copy link
Owner

mkiol commented Feb 2, 2025

I managed to reproduce the problem (thanks to your amazing guidelines).

As you suggested, the problem lies in /usr/lib/rpm/redhat/redhat-hardened-ld and the linker flag -pie. The solution is to add -fpie to the CFLAGS, but cmake for rnnoise overwrites the CFLAGS, so you can't just set new CFLAGS in the RPM spec.

The only way I've found that doesn't require changes to the upstream code is to patch dsnote.

new file rpmbuild/SOURCES/dsnote.patch

diff -ruN dsnote-4.7.1/cmake/rnnoise.cmake dsnote-4.7.1-patched/cmake/rnnoise.cmake
--- dsnote-4.7.1/cmake/rnnoise.cmake	2025-01-05 15:50:08.000000000 +0100
+++ dsnote-4.7.1-patched/cmake/rnnoise.cmake	2025-02-02 19:19:06.048021554 +0100
@@ -20,7 +20,8 @@
     -Dcelt_iir=rnnoise_celt_iir \
     -D_celt_autocorr=rnnoise__celt_autocorr \
     -Dcompute_gru=rnnoise_compute_gru \
-    -Dcompute_dense=rnnoise_compute_dense")
+    -Dcompute_dense=rnnoise_compute_dense
+    -fpie")
 
 ExternalProject_Add(rnnoise
     SOURCE_DIR ${external_dir}/rnnoise

modifications in rpmbuild/SPECS/dsnote.spec

@@ -6,6 +6,7 @@
 License:        MPL-2.0
 URL:            https://github.com/mkiol/dsnote
 Source0:        https://github.com/mkiol/dsnote/archive/refs/tags/dsnote-%{version}.tar.gz
+Patch0:         dsnote.patch
 
 BuildRequires: autoconf
 BuildRequires: automake
@@ -39,7 +40,7 @@
 Linux desktop and Sailfish OS app for note taking, reading and translating with offline Speech to Text, Text to Speech and Machine Translation
 
 %prep
-%autosetup
+%autosetup -p1
 
 
 %build

rnnoise compiled successfully, but I encountered another problem:

/root/rpmbuild/BUILD/dsnote-4.7.1/src/fake_keyboard.cpp:185:22: error: 'xkb_compose_table_iterator_new' was not declared in this scope; did you mean 'xkb_compose_table_unref'?
  185 |         auto *iter = xkb_compose_table_iterator_new(m_xkb_compose_table);
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                      xkb_compose_table_unref

libxkbcommon in rocky is too old. To compile, version >= 1.6.0 is needed. The workaround is to disable X11 features with -DWITH_X11_FEATURES=OFF. I will try to solve this problem in a more general way in the next version.

An additional but minor problem: whisper.cpp was not detecting openblas:

-- Could NOT find BLAS (missing: BLAS_LIBRARIES) 
CMake Warning at ggml/src/CMakeLists.txt:253 (message):
  BLAS not found, please refer to
  https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors
  to set correct GGML_BLAS_VENDOR

Also this:

ERROR   0002: file '/usr/bin/dsnote' contains an invalid rpath '/usr/share/dsnote/lib' in [/usr/share/dsnote/lib:/usr/lib]

For some reason, rpmbuilder does not like rpath in shared libraries. The rpath is set to /usr/share/dsnote/lib because the libraries are installed in that directory. I don't know why this is a problem 🤔

@nateskulic
Copy link
Author

nateskulic commented Feb 2, 2025

Excellent Work!

An additional but minor problem: whisper.cpp was not detecting openblas:

Let's see, we have openblas-devel in the build requires list... I presume we might need a export GGML_BLAS_VENDOR=OpenBLAS line before the cmake run.

For some reason, rpmbuilder does not like rpath in shared libraries. The rpath is set to /usr/share/dsnote/lib because the libraries are installed in that directory. I don't know why this is a problem 🤔

It's a Red Hat/Fedora policy. Sometimes a foolish one, especially for apps that want to control their libraries... I believe one intent was to enforce shared library usage. I don't often agree, as creates more work... With that, we're going to package this with all libraries included and rpath checks mostly disabled, and we'll use whatever system provided libraries we can; as we often do... If it works, it works. 🙂

--disable-rpath can sometimes be used with autoconf/configure scripts. To simply disable the check in rpmbuild, add a line to the head of *.spec file: %global __brp_check_rpaths %{nil}

Currently using Wayland/KDE (on the same distro/version) — works dandy — so X11 is on the chopping block here. Ideally it would be functional, but probably not as critical.

@mkiol
Copy link
Owner

mkiol commented Feb 3, 2025

Let's see, we have openblas-devel in the build requires list... I presume we might need a export GGML_BLAS_VENDOR=OpenBLAS line before the cmake run.

It was actually something else. Cmake didn't try to find libopenblas in /usr/lib64. Only the following directories were considered:

    /root/rpmbuild/BUILD/dsnote-4.7.1/redhat-linux-build/external/lib/(lib)openblas(\.so|\.a|\.so\.3gf)
    /root/rpmbuild/BUILD/dsnote-4.7.1/redhat-linux-build/external/(lib)openblas(\.so|\.a|\.so\.3gf)
    /root/.local/bin/(lib)openblas(\.so|\.a|\.so\.3gf)
    /root/bin/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/local/sbin/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/local/bin/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/sbin/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/bin/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/local/lib/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/local/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/lib/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/(lib)openblas(\.so|\.a|\.so\.3gf)
    /lib/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/X11R6/lib/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/X11R6/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/pkg/lib/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/pkg/(lib)openblas(\.so|\.a|\.so\.3gf)
    /opt/lib/(lib)openblas(\.so|\.a|\.so\.3gf)
    /opt/(lib)openblas(\.so|\.a|\.so\.3gf)
    /usr/lib/X11/(lib)openblas(\.so|\.a|\.so\.3gf)

Fixed by adding -DCMAKE_LIBRARY_PATH=/usr/lib64.

There was also a problem in mbrola. I had to update the mbrola source code to the latest upstream version, where the problem was resolved.

To simply disable the check in rpmbuild, add a line to the head of *.spec file: %global __brp_check_rpaths %{nil}

For some reason this didn't work on my system. To workaround I used QA_RPATHS=$(( 0x0001|0x0010|0x0002 )) rpmbuild -bb ~/rpmbuild/SPECS/dsnote.spec.

Last not resolved error is this one:

error: File not found: /root/rpmbuild/BUILDROOT/dsnote-4.7.1-1.el9.x86_64/usr/share/licenses/dsnote/add-license-file-here

I guess dsnote should also install the license file? Can this also be skipped?

Current patch:

rpmbuild/SOURCES/dsnote.patch:

diff -ruN dsnote-4.7.1/cmake/espeak.cmake dsnote-4.7.1-patched/cmake/espeak.cmake
--- dsnote-4.7.1/cmake/espeak.cmake     2025-01-05 15:50:08.000000000 +0100
+++ dsnote-4.7.1-patched/cmake/espeak.cmake     2025-02-03 19:50:09.193430572 +0100
@@ -1,5 +1,5 @@
-set(mbrola_source_url "https://github.com/numediart/MBROLA/archive/refs/tags/3.3.tar.gz")
-set(mbrola_checksum "c01ded2c0a05667e6df2439c1c02b011a5df2bfdf49e24a524630686aea2b558")
+set(mbrola_source_url "https://github.com/numediart/MBROLA/archive/bf17e9e1416a647979ac683657a536e8ca5d880e.zip")
+set(mbrola_checksum "5a7c02a926dc48ab6d1af0e4c8ab53fc191a7e4337de6df57b6706e140fa3087")
 
 set(espeak_source_url "https://github.com/rhasspy/espeak-ng/archive/8593723f10cfd9befd50de447f14bf0a9d2a14a4.zip")
 set(espeak_checksum "cc8092f23a28ccd79b1c5e62984a4c4ac1959d2d0b8193ac208d728c620bd5ed")
diff -ruN dsnote-4.7.1/cmake/rnnoise.cmake dsnote-4.7.1-patched/cmake/rnnoise.cmake
--- dsnote-4.7.1/cmake/rnnoise.cmake    2025-01-05 15:50:08.000000000 +0100
+++ dsnote-4.7.1-patched/cmake/rnnoise.cmake    2025-02-02 19:33:49.181678060 +0100
@@ -20,7 +20,8 @@
     -Dcelt_iir=rnnoise_celt_iir \
     -D_celt_autocorr=rnnoise__celt_autocorr \
     -Dcompute_gru=rnnoise_compute_gru \
-    -Dcompute_dense=rnnoise_compute_dense")
+    -Dcompute_dense=rnnoise_compute_dense \
+    -fpie")
 
 ExternalProject_Add(rnnoise
     SOURCE_DIR ${external_dir}/rnnoise
diff -ruN dsnote-4.7.1/cmake/whispercpp.cmake dsnote-4.7.1-patched/cmake/whispercpp.cmake
--- dsnote-4.7.1/cmake/whispercpp.cmake 2025-01-05 15:50:08.000000000 +0100
+++ dsnote-4.7.1-patched/cmake/whispercpp.cmake 2025-02-03 20:03:04.684270101 +0100
@@ -318,6 +318,7 @@
         -DCMAKE_C_FLAGS=${whispercpp_flags} -DCMAKE_CXX_FLAGS=${whispercpp_flags}
         -DCMAKE_INSTALL_RPATH=${rpath_install_dir}
         -DWHISPER_TARGET_NAME=whisper-openblas
+        -DCMAKE_LIBRARY_PATH=/usr/lib64
     BUILD_ALWAYS False
 )

I am one step ahead of successful build :)

@nateskulic
Copy link
Author

nateskulic commented Feb 3, 2025

Truly Excellent!

I guess dsnote should also install the license file? Can this also be skipped?

Yes. License: tag already included is sufficient as it is standard license.

There's a %files list at the end of the spec file. The intent is to specify all of the files that were installed into $RPM_BUILD_ROOT (typically ~/rpmbuild/BUILDROOT/dsnote-{version}). Delete the %license and %docs lines (which are artifacts of a command called rpmdev-newspec).

Once rpmbuild finishes the %build step, it should complain about "Installed (but unpackaged) file(s) found", printing a list of unpackaged files afterwards. You may take this list and copy it into the %files list.... Alternatively, do a find on $RPM_BUILD_ROOT; copy all the directories into this list (ensuring an ending slash meaning recursively); copy all the "standalone" files into this list. That'll capture all the files into the rpm.

E.g.

%files
/usr/bin/dsnote
/usr/lib64/dsnote/

P.S. You may add a -ba instead of -bb flag to build all (source rpm (*.srpm) and binary rpm (*.rpm)) instead of just binary rpm. The srpm will contain the spec file and tarball, among others. Later one may take this SRPM and pass it along; e.g. to other tools/distributions, or for automatic build.

@mkiol
Copy link
Owner

mkiol commented Feb 9, 2025

Hello, I just wanted to give an update on the progress. I haven't had much time to play with it, but I finally managed to build the package :) It can be installed and works fine, but only under KDE. There is a problem on GNOME - the UI is completely unreadable. I'm trying to find where the problem is.

I'll upload a working spec file when it's ready to this git repo.

@nateskulic
Copy link
Author

nateskulic commented Feb 10, 2025

One last thing, so the rpm can be mostly portable between rpm based distributions:

Replace some of the literal paths/prefixes in the build file (including the %files list) with macros from "Macros for paths set and used by build systems".

e.g. /usr/bin -> %{_bindir} and /usr/lib64 -> %{_libdir}

They are macros because some distros change these up (and they may be changed in the future).

(I usually leave this step last as a simple multi-search/replace transform when composing spec files.)

I'll give it my own run down and report as necessary.

Thank You for making this good.

Great work @mkiol!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants