osxcross icon indicating copy to clipboard operation
osxcross copied to clipboard

clang++ not happy with MacOS 10.5 SDK's stdint.h

Open HinTak opened this issue 6 years ago • 2 comments

One of Fedora's dev had a OS X cross-compiler framework setup around the time of fedora 20 (2011?) based on 10.5 SDK and gcc 4.2.1 and it is triarch (ppc + 32bit intel + 64bit intel) and it continues to work well, so I wanted to just update the compiler part of it to make use of gcc 5.x+ features.

The clang++ part dies with test_compiler o32-clang++ $BASE_DIR/oclang/test.cpp :

/usr/darwinx/SDKs/MacOSX10.5.sdk/usr/include/c++/4.0.0/bits/postypes.h:72:11: error: unknown type name 'int64_t'; did you
      mean '__int64_t'?
  typedef int64_t       streamoff;
          ^
/usr/darwinx/SDKs/MacOSX10.5.sdk/usr/include/i386/_types.h:46:20: note: '__int64_t' declared here
typedef long long               __int64_t;
                                ^
1 error generated.

and eventually I worked out that the problem is stdint.h -

$ ls -l /usr/darwinx/SDKs/MacOSX10.5.sdk/usr/include/stdint.h
lrwxrwxrwx. 1 root root 27 Nov 12  2012 /usr/darwinx/SDKs/MacOSX10.5.sdk/usr/include/stdint.h -> gcc/darwin/default/stdint.h

indeed, if I allow use the copy of stdint.h in the kernel header as in
$SDK_DIR/MacOSX$SDK_VERSION.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/std*.h - or by symlinking it elsewhere and do "-Ielswhere" then the test return success.

There are at least two online bug reports, etc related to this strange compatibility problem of Clang with Mac OS X SDK's stdint.h : https://bugreports.qt.io/browse/QTCREATORBUG-14856 https://bugs.chromium.org/p/chromium/issues/detail?id=99378#c11

and various comments about gcc's -ffreestanding which I don't quite understand.

Now, I'd like to use the existing SDK's layout without changing/re-symlinking. Is there anyway of doing so? With one of those -I quirks/includes perhaps?

HinTak avatar Aug 19 '17 20:08 HinTak

Now I also remember that for a while hfsplus-tools on fedora is buildable with clang only, and it also bundle some headers. Don't know if it is related.

HinTak avatar Aug 24 '17 02:08 HinTak

I feel like compatibility problems when mixing a newer C++ compiler with older headers is a pretty normal problem. this is not just a Mac / Xcode thing, it happens all the time on linux, where dependency version X requires gcc version Y , with library version Z.

I don't have osx 10.5 to test with but it'd be interesting to know which version of clang you were running, and what was the source code of your test program that failed to build...

donbright avatar Aug 21 '18 00:08 donbright