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

[flang] Fixed compiler build on glibc 2.17 systems after 3149c93. #84873

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

vzakhari
Copy link
Contributor

No description provided.

@vzakhari vzakhari requested a review from luporl March 12, 2024 05:24
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Mar 12, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 12, 2024

@llvm/pr-subscribers-flang-semantics

Author: Slava Zakharin (vzakhari)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/84873.diff

3 Files Affected:

  • (modified) flang/include/flang/Evaluate/integer.h (+4)
  • (modified) flang/include/flang/Evaluate/real.h (+4)
  • (modified) flang/lib/Evaluate/fold-implementation.h (+4)
diff --git a/flang/include/flang/Evaluate/integer.h b/flang/include/flang/Evaluate/integer.h
index 31768c21daae62..7395645701265d 100644
--- a/flang/include/flang/Evaluate/integer.h
+++ b/flang/include/flang/Evaluate/integer.h
@@ -27,6 +27,10 @@
 #include <string>
 #include <type_traits>
 
+// Some environments, viz. glibc 2.17, allow the macro HUGE
+// to leak out of <math.h>.
+#undef HUGE
+
 namespace Fortran::evaluate::value {
 
 // Implements an integer as an assembly of smaller host integer parts
diff --git a/flang/include/flang/Evaluate/real.h b/flang/include/flang/Evaluate/real.h
index 5266bd0ef64bfd..d0da9634651f36 100644
--- a/flang/include/flang/Evaluate/real.h
+++ b/flang/include/flang/Evaluate/real.h
@@ -18,6 +18,10 @@
 #include <limits>
 #include <string>
 
+// Some environments, viz. glibc 2.17, allow the macro HUGE
+// to leak out of <math.h>.
+#undef HUGE
+
 namespace llvm {
 class raw_ostream;
 }
diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h
index 6b3c9416724cb6..9dd8c3843465d5 100644
--- a/flang/lib/Evaluate/fold-implementation.h
+++ b/flang/lib/Evaluate/fold-implementation.h
@@ -39,6 +39,10 @@
 #include <type_traits>
 #include <variant>
 
+// Some environments, viz. glibc 2.17, allow the macro HUGE
+// to leak out of <math.h>.
+#undef HUGE
+
 namespace Fortran::evaluate {
 
 // Utilities

@vzakhari vzakhari merged commit f95710c into llvm:main Mar 12, 2024
6 of 7 checks passed
@luporl
Copy link
Contributor

luporl commented Mar 12, 2024

The headers in glibc 2.17 define HUGE when __USE_SVID is defined, which depends on _SVID_SOURCE being defined.
By default, _BSD_SOURCE and _SVID_SOURCE are defined, but not when _POSIX_C_SOURCE is defined.

So, if you want to try, defining _POSIX_C_SOURCE for all platforms may fix this issue without needing to #undef HUGE, which would be a more permanent solution, that doesn't depend on the order of the includes. But as it changes what is exposed by the C runtime, it also has the potential to break something else.

@vzakhari
Copy link
Contributor Author

Thank you for the information, @luporl! I will try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants