Missing version number in sox --version output with MacOS X clang #159
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Missing version number in sox --version output with MacOS X clang
Links
sox.sf.netpatch 104: missing version number in sox --version outputDescription
Using SoX 14.4.2 on OS X 10.9.5, the output from sox --version is missing the version number:
This is using OS X 10.9.5, Xcode 6.1.1, and Apple's compiler:
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
The same result occurs using clang 3.6.
Configuring with CFLAGS=-g instead of the default -O2, it works as expected.
Looking at the assembly output, it appears that as part of its optimization the compiler replaced the call to sox_version() with a simple load of the address of the static versionstr buffer that would be returned by sox_version(). Because sox_version() does not end up being called, the versionstr buffer contains an empty string.
It appears that this occurs because the function sox_version() was declared in src/sox.h as LSX_RETURN_PURE (i.e. attribute ((pure))). However the function actually does have an important side effect, which is to fill in the versionstr buffer. The functions sox_version_info() and lsx_enum_option() also appear to have potential side effects despite being marked LSX_RETURN_PURE. Removing LSX_RETURN_PURE from these functions resolves the issue.
Repeat by
Build on MacOS X with clang then
Results
Tested on cfarm104 with clang 14.0.0
Analysis
This was a problem with
clang-3.6, which we cannot test to confirm the problem.We could apply it anyway, as it's probably harmless, however
sox_ng.hnow contains:so
LSX_RETURN_PUREis removed on non-gcc compilers, achieving what the patch wants.Conclusion
Not necessary any more.