Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is libsasl2 broken on OSX Yosemite? Missing sasl_client_done

I've been having some trouble with the installed version of libsasl2 (Cyrus SASL).

In particular, it seems that the local headers and sasl_version report version 2.1.26, but no symbol is provided for the global function sasl_client_done.

I'm pretty sure I'm supposed to have that symbol because:

  • It's there in the provided sasl/sasl.h header
  • The cyrsus sasl NEWS file lists "Implemented sasl_client_done()/sasl_server_done()" as a 2.1.24 feature
  • It's there everywhere that provides 2.1.26 outside of Yosemite

For a reproduction:

  • note that the sample below prints
    • "impl: 'Cyrus SASL', version: 33619994, major: 2, minor: 1, step: 26"
  • the sample compiles and executes on a linux install with the same library version after uncommenting the code

the uncommented code produces a link error on yosemite

Undefined symbols for architecture x86_64:
  "_sasl_client_done", referenced from:
      _main in foo-072675.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

invoking the compiler with:

clang -Wall -Werror -lsasl2 -o foo foo.c -v

with clang -v of:

Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.10.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name foo.c -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 241.9 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -Wall -Werror -fdebug-compilation-dir /Users/jcarey/work -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fdiagnostics-show-option -vectorize-slp -o /var/folders/wq/jypwqgv976n0db5l5qxw900r0000gq/T/foo-92054e.o -x c foo.c
clang -cc1 version 6.0 based upon LLVM 3.5svn default target x86_64-apple-darwin14.0.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks (framework directory)
End of search list.
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -o foo -lsasl2 /var/folders/wq/jypwqgv976n0db5l5qxw900r0000gq/T/foo-92054e.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "_sasl_client_done", referenced from:
      _main in foo-92054e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

And the code in question:

#include <sasl/sasl.h>
#include <stdio.h>
#include <stdint.h>

int main(int argc, char ** argv) {
    const char *impl;
    int version;
    uint32_t buf;
    uint16_t major;
    uint8_t minor;
    uint8_t step;

    sasl_version(&impl, &version);

    buf = version;

    major = buf >> 24;
    minor = (buf << 8) >> 24;
    step = (buf << 24) >> 24;

    printf("impl: '%s', version: %d, major: %d, minor: %d, step: %d\n", impl, version, major, minor, step);

    /*
    {
        int (* scd)(void);

        scd = &sasl_client_done;

        printf("sasl_client_done: %p\n", scd);
    }
    */

    return 0;
}

I'm thinking that something's screwy with the way cyrus sasl got packaged for Yosemite (using a symbol list from Mavericks perhaps?).

like image 328
hanumantmk Avatar asked Oct 31 '22 14:10

hanumantmk


1 Answers

As a matter of interest, I just checked with 10.10.4 and I see the symbol is now there:

$ nm /usr/lib/libsasl2.dylib |grep sasl_client_done
000000000000724a T _sasl_client_done

The sample code now works fine (with the commented section now uncommented). The same Cyrus SASL version is still returned though:

impl: 'Cyrus SASL', version: 33619994, major: 2, minor: 1, step: 26
sasl_client_done: 0x7fff8e3dc24a
like image 90
mjturner Avatar answered Nov 15 '22 07:11

mjturner