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

musepack: Fix build for Linux #92041

Closed
wants to merge 2 commits into from
Closed

Conversation

iMichka
Copy link
Member

@iMichka iMichka commented Dec 26, 2021

Fixes:
./libmpcdec/libmpcdec.so: undefined reference to `pow'

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

Fixes:
./libmpcdec/libmpcdec.so: undefined reference to `pow'
@BrewTestBot BrewTestBot added missing license Formula has a missing license which should be added no Linux bottle Formula has no Linux bottle labels Dec 26, 2021
@iMichka iMichka mentioned this pull request Dec 26, 2021
@iMichka
Copy link
Member Author

iMichka commented Dec 26, 2021

  [ 63%] Linking C static library libmpcenc_static.a
  ../libmpcdec/libmpcdec.so: undefined reference to `pow'
  ../libmpcdec/libmpcdec.so: undefined reference to `log10'
  collect2: error: ld returned 1 exit status
  mpcdec/CMakeFiles/mpcdec_cmd.dir/build.make:98: recipe for target 'mpcdec/mpcdec' failed

@carlocab carlocab added the CI-no-bottles Merge without publishing bottles label Dec 26, 2021
@alebcay alebcay added CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. and removed CI-long-timeout [DEPRECATED] Use longer GitHub Actions CI timeout. labels Jan 1, 2022
Comment on lines +34 to +35
# Fix missing linkage to libm on Linux
(buildpath/"libmpcdec/CMakeLists.txt").append_lines "target_link_libraries(mpcdec m)\n" if OS.linux?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has this been reported upstream?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I guess @alebcay just found this out. We need to upstream this.

Copy link
Member

@alebcay alebcay Jan 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Just wanted to make sure this works. Not sure how this has compiled for so long without this (unless they only build/test on platforms where the math routines are contained in libc).

I suspect the fix for upstream will be more than a one-liner though, as it would be better to check if linkage to libm is needed at all (or if libm even exists) rather than blindly adding a link library to the target.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know how to write that patch or should I help investigate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on writing the needed patch(es). They have both Autotools and CMake build systems available, so I'm trying to add the patch for both.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My schedule has been busy so I don't think I will be able to help further with the patch for the time being. But I will provide here what I have so far. Adding this snippet to the end of libmpcdec/CMakeLists.txt should be a more well-rounded patch:

include(CheckCSourceCompiles)
set(LIBM_TEST_SOURCE "#include<math.h>\ndouble x,y;int main(){log10(x);pow(x,y);return 0;}")

check_c_source_compiles("${LIBM_TEST_SOURCE}" HAVE_BUILTIN_MATH)
if(NOT HAVE_BUILTIN_MATH)
  set(CMAKE_REQUIRED_LIBRARIES m)
  check_c_source_compiles("${LIBM_TEST_SOURCE}" HAVE_LIBM_MATH)
  unset(CMAKE_REQUIRED_LIBRARIES)
  if(NOT HAVE_LIBM_MATH)
    message(FATAL_ERROR "Unable to find math library functions")
  endif()
  target_link_libraries(mpcdec m)
endif()

I tried to include as many of the math functions in libmpcdec as I could find in LIBM_TEST_SOURCE. But maybe it's overkill - or maybe there's more that should be added.

The Autotools workflow is trickier to patch because it seems there is math library usage in multiple subprojects, and the Autotools files do not work as-is. AC_SEARCH_LIBS can be used in the configure.in file (which should be named configure.ac by convention) to attain this. Like in the CMake approach, I'm unsure if we should check just one of the math functions used, or all of them.

@iMichka
Copy link
Member Author

iMichka commented Jan 17, 2022

Thinking more about this, I think we might have an issue to upstream our changes anyway.
The last released were 11 years ago and upstream sort of looks unmaintained (but I might be wrong):
https://www.musepack.net/index.php?pg=src

The download count for Musepack is high, but mostly due to gst-plugins-bad having it as a dependency. I am unsure how important this package is. Do we have any audio experts here?

@carlocab carlocab mentioned this pull request Jan 27, 2022
6 tasks
@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Feb 8, 2022
@github-actions github-actions bot closed this Feb 15, 2022
@github-actions github-actions bot added the outdated PR was locked due to age label Mar 18, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI-no-bottles Merge without publishing bottles missing license Formula has a missing license which should be added no Linux bottle Formula has no Linux bottle outdated PR was locked due to age stale No recent activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants