Re: [sqlite] 3.7.10 build failure on OS X 10.4: ld: Undefined symbols: _OSAtomicCompareAndSwapPtrBarrier
On Jan 21, 2012, at 06:21, Richard Hipp wrote: > On Sat, Jan 21, 2012 at 3:29 AM, Ryan Schmidt wrote: > >> Hello, I'm writing on behalf of the MacPorts package management system. >> Our users are having trouble compiling sqlite 3.7.10 on OS X 10.4, both on >> PowerPC and on Intel. 3.7.9 compiled fine. The error is: >> >> ld: Undefined symbols: >> _OSAtomicCompareAndSwapPtrBarrier >> >> The complete log is attached to our bug report: >> >> https://trac.macports.org/ticket/32930 >> >> Thanks for any help you can provide. >> > > I think that if you add this patch: > >http://www.sqlite.org/src/info/238e35a441 > > and if you compile with -DSQLITE_WITHOUT_ZONEMALLOC that it might work. > Please give it a try and let me know one way or another. Thank you, that worked for me. https://trac.macports.org/changeset/89249 ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] 3.7.10 build failure on OS X 10.4: ld: Undefined symbols:_OSAtomicCompareAndSwapPtrBarrier
Joe Mistachkin wrote: bool success; malloc_zone_t* newzone = malloc_create_zone(4096, 0); malloc_set_zone_name(newzone, "Sqlite_Heap"); do{ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone, (void * volatile *)&_sqliteZone_); +#else + success = OSAtomicCompareAndSwapPtr(NULL, newzone, + (void * volatile *)&_sqliteZone_); + OSMemoryBarrier(); +#endif }while(!_sqliteZone_); if( !success ){ /* somebody registered a zone first */ malloc_destroy_zone(newzone); } With this algorithm, where there are not multiple memory objects having some defined, coordinated meaning with respect to each other, the barrier not necessary. So this code could be simplified to simply use the non-barrier pointer swap, always. Cheers, -- Larry Brasfield ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] 3.7.10 build failure on OS X 10.4: ld: Undefined symbols: _OSAtomicCompareAndSwapPtrBarrier
On Sat, Jan 21, 2012 at 3:29 AM, Ryan Schmidtwrote: > Hello, I'm writing on behalf of the MacPorts package management system. > Our users are having trouble compiling sqlite 3.7.10 on OS X 10.4, both on > PowerPC and on Intel. 3.7.9 compiled fine. The error is: > > ld: Undefined symbols: > _OSAtomicCompareAndSwapPtrBarrier > > The complete log is attached to our bug report: > > https://trac.macports.org/ticket/32930 > > Thanks for any help you can provide. > I think that if you add this patch: http://www.sqlite.org/src/info/238e35a441 and if you compile with -DSQLITE_WITHOUT_ZONEMALLOC that it might work. Please give it a try and let me know one way or another. -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] 3.7.10 build failure on OS X 10.4: ld: Undefined symbols:_OSAtomicCompareAndSwapPtrBarrier
DISCLAIMER: I am *NOT* an expert on Mac OS X programming. That being said, I think the following patch might work (this is UNTESTED, as I have no readily available Apple hardware): Index: src/mem1.c == --- src/mem1.c +++ src/mem1.c @@ -72,10 +72,11 @@ ** SQLITE_WITHOUT_ZONEMALLOC symbol is defined. */ #include #include #include +#include static malloc_zone_t* _sqliteZone_; #define SQLITE_MALLOC(x) malloc_zone_malloc(_sqliteZone_, (x)) #define SQLITE_FREE(x) malloc_zone_free(_sqliteZone_, (x)); #define SQLITE_REALLOC(x,y) malloc_zone_realloc(_sqliteZone_, (x), (y)) #define SQLITE_MALLOCSIZE(x) \ @@ -236,12 +237,18 @@ ** e.g. we have our own dedicated locks */ bool success; malloc_zone_t* newzone = malloc_create_zone(4096, 0); malloc_set_zone_name(newzone, "Sqlite_Heap"); do{ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone, (void * volatile *)&_sqliteZone_); +#else + success = OSAtomicCompareAndSwapPtr(NULL, newzone, + (void * volatile *)&_sqliteZone_); + OSMemoryBarrier(); +#endif }while(!_sqliteZone_); if( !success ){ /* somebody registered a zone first */ malloc_destroy_zone(newzone); } -- Joe Mistachkin ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] 3.7.10 build failure on OS X 10.4: ld: Undefined symbols: _OSAtomicCompareAndSwapPtrBarrier
Ryan Schmidt sqlite-2012a at ryandesign.com wrote: Hello, I'm writing on behalf of the MacPorts package management system. Our users are having trouble compiling sqlite 3.7.10 on OS X 10.4, both on PowerPC and on Intel. 3.7.9 compiled fine. The error is: ld: Undefined symbols: _OSAtomicCompareAndSwapPtrBarrier The complete log is attached to our bug report: https://trac.macports.org/ticket/32930 Thanks for any help you can provide. Here are a few observations and deductions that may help you narrow your search. OSAtomicCompareAndSwapPtrBarrier(...) is implemented in the so-called 'Standard C Library' on BSD, hence on modern Apple platforms. It is not declared or #defined anywhere in the published SQlite3 source, only used, under an #ifdef __APPLE__ protected section of code. This section did not appear in a form calling OSAtomicCompareAndSwapPtrBarrier in SQlite3 v3.7.9, but v3.7.10 has such a call. (You surely surmised this; I just mention it to support some reasoning below.) It appears to be declared once libkern/OSAtomic.h has been #included. Older versions of OSAtomic have varying names for very similar functions, such as OSCompareAndSwapPtr(...) with the same signature. Here is something that I proffer more tentatively: The actual declaration appears in a file listed at http://www.opensource.apple.com/source/CF/CF-635/CoreFoundation_Prefix.h which has a very strange feature. Instead of the usual bracketing reading #ifdef __cplusplus extern "C" { #endif the conditional reads #if DEPLOYMENT_TARGET_WINDOWS && defined(__cplusplus) . This suggests to me that the definition itself, (the one whose address must be found by ld to resolve references), may have a name that is decorated per one of the various C++ schemes, when built for a platform for which DEPLOYMENT_TARGET_WINDOWS does not get #define'd. This would cause the link failure you see. The SQLite code, compiled as C, references the barely decorated name, (with just the leading '_'), producing the reference that is not resolved, whereas the library, if compiled as C++, may have exposed its definition with the more ornate name decoration which encodes the signature. You could do a little work with nm and grep, looking for where 'OSAtomicCompareAndSwapPtrBarrier' is exposed, either as a definition or a reference. As soon as you find such, you will see whether it is C++-decorated or not. Of course, the problem may be as simple as not having enough libraries in your link step. That same "nm | grep" effort will tell you what additional library is needed, (if that will solve the problem). Given the evolving nature of the synchronization primitives on the platform, you may be suffering from linking against too-dated libraries. The "nm $obj | grep OSAtomicCompareAndSwapPtrBarrier" effort should also uncover that. (If you find the library with the non-Barrier forms of those primitives, or the older OSCompareAndSwapPtr, but missing OSAtomicCompareAndSwapPtrBarrier, that would be a strong clue that the missing entry point is truly missing among the set of libraries you had hoped to use.) Good luck, -- Larry Brasfield ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] 3.7.10 build failure on OS X 10.4: ld: Undefined symbols: _OSAtomicCompareAndSwapPtrBarrier
Hello, I'm writing on behalf of the MacPorts package management system. Our users are having trouble compiling sqlite 3.7.10 on OS X 10.4, both on PowerPC and on Intel. 3.7.9 compiled fine. The error is: ld: Undefined symbols: _OSAtomicCompareAndSwapPtrBarrier The complete log is attached to our bug report: https://trac.macports.org/ticket/32930 Thanks for any help you can provide. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users