Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 740310

Summary: media-libs/libsoundtouch[openmp] built with clang causes issues with other apps like audacity: error: /usr/lib64/libSoundTouch.so: undefined reference to __kmpc_for_static_fini
Product: Gentoo Linux Reporter: Agostino Sarubbo <ago>
Component: Current packagesAssignee: Gentoo Sound Team <sound>
Status: CONFIRMED ---    
Severity: normal CC: fordfrog, richard, sam, telans
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=740396
https://bugs.gentoo.org/show_bug.cgi?id=349078
https://bugs.gentoo.org/show_bug.cgi?id=915833
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 881275    
Bug Blocks: 731004    
Attachments: build.log.xz
1-CMakeError.log
1-CMakeOutput.log

Description Agostino Sarubbo gentoo-dev 2020-09-04 07:45:36 UTC
https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/

Issue: media-sound/audacity-2.4.2-r1 fails to compile.
Discovered on: amd64 (internal ref: tinderbox)

NOTE:
This machine uses a clang/LLVM toolchain.
If you think that this issue is strictly related to clang/LLVM please block bug 408963. If you think that this issue is strictly related to the LLD linker, please block bug 731004.
This machine uses also GLIBC-2.32. If you think that this issue is strictly related to GLIBC please block bug 736174.
Comment 1 Agostino Sarubbo gentoo-dev 2020-09-04 07:45:39 UTC
Created attachment 658288 [details]
build.log.xz

build log and emerge --info (compressed because it exceeds attachment limit, use 'xzless' to read it)
Comment 2 Agostino Sarubbo gentoo-dev 2020-09-04 07:45:40 UTC
Created attachment 658290 [details]
1-CMakeError.log

1-CMakeError.log
Comment 3 Agostino Sarubbo gentoo-dev 2020-09-04 07:45:41 UTC
Created attachment 658292 [details]
1-CMakeOutput.log

1-CMakeOutput.log
Comment 4 Miroslav Šulc gentoo-dev 2020-09-04 10:13:41 UTC
this is the error (shortened command):

