Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__udivti3 undefined when compiling with Apple LLVM v 5.0 #67

Closed
RafaelBaptista opened this issue Mar 6, 2014 · 6 comments
Closed

__udivti3 undefined when compiling with Apple LLVM v 5.0 #67

RafaelBaptista opened this issue Mar 6, 2014 · 6 comments

Comments

@RafaelBaptista
Copy link

Recently upgraded to OsX mavericks, which comes with a new compiler, that identifies itself as:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.1.0

Building PolarSSL v.2.3.3:

Undefined symbols for architecture x86_64:
"___udivti3", referenced from:
_mpi_div_mpi in libpolarssl.a(bignum.o)

The error is in bignum.c at line 1239:

        t_udbl r;

        r  = (t_udbl) X.p[i] << biL;
        r |= (t_udbl) X.p[i - 1];
        r /= Y.p[t];                                                    <---- this line
        if( r > ((t_udbl) 1 << biL) - 1)
            r = ((t_udbl) 1 << biL) - 1;

        Z.p[i - t - 1] = (t_uint) r;

Looks like clang can't find its own definition of a built-in 128 bit division. I have a workaround for now: undefine POLARSSL_HAVE_UDBL in bignum.h

@mpg
Copy link
Contributor

mpg commented Mar 11, 2014

I'm sorry, but Isn't that a bug of the compiler? I mean, it's generating a symbol it can't resolve, and all x84_64 CPUs have 128-bits integer division, so there is not reason for the compiler not to support it. Besides, it works great with other versions of Clang on Linux (3.4 on my development machine, and 3.0 I believe on our buildbot x86_64 machine).

Did you try to bug Clang/Apple about it and/or ask on a Clang mailing list? What do they think about that?

@RafaelBaptista
Copy link
Author

I agree - this is more of a compiler bug, and a bug in polarssl proper. And
I think this issue may already be fixed in the clang mainline.

But Apple has bundled a particular version of the compiler with the latest
OsX. So as of right now the PolarSSL code will not build on a standard
install of Mavericks with the latest Xcode. I don't know when Apple will
update the compiler in Xcode - but they don't do it very often.

To support standard OsX mavericks builds you may need to put in a work
around this compiler bug.

On Tue, Mar 11, 2014 at 4:53 AM, Manuel Pégourié-Gonnard <
notifications@github.com> wrote:

I'm sorry, but Isn't that a bug of the compiler? I mean, it's generating a
symbol it can't resolve, and all x84_64 CPUs have 128-bits integer
division, so there is not reason for the compiler not to support it.
Besides, it works great with other versions of Clang on Linux (3.4 on my
development machine, and 3.0 I believe on our buildbot x86_64 machine).

Did you try to bug Clang/Apple about it and/or ask on a Clang mailing
list? What do they think about that?

Reply to this email directly or view it on GitHubhttps://github.com//issues/67#issuecomment-37274251
.

@mpg
Copy link
Contributor

mpg commented Mar 12, 2014

I'm afraid you're right. Thanks for the info that Apple doesn't update often.

I'd like to activate the workaround only with this specific version of the compiler. Would you mind showing me the output of clang -E -dM -x c /dev/null on the affected machine, so that I can know which exact values of the macros to check for? That would be very appreciated.

@mpg
Copy link
Contributor

mpg commented Mar 14, 2014

Ok, so I just disabled 128-bit division on the following condition:

defined(__x86_64__) && defined(__clang__) && defined(__APPLE__)

which is not as specific as I'd like but should be safe. The output of clang -E -dM -x c /dev/null would really help selecting only the affected version, if you can provide it.

@mpg mpg closed this as completed Mar 14, 2014
@RafaelBaptista
Copy link
Author

Sorry I missed getting this to you sooner:

~: clang -E -dM -x c /dev/null

#define OBJC_NEW_PROPERTIES 1

#define _LP64 1

#define APPLE_CC 5621

#define APPLE 1

#define __ATOMIC_ACQUIRE 2

#define __ATOMIC_ACQ_REL 4

#define __ATOMIC_CONSUME 1

#define __ATOMIC_RELAXED 0

#define __ATOMIC_RELEASE 3

#define __ATOMIC_SEQ_CST 5

#define BLOCKS 1

#define BYTE_ORDER ORDER_LITTLE_ENDIAN

#define CHAR16_TYPE unsigned short

#define CHAR32_TYPE unsigned int

#define CHAR_BIT 8

#define CONSTANT_CFSTRINGS 1

#define DBL_DENORM_MIN 4.9406564584124654e-324

#define DBL_DIG 15

#define DBL_EPSILON 2.2204460492503131e-16

#define DBL_HAS_DENORM 1

#define DBL_HAS_INFINITY 1

#define DBL_HAS_QUIET_NAN 1

#define DBL_MANT_DIG 53

#define DBL_MAX_10_EXP 308

#define DBL_MAX_EXP 1024

#define DBL_MAX 1.7976931348623157e+308

#define DBL_MIN_10_EXP (-307)

#define DBL_MIN_EXP (-1021)

#define DBL_MIN 2.2250738585072014e-308

#define DECIMAL_DIG 21

#define DYNAMIC 1

#define ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED 1090

#define FINITE_MATH_ONLY 0

#define FLT_DENORM_MIN 1.40129846e-45F

#define FLT_DIG 6

#define FLT_EPSILON 1.19209290e-7F

#define FLT_EVAL_METHOD 0

#define FLT_HAS_DENORM 1

#define FLT_HAS_INFINITY 1

#define FLT_HAS_QUIET_NAN 1

#define FLT_MANT_DIG 24

