aboutsummaryrefslogtreecommitdiffstats
path: root/win32/setup.mak
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-02-12 23:29:19 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-02-20 20:39:48 +0900
commited8776f96034b245b5418d4817d0ebda3db24198 (patch)
tree7b3482ad52f1ec8aecd4f071186f41bd2ad69bfa /win32/setup.mak
parent32af1a3b5e8bb7b5ffc3c7f97edb8c0b74f016ae (diff)
downloadruby-ed8776f96034b245b5418d4817d0ebda3db24198.tar.gz
[MSWin] Tentative measure for a bug of VS2022 [Misc #18362]
Disable the use of `__assume()`, when combinations of `isnan()`, `isinf()` and `__assume()` will be wrongly optimized due to the bug of VS2022.
Diffstat (limited to 'win32/setup.mak')
-rw-r--r--win32/setup.mak49
1 files changed, 49 insertions, 0 deletions
diff --git a/win32/setup.mak b/win32/setup.mak
index 4ed112294d..466c1ef515 100644
--- a/win32/setup.mak
+++ b/win32/setup.mak
@@ -123,6 +123,55 @@ int main(void) {FILE *volatile f = stdin; return 0;}
-headers-: nul
+-headers-: vs2022-fp-bug
+
+# Check the bug reported at:
+# https://developercommunity.visualstudio.com/t/With-__assume-isnan-after-isinf/1515649
+# https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
+vs2022-fp-bug:
+ @echo checking for $(@:-= )
+ @echo <<$@.c > NUL
+/* compile with -O2 */
+#include <math.h>
+#include <float.h>
+
+#define value_finite(d) 'f'
+#define value_infinity() 'i'
+#define value_nan() 'n'
+
+#ifdef NO_ASSUME
+# define ASSUME_TRUE() (void)0
+#else
+# define ASSUME_TRUE() __assume(1)
+#endif
+
+static int
+check_value(double value)
+{
+ if (isinf(value)) {
+ return value_infinity();
+ }
+ else if (isnan(value)) {
+ return value_nan();
+ }
+
+ ASSUME_TRUE();
+ return value_finite(value);
+}
+
+int
+main(void)
+{
+ int c = check_value(nan(""));
+ printf("NaN=>%c\n", c);
+ return c != value_nan();
+}
+<<
+ @( \
+ ($(CC) -O2 -DNO_ASSUME $@.c && .\$@ && $(CC) -O2 $@.c) && \
+ (.\$@ || echo>>$(MAKEFILE) VS2022_FP_BUG=1) \
+ ) & $(WIN32DIR:/=\)\rm.bat $@.*
+
-version-: nul verconf.mk
verconf.mk: nul