Skip to contentSkip to conversation

configure: Make epoll_create1 test work around SPARC glibc bug

PATCH Applied Peter Maydell 2 participants 2 messages Apr 26, 2011

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 configure: Make epoll_create1 test work around SPARC glibc bug

Work around a SPARC glibc bug which caused the epoll_create1 configure test to wrongly claim that the function was present. Some versions of SPARC glibc provided the function in the library but didn't declare it in the include file; the result is that gcc warns about an implicit declaration but a link succeeds. So we reference the function as a value rather than a function call to induce a compile time error if the declaration was not present.

---
v1->v2: instead of compiling the test with -Werror, use the approach suggested by Blue Swirl to force a compile-time failure if the declaration is missing from the header file.

 configure |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
configure +9 -1
index de44bac..2bbbbf5 100755
@@ -2225,7 +2225,15 @@ cat > $TMPC << EOF
 
 int main(void)
 {
-    epoll_create1(0);
+    /* Note that we use epoll_create1 as a value, not as
+     * a function being called. This is necessary so that on
+     * old SPARC glibc versions where the function was present in
+     * the library but not declared in the header file we will
+     * fail the configure check. (Otherwise we will get a compiler
+     * warning but not an error, and will proceed to fail the
+     * qemu compile where we compile with -Werror.)
+     */
+    epoll_create1;
     return 0;
 }
 EOF
Signature · 1 line
1.7.1
Applied
#1 lore raw

Thanks, applied.

Quoted 42 lines · Peter Maydell

Work around a SPARC glibc bug which caused the epoll_create1 configure test to wrongly claim that the function was present. Some versions of SPARC glibc provided the function in the library but didn't declare it in the include file; the result is that gcc warns about an implicit declaration but a link succeeds. So we reference the function as a value rather than a function call to induce a compile time error if the declaration was not present.

---
v1->v2: instead of compiling the test with -Werror, use the approach suggested by Blue Swirl to force a compile-time failure if the declaration is missing from the header file.

 configure |   10 +++++++++-

 1 files changed, 9 insertions(+), 1 deletions(-)
configure +9 -1
index de44bac..2bbbbf5 100755
@@ -2225,7 +2225,15 @@ cat > $TMPC << EOF
 
  int main(void)
  {
-    epoll_create1(0);
+    /* Note that we use epoll_create1 as a value, not as
+     * a function being called. This is necessary so that on
+     * old SPARC glibc versions where the function was present in
+     * the library but not declared in the header file we will
+     * fail the configure check. (Otherwise we will get a compiler
+     * warning but not an error, and will proceed to fail the
+     * qemu compile where we compile with -Werror.)
+     */
+    epoll_create1;
     return 0;
  }

 EOF
--
1.7.1