[PATCH] D116753: Default to -fno-math-errno for musl too

Alex Xu (Hello71) via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 6 08:54:58 PST 2022


alxu created this revision.
alxu added a project: clang.
alxu requested review of this revision.
Herald added a subscriber: cfe-commits.

musl does not set errno in math functions: https://wiki.musl-libc.org/mathematical-library.html, https://github.com/ifduyue/musl/blob/cfdfd5ea3ce14c6abf7fb22a531f3d99518b5a1b/include/math.h#L28.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116753

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/fast-math.c


Index: clang/test/Driver/fast-math.c
===================================================================
--- clang/test/Driver/fast-math.c
+++ clang/test/Driver/fast-math.c
@@ -102,6 +102,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-linux-android -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-linux-musl -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target amdgcn-amd-amdhsa -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target amdgcn-amd-amdpal -c %s 2>&1 \
Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -681,7 +681,7 @@
 }
 
 bool Linux::IsMathErrnoDefault() const {
-  if (getTriple().isAndroid())
+  if (getTriple().isAndroid() || getTriple().isMusl())
     return false;
   return Generic_ELF::IsMathErrnoDefault();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116753.397913.patch
Type: text/x-patch
Size: 1099 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220106/7370e16b/attachment.bin>


More information about the cfe-commits mailing list