Re: [sqlite] OS X/Xcode build error: use of unknown builtin

2017-02-15 Thread Anthony Chan (antchan2)
Thank you for all the responses and a speedy resolution.  For complete-ness: I 
am using the older Xcode 6.4 – “Apple LLVM version 6.1.0 (clang-602.0.53) 
(based on LLVM 3.6.0svn)”.  

Now that the problem has been fixed in 3.17 branch I will use that.


On 2017-02-15, 8:20 AM, "drhsql...@gmail.com on behalf of Richard Hipp" 
<drhsql...@gmail.com on behalf of d...@sqlite.org> wrote:

On 2/14/17, Anthony Chan (antchan2) <antch...@cisco.com> wrote:
>
> I tried building SQLite 3.17.0 with OSX/Xcode and got the following 
errors:
>

Several possible fixes, any one of which will work:

(1) Update your Xcode to the latest from Apple

(2) Compile using the -DSQLITE_DISABLE_INTRINSIC compile-time option

(3) Use the latest SQLite code from trunk
(https://www.sqlite.org/src/info/trunk) or from branch-3.17
(https://www.sqlite.org/src/info/branch-3.17).  Click on one of the
"Tarball" or "ZIP Archive" links to download the complete source code.

(4) Apply the patch shown at
https://www.sqlite.org/src/vpatch?from=ada05cfa86ad7f56=8d3f485d86b2f2d8

-- 
D. Richard Hipp
d...@sqlite.org


___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] OS X/Xcode build error: use of unknown builtin

2017-02-14 Thread Anthony Chan (antchan2)
Hello,

I tried building SQLite 3.17.0 with OSX/Xcode and got the following errors:

-
sqlite3.c:28836:10: error: use of unknown builtin '__builtin_add_overflow' 
[-Wimplicit-function-declaration]
  return __builtin_add_overflow(*pA, iB, pA);
 ^
sqlite3.c:28856:10: error: use of unknown builtin '__builtin_sub_overflow' 
[-Wimplicit-function-declaration]
  return __builtin_sub_overflow(*pA, iB, pA);
 ^
sqlite3.c:28856:10: note: did you mean '__builtin_add_overflow'?
sqlite3.c:28836:10: note: '__builtin_add_overflow' declared here
  return __builtin_add_overflow(*pA, iB, pA);
 ^
sqlite3.c:28871:10: error: use of unknown builtin '__builtin_mul_overflow' 
[-Wimplicit-function-declaration]
  return __builtin_mul_overflow(*pA, iB, pA);
 ^
sqlite3.c:28871:10: note: did you mean '__builtin_sub_overflow'?
sqlite3.c:28856:10: note: '__builtin_sub_overflow' declared here
  return __builtin_sub_overflow(*pA, iB, pA);
 ^
3 errors generated.
-

I believe this is related to the recent change “Cleanup the usage of the 
SQLITE_DISABLE_INTRINSIC compile-time option…” 
(http://www.sqlite.org/src/info/798fb9d70d2e5f95) and the use of CLANG_VERSION 
to decide whether to use builtin functions:

#if defined(__clang__) && !defined(_WIN32) && !defined(SQLITE_DISABLE_INTRINSIC)
# define CLANG_VERSION \
(__clang_major__*100+__clang_minor__*1000+__clang_patchlevel__)
#else
# define CLANG_VERSION 0
#endif

…

#elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=300)
  u32 x;
  memcpy(,p,4);
  return __builtin_bswap32(x);

According to Clang documentation 
(http://clang.llvm.org/docs/LanguageExtensions.html): “marketing version 
numbers should not be used to check for language features, as different vendors 
use different numbering schemes. Instead, use the Feature Checking Macros.”

With this in mind, I suggest creating a new macro that uses feature checking 
macros.  For example:

#if defined(__clang__) && !defined(_WIN32) && !defined(SQLITE_DISABLE_INTRINSIC)
# if __has_builtin(__builtin_add_overflow) && \
 __has_builtin(__builtin_sub_overflow) && \
 __has_builtin(__builtin_mul_overflow) && \
 __has_builtin(__builtin_bswap32) && \
 __has_builtin(__builtin_bswap64)
#  define CLANG_USE_INTRINSIC 1
# else 
#  define CLANG_USE_INTRINSIC 0
# endif
#else
# define CLANG_USE_INTRINSIC 0
#endif

The tests would look like this:

#elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_USE_INTRINSIC!=0)
  u32 x;
  memcpy(,p,4);
  return __builtin_bswap32(x);

Your comments are welcome.

Thanks,

Anthony
antch...@cisco.com



___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users