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

Problems with building on Arch Linux #14

Closed
dvdesolve opened this issue Dec 30, 2019 · 8 comments
Closed

Problems with building on Arch Linux #14

dvdesolve opened this issue Dec 30, 2019 · 8 comments

Comments

@dvdesolve
Copy link

dvdesolve commented Dec 30, 2019

With the transition to CMake build system some problems appeared. AUR package is available here

  1. Main problem is incompatibility with systemwide LDFLAGS. Here is my makepkg.conf:
#!/hint/bash
#
# /etc/makepkg.conf
#

#########################################################################
# SOURCE ACQUISITION
#########################################################################
#
#-- The download utilities that makepkg should use to acquire sources
#  Format: 'protocol::agent'
DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
          'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
          'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'rsync::/usr/bin/rsync --no-motd -z %u %o'
          'scp::/usr/bin/scp -C %u %o')

# Other common tools:
# /usr/bin/snarf
# /usr/bin/lftpget -c
# /usr/bin/wget

#-- The package required by makepkg to download VCS sources
#  Format: 'protocol::package'
VCSCLIENTS=('bzr::bzr'
            'git::git'
            'hg::mercurial'
            'svn::subversion')

#########################################################################
# ARCHITECTURE, COMPILE FLAGS
#########################################################################
#
CARCH="x86_64"
CHOST="x86_64-pc-linux-gnu"

#-- Compiler and Linker Flags
CPPFLAGS="-D_FORTIFY_SOURCE=2"
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt"
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
#-- Make Flags: change this for DistCC/SMP systems
MAKEFLAGS="-j2"
#-- Debugging flags
DEBUG_CFLAGS="-g -fvar-tracking-assignments"
DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"

#########################################################################
# BUILD ENVIRONMENT
#########################################################################
#
# Defaults: BUILDENV=(!distcc !color !ccache check !sign)
#  A negated environment option will do the opposite of the comments below.
#
#-- distcc:   Use the Distributed C/C++/ObjC compiler
#-- color:    Colorize output messages
#-- ccache:   Use ccache to cache compilation
#-- check:    Run the check() function if present in the PKGBUILD
#-- sign:     Generate PGP signature file
#
BUILDENV=(!distcc color !ccache check sign)
#
#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
#-- specify a space-delimited list of hosts running in the DistCC cluster.
#DISTCC_HOSTS=""
#
#-- Specify a directory for package building.
BUILDDIR=/tmp/makepkg

#########################################################################
# GLOBAL PACKAGE OPTIONS
#   These are default values for the options=() settings
#########################################################################
#
# Default: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug)
#  A negated option will do the opposite of the comments below.
#
#-- strip:      Strip symbols from binaries/libraries
#-- docs:       Save doc directories specified by DOC_DIRS
#-- libtool:    Leave libtool (.la) files in packages
#-- staticlibs: Leave static library (.a) files in packages
#-- emptydirs:  Leave empty directories in packages
#-- zipman:     Compress manual (man and info) pages in MAN_DIRS with gzip
#-- purge:      Remove files specified by PURGE_TARGETS
#-- debug:      Add debugging flags as specified in DEBUG_* variables
#
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug)

#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5)
#-- Options to be used when stripping binaries. See `man strip' for details.
STRIP_BINARIES="--strip-all"
#-- Options to be used when stripping shared libraries. See `man strip' for details.
STRIP_SHARED="--strip-unneeded"
#-- Options to be used when stripping static libraries. See `man strip' for details.
STRIP_STATIC="--strip-debug"
#-- Manual (man and info) directories to compress (if zipman is specified)
MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
#-- Doc directories to remove (if !docs is specified)
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
#-- Files to be removed from all packages (if purge is specified)
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
#-- Directory to store source code in for debug packages
DBGSRCDIR="/usr/src/debug"