[31mFAILED: [0mbin/Gentoo/audacity 
: && /usr/lib/llvm/10/bin/x86_64-pc-linux-gnu-clang++ -O2 -pipe -march=native -frecord-gcc-switches -fno-diagnostics-color -std=gnu++14 -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -fuse-ld=lld   -Wl,--export-dynamic  -rdynamic ... -o bin/Gentoo/audacity  -lm  -latomic  -ldl  lib64/audacity/libportaudio-v19.a  lib64/audacity/liblibnyquist.a  lib64/audacity/libportmixer.a  -lz  -lpthread  -L/usr/lib64  -pthread  /usr/lib64/libwx_gtk3u_adv-3.0-gtk3.so  /usr/lib64/libwx_baseu-3.0-gtk3.so  /usr/lib64/libwx_gtk3u_core-3.0-gtk3.so  /usr/lib64/libwx_gtk3u_html-3.0-gtk3.so  /usr/lib64/libwx_baseu_net-3.0-gtk3.so  /usr/lib64/libwx_gtk3u_qa-3.0-gtk3.so  -lz  /usr/lib64/libexpat.so  /usr/lib64/libmp3lame.so  /usr/lib64/libsoxr.so  /usr/lib64/libFLAC++.so  /usr/lib64/libFLAC.so  /usr/lib64/libvorbis.so  /usr/lib64/libvorbisenc.so  /usr/lib64/libvorbisfile.so  /usr/lib64/liblilv-0.so  /usr/lib64/libdl.so  /usr/lib64/libsratom-0.so  /usr/lib64/libsord-0.so  /usr/lib64/libserd-0.so  /usr/lib64/libsuil-0.so  /usr/lib64/libsndfile.so  lib64/audacity/libportaudio-v19.a  /usr/lib64/libSoundTouch.so  /usr/lib64/libgtk-3.so  /usr/lib64/libgdk-3.so  /usr/lib64/libpangocairo-1.0.so  /usr/lib64/libpango-1.0.so  /usr/lib64/libatk-1.0.so  /usr/lib64/libcairo-gobject.so  /usr/lib64/libcairo.so  /usr/lib64/libgdk_pixbuf-2.0.so  /usr/lib64/libgio-2.0.so  /usr/lib64/libgobject-2.0.so  /usr/lib64/libglib-2.0.so && :
ld.lld: error: /usr/lib64/libSoundTouch.so: undefined reference to __kmpc_for_static_fini
ld.lld: error: /usr/lib64/libSoundTouch.so: undefined reference to __kmpc_for_static_init_4
ld.lld: error: /usr/lib64/libSoundTouch.so: undefined reference to __kmpc_for_static_init_4u
ld.lld: error: /usr/lib64/libSoundTouch.so: undefined reference to __kmpc_fork_call
ld.lld: error: /usr/lib64/libSoundTouch.so: undefined reference to __kmpc_critical
ld.lld: error: /usr/lib64/libSoundTouch.so: undefined reference to __kmpc_end_critical
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.


but i can't reproduce it with the following command (am i missing something?):

CC=x86_64-pc-linux-gnu-clang CXX=x86_64-pc-linux-gnu-clang++ LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -fuse-ld=lld" emerge -va1 audacity
Comment 5 Andy Figueroa 2020-09-06 17:25:56 UTC
Stable x86, up-to-date, compiling fails at the same spot last three days. Currently running version 2.2.2.

ninja: build stopped: subcommand failed.
* ERROR: media-sound/audacity-2.4.2-r1::gentoo failed (compile phase):
* ninja -v -j4 -l0 failed 

I wrote about it with emerge --info on the forums here:
https://forums.gentoo.org/viewtopic.php?p=8497778

Also put the full build log as a .txt file here:
https://2chronicles36.org/media-sound-audacity-2.4.2-r1-20200906-135527.txt
Comment 6 Miroslav Šulc gentoo-dev 2020-09-07 08:12:11 UTC
(In reply to Andy Figueroa from comment #5)
> Stable x86, up-to-date, compiling fails at the same spot last three days.
> Currently running version 2.2.2.
> 
> ninja: build stopped: subcommand failed.
> * ERROR: media-sound/audacity-2.4.2-r1::gentoo failed (compile phase):
> * ninja -v -j4 -l0 failed 
> 
> I wrote about it with emerge --info on the forums here:
> https://forums.gentoo.org/viewtopic.php?p=8497778
> 
> Also put the full build log as a .txt file here:
> https://2chronicles36.org/media-sound-audacity-2.4.2-r1-20200906-135527.txt

could you please upload the log here? i get something weird from the provided link.
Comment 7 Miroslav Šulc gentoo-dev 2020-09-07 08:17:43 UTC
according to what i found, it seems to need -openmp option for the linking.
Comment 8 Miroslav Šulc gentoo-dev 2020-09-07 08:20:15 UTC
is your media-libs/libsoundtouch built with openmp use flag?
Comment 9 Andreas Sturmlechner gentoo-dev 2020-09-07 09:17:08 UTC
(In reply to Andy Figueroa from comment #5)
> Also put the full build log as a .txt file here:
> https://2chronicles36.org/media-sound-audacity-2.4.2-r1-20200906-135527.txt

This the wrong bug for you. Please *attach* your logs, not link, to the correct one.

Of course this would be greatly improved with a meaningful $summary.
Comment 10 GoGoOtaku 2021-05-20 00:04:42 UTC
This is actually not an issue with Audacity but an issue with libSoundTouch or rather with Clang and it's OpenMP implementation.

If you compile libsoundtouch with clang and the LD flag -Wl,-z,defs [1] the compilation will fail. This is because -fopenmp defaults to libGomp which is the GCC implementation. In order to build OpenMP support with clang you need to build with "-fopenmp=libomp"[2]. Obviously you need to have libomp[3] installed for this.

So easy, right? Just add "LDFLAGS=${LDFLAGS} -fopenmp=libomp" to an env file.
Sadly no. OpenMP is too deep inside the make process and libtool is going to cut the "=libomp".

I don't have any good and more importantly clean solution at this point besides recommending to compile OpenMP projects with GCC and Gold.
Then again I am also not that familiar with autotools and maybe there is an easy way to do this.

[1] https://wiki.gentoo.org/wiki/Project:Quality_Assurance/-Wl,-z,defs_and_-Wl,--no-allow-shlib-undefined
[2] https://stackoverflow.com/a/33400688
[3] https://packages.gentoo.org/packages/sys-libs/libomp
Comment 11 James Beddek 2021-06-07 08:01:37 UTC
(In reply to GoGoOtaku from comment #10)
> This is actually not an issue with Audacity but an issue with libSoundTouch
> or rather with Clang and it's OpenMP implementation.
> 
> If you compile libsoundtouch with clang and the LD flag -Wl,-z,defs [1] the
> compilation will fail. This is because -fopenmp defaults to libGomp which is
> the GCC implementation. In order to build OpenMP support with clang you need
> to build with "-fopenmp=libomp"[2]. Obviously you need to have libomp[3]
> installed for this.

Unless I'm missing something the default OpenMP implementation for Clang is libomp and has been for a few years now
https://github.com/llvm/llvm-project/blob/llvmorg-12.0.0/clang/CMakeLists.txt#L282

Although yes, it seems anything OpenMP only successfully builds with GCC on either of my two systems.
Comment 12 Alec Ari 2022-09-12 05:16:08 UTC
Sorry, forgot to share this with you guys!

https://github.com/NTULINUX/gentoo_backup/blob/master/etc/portage/package.env

# media-sound/audacity: libSoundTouch.so: undefined reference to __kmpc_*
media-libs/libsoundtouch openmp.conf

https://github.com/NTULINUX/gentoo_backup/blob/master/etc/portage/env/openmp.conf

Cheers!
Comment 13 Alec Ari 2022-12-16 07:55:44 UTC
In case you guys missed it:

/etc/portage/package.env:

media-libs/libsoundtouch openmp.conf

/etc/portage/env/openmp.conf:

CXXFLAGS="-O2 -march=x86-64-v2 -fopenmp=libomp -fPIC -fstack-protector-strong -fstack-clash-protection -fomit-frame-pointer -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"

You only really need CXXFLAGS="-O2 -fopenmp=libomp"
Comment 14 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-24 07:44:55 UTC
*** Bug 884781 has been marked as a duplicate of this bug. ***
Comment 15 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-24 07:45:03 UTC
*** Bug 740396 has been marked as a duplicate of this bug. ***
Comment 16 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-24 07:45:09 UTC
*** Bug 885541 has been marked as a duplicate of this bug. ***
Comment 17 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-24 07:45:14 UTC
*** Bug 831175 has been marked as a duplicate of this bug. ***
Comment 18 Larry the Git Cow gentoo-dev 2024-03-24 07:46:04 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f4f260fbb7738de5bce902cd54f86cd3a8395561

commit f4f260fbb7738de5bce902cd54f86cd3a8395561
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-03-24 07:45:41 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-03-24 07:45:41 +0000

    media-libs/libsoundtouch: respect LDFLAGS
    
    Closes: https://bugs.gentoo.org/740310
    Closes: https://bugs.gentoo.org/881275
    Signed-off-by: Sam James <sam@gentoo.org>

 .../files/libsoundtouch-2.3.2-flags.patch          | 18 +++++++
 .../libsoundtouch/libsoundtouch-2.3.2-r1.ebuild    | 63 ++++++++++++++++++++++
 2 files changed, 81 insertions(+)
Comment 19 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-24 08:07:11 UTC
*** Bug 925758 has been marked as a duplicate of this bug. ***
Comment 20 Larry the Git Cow gentoo-dev 2024-03-24 08:34:26 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/elt-patches.git/commit/?id=d3c77e47d0c2ae8806b340aabb53947012c239f5

commit d3c77e47d0c2ae8806b340aabb53947012c239f5
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-03-24 08:29:20 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-03-24 08:34:20 +0000

    patches/openmp: new patch to allow -fopenmp=*
    
    Bug: https://bugs.gentoo.org/740310
    Signed-off-by: Sam James <sam@gentoo.org>

 eltpatch.in          |  2 +-
 patches/openmp/2.4.6 | 36 ++++++++++++++++++++++++++++++++++++
 patches/openmp/2.4.7 | 36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 1 deletion(-)
Comment 21 Larry the Git Cow gentoo-dev 2024-03-24 08:36:25 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0dc7b3c1b26e36133f67b6df8375e375bfde7902

commit 0dc7b3c1b26e36133f67b6df8375e375bfde7902
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-03-24 08:36:00 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-03-24 08:36:17 +0000

    app-portage/elt-patches: add 20240324
    
    Sam James (1):
          patches/openmp: new patch to allow -fopenmp=*
    
    Bug: https://bugs.gentoo.org/740310
    Signed-off-by: Sam James <sam@gentoo.org>

 app-portage/elt-patches/Manifest                   |  1 +
 .../elt-patches/elt-patches-20240324.ebuild        | 39 ++++++++++++++++++++++
 2 files changed, 40 insertions(+)
Comment 22 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-24 08:38:56 UTC
To summarise, there were two problems here:
1) libtool filtering -fopenmp=*. If you wanted to use libomp with Clang before it defaulted to it, it would be a pain to specify which impl you wanted. (Still is a problem, but it matters less now because of the default change).

2) libsoundtouch was clobbering LDFLAGS anyway.

I've fixed 2) in Gentoo, and I've sent a patch for 1) upstream and fixed it in elt-patches.
Comment 23 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-24 08:53:48 UTC
Reopening for now. I don't see libomp linked with unlike with GCC. Same in bug 740310. Not sure what's going on yet.