#define FLT_MAX_10_EXP 38

#define FLT_MAX_EXP 128

#define FLT_MAX 3.40282347e+38F

#define FLT_MIN_10_EXP (-37)

#define FLT_MIN_EXP (-125)

#define FLT_MIN 1.17549435e-38F

#define FLT_RADIX 2

#define __GCC_ATOMIC_BOOL_LOCK_FREE 2

#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2

#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2

#define __GCC_ATOMIC_CHAR_LOCK_FREE 2

#define __GCC_ATOMIC_INT_LOCK_FREE 2

#define __GCC_ATOMIC_LLONG_LOCK_FREE 2

#define __GCC_ATOMIC_LONG_LOCK_FREE 2

#define __GCC_ATOMIC_POINTER_LOCK_FREE 2

#define __GCC_ATOMIC_SHORT_LOCK_FREE 2

#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1

#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2

#define GNUC_MINOR 2

#define GNUC_PATCHLEVEL 1

#define GNUC_STDC_INLINE 1

#define GNUC 4

#define __GXX_ABI_VERSION 1002

#define __GXX_RTTI 1

#define INT16_TYPE short

#define INT32_TYPE int

#define INT64_C_SUFFIX LL

#define INT64_TYPE long long int

#define INT8_TYPE char

#define INTMAX_MAX 9223372036854775807L

#define INTMAX_TYPE long int

#define INTMAX_WIDTH 64

#define INTPTR_TYPE long int

#define INTPTR_WIDTH 64

#define INT_MAX 2147483647

#define LDBL_DENORM_MIN 3.64519953188247460253e-4951L

#define LDBL_DIG 18

#define LDBL_EPSILON 1.08420217248550443401e-19L

#define LDBL_HAS_DENORM 1

#define LDBL_HAS_INFINITY 1

#define LDBL_HAS_QUIET_NAN 1

#define LDBL_MANT_DIG 64

#define LDBL_MAX_10_EXP 4932

#define LDBL_MAX_EXP 16384

#define LDBL_MAX 1.18973149535723176502e+4932L

#define LDBL_MIN_10_EXP (-4931)

#define LDBL_MIN_EXP (-16381)

#define LDBL_MIN 3.36210314311209350626e-4932L

#define LITTLE_ENDIAN 1

#define LONG_LONG_MAX 9223372036854775807LL

#define LONG_MAX 9223372036854775807L

#define LP64 1

#define MACH 1

#define MMX 1

#define NO_INLINE 1

#define __NO_MATH_INLINES 1

#define ORDER_BIG_ENDIAN 4321

#define ORDER_LITTLE_ENDIAN 1234

#define ORDER_PDP_ENDIAN 3412

#define PIC 2

#define POINTER_WIDTH 64

#define __PRAGMA_REDEFINE_EXTNAME 1

#define PTRDIFF_TYPE long int

#define PTRDIFF_WIDTH 64

#define REGISTER_PREFIX

#define SCHAR_MAX 127

#define SHRT_MAX 32767

#define SIG_ATOMIC_WIDTH 32

#define SIZEOF_DOUBLE 8

#define SIZEOF_FLOAT 4

#define SIZEOF_INT128 16

#define SIZEOF_INT 4

#define SIZEOF_LONG_DOUBLE 16

#define SIZEOF_LONG_LONG 8

#define SIZEOF_LONG 8

#define SIZEOF_POINTER 8

#define SIZEOF_PTRDIFF_T 8

#define SIZEOF_SHORT 2

#define SIZEOF_SIZE_T 8

#define SIZEOF_WCHAR_T 4

#define SIZEOF_WINT_T 4

#define SIZE_TYPE long unsigned int

#define SIZE_WIDTH 64

#define SSE2_MATH 1

#define SSE2 1

#define SSE3 1

#define SSE_MATH 1

#define SSE 1

#define SSP 1

#define SSSE3 1

#define STDC_HOSTED 1

#define STDC_VERSION 199901L

#define STDC 1

#define UINTMAX_TYPE long unsigned int

#define USER_LABEL_PREFIX _

#define VERSION "4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)"

#define WCHAR_MAX 2147483647

#define WCHAR_TYPE int

#define WCHAR_WIDTH 32

#define WINT_TYPE int

#define WINT_WIDTH 32

#define __amd64 1

#define amd64 1

#define apple_build_version 5000279

#define block __attribute((blocks(byref)))

#define clang 1

#define clang_major 5

#define clang_minor 0

#define clang_patchlevel 0

#define clang_version "5.0 (clang-500.2.79)"

#define __core2 1

#define core2 1

#define llvm 1

#define pic 2

#define __strong

#define tune_core2 1

#define __unsafe_unretained

#define weak __attribute((objc_gc(weak)))

#define __x86_64 1

#define x86_64 1

On Fri, Mar 14, 2014 at 4:28 AM, Manuel Pégourié-Gonnard <
notifications@github.com> wrote:

Closed #67 #67.

Reply to this email directly or view it on GitHubhttps://github.com//issues/67
.

@mpg
Copy link
Contributor

mpg commented Mar 14, 2014

Thanks a lot! No problem that you didn't reply sooner, it's just that we're planning a release in the next few days, so I was eager to include this early :) Thanks for your help again.

gilles-peskine-arm pushed a commit to gilles-peskine-arm/mbedtls that referenced this issue Mar 1, 2019
psa: Add backwards compatible error codes
hanno-becker pushed a commit to hanno-becker/mbedtls that referenced this issue Dec 1, 2020
Reduce duplication between ssl_msg.c and ssl_tls13_messaging.c, Mbed-TLS#2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants