OS X/Xcode build error: use of unknown builtin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

OS X/Xcode build error: use of unknown builtin

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__*1000000+__clang_minor__*1000+__clang_patchlevel__)
#else
# define CLANG_VERSION 0
#endif



#elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000)
  u32 x;
  memcpy(&x,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(&x,p,4);
  return __builtin_bswap32(x);

Your comments are welcome.

Thanks,

Anthony
[hidden email]



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

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

Richard Hipp-3
On 2/14/17, Anthony Chan (antchan2) <[hidden email]> wrote:
> Hello,
>
> I tried building SQLite 3.17.0 with OSX/Xcode and got the following errors:
>

We do test extensively on OSX and didn't have any problems.  What
version of Xcode do you have?
--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

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

Domingo Alvarez Duarte
In reply to this post by Anthony Chan (antchan2)
Hello Anthony !

I also got those errors and did a dirty change to sqlite3 to compile,
your proposal makes an all or nothing use of builtins, probably a one by
one check/enable could give better result.

Cheers !


On 14/02/17 21:38, Anthony Chan (antchan2) wrote:

> 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__*1000000+__clang_minor__*1000+__clang_patchlevel__)
> #else
> # define CLANG_VERSION 0
> #endif
>
> …
>
> #elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000)
>    u32 x;
>    memcpy(&x,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(&x,p,4);
>    return __builtin_bswap32(x);
>
> Your comments are welcome.
>
> Thanks,
>
> Anthony
> [hidden email]
>
>
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

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

Richard Hipp-3
What does "clang -v" show on your machine?

On 2/15/17, Domingo Alvarez Duarte <[hidden email]> wrote:

> Hello Anthony !
>
> I also got those errors and did a dirty change to sqlite3 to compile,
> your proposal makes an all or nothing use of builtins, probably a one by
> one check/enable could give better result.
>
> Cheers !
>
>
> On 14/02/17 21:38, Anthony Chan (antchan2) wrote:
>> 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__*1000000+__clang_minor__*1000+__clang_patchlevel__)
>> #else
>> # define CLANG_VERSION 0
>> #endif
>>
>> …
>>
>> #elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 ||
>> CLANG_VERSION>=3000000)
>>    u32 x;
>>    memcpy(&x,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(&x,p,4);
>>    return __builtin_bswap32(x);
>>
>> Your comments are welcome.
>>
>> Thanks,
>>
>> Anthony
>> [hidden email]
>>
>>
>>
>> _______________________________________________
>> sqlite-users mailing list
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

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

Richard Hipp-3
In reply to this post by Anthony Chan (antchan2)
On 2/14/17, Anthony Chan (antchan2) <[hidden email]> 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&to=8d3f485d86b2f2d8

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

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

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, "[hidden email] on behalf of Richard Hipp" <[hidden email] on behalf of [hidden email]> wrote:

    On 2/14/17, Anthony Chan (antchan2) <[hidden email]> 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&to=8d3f485d86b2f2d8
   
    --
    D. Richard Hipp
    [hidden email]
   

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users