#54135 closed defect (fixed)
clang-4.0 error building software on 10.6 (or less) due to #include_next <float.h>
Reported by: | kencu (Ken) | Owned by: | jeremyhu (Jeremy Huddleston Sequoia) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | snowleopard leopard tiger | Cc: | devernay (Frédéric Devernay), ballapete (Peter "Pete" Dyballa), dliessi (Davide Liessi), mojca (Mojca Miklavec) |
Port: | clang-4.0 |
Description
Jeremy identified this bug six months ago or so, but it's still in the clang-4.0 source tree.
<https://bugs.llvm.org//show_bug.cgi?id=31504>
Gestos (ftp83) recently came across this error <https://pastebin.com/dmNJFQKU> while building glib2 with clang-4.0, and asked for help:
:info:build In file included from /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.0/include/float.h:36: :info:build /usr/include/float.h:8:15: fatal error: 'float.h' file not found :info:build #include_next <float.h> :info:build ^~~~~~~~~ :info:build 1 error generated.
I generated this bit for the Portfile:
platform darwin { # float.h broken on clang (file doesn't exist when building llvm only) # only for < SnowLeopard if {${subport} eq "clang-${llvm_version}" && ${os.major} < 11 } { # https://bugs.llvm.org//show_bug.cgi?id=31504 patchfiles-append 998-patch-tools-clang-lib-headers-float-fix-SL.diff } }
and this patchfile
--- ./tools/clang/lib/Headers/float.h.orig 2017-05-06 10:27:32.000000000 -0700 +++ ./tools/clang/lib/Headers/float.h 2017-05-06 10:28:08.000000000 -0700 @@ -31,7 +31,7 @@ * Also fall back on Darwin to allow additional definitions and * implementation-defined values. */ -#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \ +#if ((defined(__MINGW32__) || defined(_MSC_VER))) && \ __STDC_HOSTED__ && __has_include_next(<float.h>) # include_next <float.h>
and with this I've had no such issues so far building ports with clang-4.0 on SnowLeopard.
I hesitate to generate a PR for such a complex port as clang-4.0.
Change History (21)
comment:1 Changed 8 years ago by kencu (Ken)
comment:2 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)
Cc: | jeremyhu removed |
---|---|
Keywords: | snowleopard leopard tiger added; SnowLeopard removed |
Owner: | set to jeremyhu |
Status: | new → assigned |
comment:3 Changed 8 years ago by devernay (Frédéric Devernay)
Cc: | devernay added |
---|
comment:4 Changed 8 years ago by roebel (Axel Roebel)
The proposed patch has solved the problem for me compiling on snow leopard as well. Thanks for the fix.
comment:5 Changed 7 years ago by ballapete (Peter "Pete" Dyballa)
Cc: | ballapete added |
---|
comment:6 Changed 7 years ago by ballapete (Peter "Pete" Dyballa)
After figuring out that the patch will only be applied to Clang I build LLVM first and then studied which patches were applied to Clang. So I managed to add the patch to Portfile. Clang built as well.
It would be easier to work with the pieces if line numbers would be displayed or diff output would exist.
comment:7 Changed 7 years ago by dliessi (Davide Liessi)
Cc: | dliessi added |
---|
comment:8 Changed 7 years ago by mojca (Mojca Miklavec)
Cc: | mojca added |
---|
comment:9 Changed 7 years ago by mojca (Mojca Miklavec)
Cc: | mojca removed |
---|
comment:10 Changed 7 years ago by mojca (Mojca Miklavec)
Cc: | mojca added |
---|
comment:11 Changed 7 years ago by mojca (Mojca Miklavec)
In case Jeremy has no time to commit this, one of us could, even though I'm sadly unable to do such extensive testing as Jeremy usually does. I desperately need a working clang-4.0 compiler on 10.6 :)
From what I understand Jeremy suggested to completely revert the patch. That is: make the patch unconditional (not just on 10.6). Someone may submit a PR, even though I doubt that the build would actually finish in time.
Does this need a revbump or not?
comment:14 Changed 7 years ago by devernay (Frédéric Devernay)
I've been using this patch for weeks to build a full macports + a 600k LOC application (Natron). We are even using the OpenMP implementation from clang-4.0.
Note that LLVM 4.0.1 is out
comment:15 Changed 7 years ago by jeremyhu (Jeremy Huddleston Sequoia)
I’m thinking adding something like:
#if defined(__APPLE__) && __has_include(<Availability.h>) #include <Availability.h> #endif
and then changing the defined(__APPLE__)
in the condition to (defined(__APPLE__) && (!defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300))
If someone could test that, I’d appreciate it.
comment:16 Changed 7 years ago by jeremyhu (Jeremy Huddleston Sequoia)
diff --git a/lib/Headers/float.h b/lib/Headers/float.h index 0f453d87cb..1db2b28ed7 100644 --- a/lib/Headers/float.h +++ b/lib/Headers/float.h @@ -31,7 +31,12 @@ * Also fall back on Darwin to allow additional definitions and * implementation-defined values. */ -#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \ + +#if defined(__APPLE__) && __has_include(<Availability.h>) +#include <Availability.h> +#endif + +#if ((defined(__APPLE__) && __has_include(<Availability.h>) && (!defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300)) || (defined(__MINGW32__) || defined(_MSC_VER))) && \ __STDC_HOSTED__ && __has_include_next(<float.h>) # include_next <float.h>
comment:17 Changed 7 years ago by kencu (Ken)
I needed to adjust the path a bit, to
--- ./tools/clang/lib/Headers/float.h.orig 2017-05-06 10:27:32.000000000 -0700 +++ ./tools/clang/lib/Headers/float.h 2017-05-06 10:28:08.000000000 -0700
but after that it installed fine. I have clang-4.0 built with this on 10.6 now, and I'm just running a glib2 build to make sure it works correctly. I'll make you a PR for this tomorrow, as I assume that's easier for you.
comment:18 Changed 7 years ago by jeremyhu (Jeremy Huddleston Sequoia)
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:19 Changed 7 years ago by jeremyhu (Jeremy Huddleston Sequoia)
comment:20 Changed 7 years ago by jeremyhu (Jeremy Huddleston Sequoia)
comment:21 Changed 7 years ago by ballapete (Peter "Pete" Dyballa)
llvm-4.0 and clang-4.0 built on Mac OS X 10.6.8, Snow Leopard.
the comment should say