[flang-commits] [flang] [flang] Remove C++ runtime dependency from Sleep extension (PR #84911)

via flang-commits flang-commits at lists.llvm.org
Tue Mar 12 06:40:05 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-runtime

Author: David Truby (DavidTruby)

<details>
<summary>Changes</summary>

The Sleep extension currently has a potential dependency on the C++ runtime. I
run into this dependency using libc++ on Linux. This patch uses the POSIX
`sleep` function or the Windows `Sleep` function instead to avoid this
dependency.


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


1 Files Affected:

- (modified) flang/runtime/extensions.cpp (+5-1) 


``````````diff
diff --git a/flang/runtime/extensions.cpp b/flang/runtime/extensions.cpp
index 3ac98000335d7d..fb11e792f613f5 100644
--- a/flang/runtime/extensions.cpp
+++ b/flang/runtime/extensions.cpp
@@ -135,7 +135,11 @@ void RTNAME(Sleep)(std::int64_t seconds) {
   if (seconds < 1) {
     return;
   }
-  std::this_thread::sleep_for(std::chrono::seconds(seconds));
+#if _WIN32
+  Sleep(seconds * 1000);
+#else
+  sleep(seconds);
+#endif
 }
 
 } // namespace Fortran::runtime

``````````

</details>


https://github.com/llvm/llvm-project/pull/84911


More information about the flang-commits mailing list