-
-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Conversation
Fixes: ./libmpcdec/libmpcdec.so: undefined reference to `pow'
|
# Fix missing linkage to libm on Linux | ||
(buildpath/"libmpcdec/CMakeLists.txt").append_lines "target_link_libraries(mpcdec m)\n" if OS.linux? |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Thinking more about this, I think we might have an issue to upstream our changes anyway. The download count for |
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. |
Fixes:
./libmpcdec/libmpcdec.so: undefined reference to `pow'
brew install --build-from-source <formula>
, where<formula>
is the name of the formula you're submitting?brew test <formula>
, where<formula>
is the name of the formula you're submitting?brew audit --strict <formula>
(after doingbrew install --build-from-source <formula>
)? If this is a new formula, does it passbrew audit --new <formula>
?