#########################################################################
# PACKAGE OUTPUT
#########################################################################
#
# Default: put built package and cached source in build directory
#
#-- Destination: specify a fixed directory where all packages will be placed
#PKGDEST=/home/packages
#-- Source cache: specify a fixed directory where source files will be cached
#SRCDEST=/home/sources
#-- Source packages: specify a fixed directory where all src packages will be placed
#SRCPKGDEST=/home/srcpackages
#-- Log files: specify a fixed directory where all log files will be placed
#LOGDEST=/home/makepkglogs
#-- Packager: name/email of the person or organization building packages
#PACKAGER=""
#-- Specify a key to use for package signing
#GPGKEY=""

#########################################################################
# COMPRESSION DEFAULTS
#########################################################################
#
COMPRESSGZ=(gzip -c -f -n)
COMPRESSBZ2=(bzip2 -c -f)
COMPRESSXZ=(xz -c -z -)
COMPRESSZST=(zstd -c -z -q -)
COMPRESSLRZ=(lrzip -q)
COMPRESSLZO=(lzop -q)
COMPRESSZ=(compress -c -f)
COMPRESSLZ4=(lz4 -q)
COMPRESSLZ=(lzip -c -f)

#########################################################################
# EXTENSION DEFAULTS
#########################################################################
#
PKGEXT='.pkg.tar.xz'
SRCEXT='.src.tar.gz'

And here is PKGBUILD for this package:

# Maintainer: Viktor Drobot (aka dviktor) linux776 [at] gmail [dot] com
# Contributor: Julio Diez <juliosddr@gmail.com>

pkgname=sigutils-git
pkgver=r204.2555138
pkgrel=1
pkgdesc="Digital signal processing library"
arch=("any")
url="https://github.com/BatchDrake/sigutils"
license=("GPL")
depends=("libsndfile" "alsa-lib" "fftw")
makedepends=("git" "cmake>=3.7.2")
optdepends=("libvolk")
provides=("sigutils")
conflicts=("sigutils")
source=(${pkgname}::git+https://github.com/BatchDrake/sigutils.git)
md5sums=('SKIP')

pkgver() {
    cd "${pkgname}"
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd "$pkgname"
  
  mkdir build
  cd build

  cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_RPATH=ON -DCMAKE_SKIP_INSTALL_RPATH=ON ..
  make
}

package() {
  cd "$pkgname/build"

  make DESTDIR="$pkgdir/" install
}

When trying to build package I have the following error:

==> Making package: sigutils-git r204.2555138-1 (Tue 31 Dec 2019 02:31:38 AM MSK)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Cloning sigutils-git git repo...
Cloning into bare repository '/home/viktor/build/aur/sigutils-git/sigutils-git'...
remote: Enumerating objects: 52, done.
remote: Counting objects: 100% (52/52), done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 1376 (delta 19), reused 35 (delta 15), pack-reused 1324
Receiving objects: 100% (1376/1376), 391.18 KiB | 1.24 MiB/s, done.
Resolving deltas: 100% (1001/1001), done.
==> Validating source files with md5sums...
    sigutils-git ... Skipped
==> Extracting sources...
  -> Creating working copy of sigutils-git git repo...
Cloning into 'sigutils-git'...
done.
==> Starting pkgver()...
==> Starting build()...
-- The C compiler identification is GNU 9.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.6.3") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Checking for module 'sndfile>=1.0.2'
--   Found sndfile, version 1.0.28
-- Checking for module 'fftw3f>=3.0'
--   Found fftw3f, version 3.3.8
-- Checking for module 'volk>=1.0'
--   Found volk, version 2.0
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/makepkg/sigutils-git/src/sigutils-git/build
Scanning dependencies of target sigutils
[  2%] Building C object CMakeFiles/sigutils.dir/util/util.c.o
[  4%] Building C object CMakeFiles/sigutils.dir/sigutils/agc.c.o
[  6%] Building C object CMakeFiles/sigutils.dir/sigutils/block.c.o
[  9%] Building C object CMakeFiles/sigutils.dir/sigutils/clock.c.o
[ 11%] Building C object CMakeFiles/sigutils.dir/sigutils/codec.c.o
[ 13%] Building C object CMakeFiles/sigutils.dir/sigutils/coef.c.o
[ 15%] Building C object CMakeFiles/sigutils.dir/sigutils/detect.c.o
[ 18%] Building C object CMakeFiles/sigutils.dir/sigutils/equalizer.c.o
[ 20%] Building C object CMakeFiles/sigutils.dir/sigutils/iir.c.o
[ 22%] Building C object CMakeFiles/sigutils.dir/sigutils/lfsr.c.o
[ 25%] Building C object CMakeFiles/sigutils.dir/sigutils/lib.c.o
[ 27%] Building C object CMakeFiles/sigutils.dir/sigutils/log.c.o
[ 29%] Building C object CMakeFiles/sigutils.dir/sigutils/modem.c.o
[ 31%] Building C object CMakeFiles/sigutils.dir/sigutils/ncqo.c.o
[ 34%] Building C object CMakeFiles/sigutils.dir/sigutils/pll.c.o
[ 36%] Building C object CMakeFiles/sigutils.dir/sigutils/property.c.o
[ 38%] Building C object CMakeFiles/sigutils.dir/sigutils/softtune.c.o
[ 40%] Building C object CMakeFiles/sigutils.dir/sigutils/specttuner.c.o
[ 43%] Building C object CMakeFiles/sigutils.dir/sigutils/taps.c.o
[ 45%] Building C object CMakeFiles/sigutils.dir/sigutils/blocks/agc.c.o
[ 47%] Building C object CMakeFiles/sigutils.dir/sigutils/blocks/clock.c.o
[ 50%] Building C object CMakeFiles/sigutils.dir/sigutils/blocks/pll.c.o
[ 52%] Building C object CMakeFiles/sigutils.dir/sigutils/blocks/tuner.c.o
[ 54%] Building C object CMakeFiles/sigutils.dir/sigutils/blocks/filt.c.o
[ 56%] Building C object CMakeFiles/sigutils.dir/sigutils/blocks/siggen.c.o
[ 59%] Building C object CMakeFiles/sigutils.dir/sigutils/blocks/wavfile.c.o
[ 61%] Building C object CMakeFiles/sigutils.dir/sigutils/codecs/diff.c.o
[ 63%] Building C object CMakeFiles/sigutils.dir/sigutils/modems/qpsk.c.o
[ 65%] Linking C shared library libsigutils.so
[ 65%] Built target sigutils
Scanning dependencies of target sutest
[ 68%] Building C object CMakeFiles/sutest.dir/src/tests/agc.c.o
[ 70%] Building C object CMakeFiles/sutest.dir/src/tests/block.c.o
[ 72%] Building C object CMakeFiles/sutest.dir/src/tests/clock.c.o
[ 75%] Building C object CMakeFiles/sutest.dir/src/tests/costas.c.o
[ 77%] Building C object CMakeFiles/sutest.dir/src/tests/detect.c.o
[ 79%] Building C object CMakeFiles/sutest.dir/src/tests/filt.c.o
[ 81%] Building C object CMakeFiles/sutest.dir/src/main.c.o
[ 84%] Building C object CMakeFiles/sutest.dir/src/tests/ncqo.c.o
[ 86%] Building C object CMakeFiles/sutest.dir/src/tests/codec.c.o
[ 88%] Building C object CMakeFiles/sutest.dir/src/tests/pll.c.o
[ 90%] Building C object CMakeFiles/sutest.dir/src/tests/specttuner.c.o
[ 93%] Building C object CMakeFiles/sutest.dir/testutil/common.c.o
[ 95%] Building C object CMakeFiles/sutest.dir/testutil/poolhelper.c.o
[ 97%] Building C object CMakeFiles/sutest.dir/testutil/sigbufpool.c.o
[100%] Linking C executable sutest
/usr/bin/ld: libsigutils.so: undefined reference to `fftwf_execute'
/usr/bin/ld: libsigutils.so: undefined reference to `fftwf_free'
/usr/bin/ld: libsigutils.so: undefined reference to `fftwf_malloc'
/usr/bin/ld: libsigutils.so: undefined reference to `fftwf_plan_dft_1d'
/usr/bin/ld: libsigutils.so: undefined reference to `fftwf_destroy_plan'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/sutest.dir/build.make:280: sutest] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/sutest.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

So the problem is related to the linking stage. If I set LDFLAGS to empty string before cmake incantation all works fine.

  1. Less daunting bug is with saving temporary building tree path into final library:
$ makepkg
...
==> Checking for packaging issues...
==> WARNING: Package contains reference to $srcdir
usr/lib/libsigutils.so
...
$ strings libsigutils.so | grep makepkg
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/block.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/clock.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/codec.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/detect.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/equalizer.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/lfsr.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/lib.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/modem.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/ncqo.h
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/pll.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/property.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/softtune.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/specttuner.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/blocks/agc.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/blocks/pll.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/blocks/tuner.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/blocks/siggen.c
I1/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/blocks/wavfile.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/codecs/diff.c
/tmp/makepkg/sigutils-git/src/sigutils-git/sigutils/modems/qpsk.c

Can it be fixed?

@BatchDrake
Copy link
Owner

References to the source dir are easy to fix, it's simply that I forgot to add a strip stage after linking. The LDFLAGS issue seems odd though. Could you please attach a copy of the file CMakeFiles/sutest.dir/link.txt inside your build directory?

Thanks,

@BatchDrake
Copy link
Owner

In fact, I thik it's going to be better off if you simply attach all of your CMakeFiles/*/link.txt files here. I think I have an idea of what is going on.

@dvdesolve
Copy link
Author

@BatchDrake
Copy link
Owner

Alright, I think I got it. Try the following and tell me whether it works:

  • Open CMakeLists.txt
  • Locate the following lines at the bottom of the file:
link_directories(sutest ${PROJECT_BINARY_DIR})
target_link_libraries(sutest sigutils)
  • Move them right after the following line:
# Required dependencies
  • Try again.

If this works for you, try the same approach with suscan. If everything works, send me a pull requests of your changes (or simply forward me your modified CMakeLists.txt) and I'll merge / commit to master ASAP.

@dvdesolve
Copy link
Author

Works just fine. Here is the diff:

--- CMakeLists.txt.old	2019-12-31 17:53:40.490947320 +0300
+++ CMakeLists.txt	2019-12-31 17:54:59.359252970 +0300
@@ -202,19 +202,20 @@
 target_include_directories(
   sutest 
   PRIVATE . util ${SRCDIR} ${TESTDIR} ${TESTUTILDIR})
 
 # Required dependencies
+link_directories(sutest ${PROJECT_BINARY_DIR})
+target_link_libraries(sutest sigutils)
+
 target_include_directories(sutest SYSTEM PUBLIC ${SNDFILE_INCLUDE_DIRS})
 target_link_libraries(sutest ${SNDFILE_LIBRARIES})
 
 target_include_directories(sutest SYSTEM PUBLIC ${FFTW3_INCLUDE_DIRS})
 target_link_libraries(sutest ${FFTW3_LIBRARIES})
 
 target_link_libraries(sutest ${CMAKE_THREAD_LIBS_INIT})
-link_directories(sutest ${PROJECT_BINARY_DIR})
-target_link_libraries(sutest sigutils)
 target_link_libraries(sutest m)
 
 # Optional dependencies
 if(VOLK_FOUND)
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_VOLK=1")

@BatchDrake
Copy link
Owner

Done, changes in master now both in sigutils and suscan. I'm delaying the srcdir paths issue until tomorrow (which is when I expect to be in front of a computer).

@BatchDrake
Copy link
Owner

The absolute paths issue should be fixed too now in master, both in sigutils and suscan. Build again and tell me if they are gone. If everything is set, I'll close both issues.

@dvdesolve
Copy link
Author

Works fine for sigutils, however suscan still experiences the same issue

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

No branches or pull requests

2 participants