[Runtime] Use libc monotonic clock on Emscripten (#25165)

While building with Emscripten 6x (latest emscripten), `clock_now_ns` is an undefined symbol. Emscripten currently takes the freestanding Wasm clock path, although it already provides `clock_gettime`.

Use the existing libc `CLOCK_MONOTONIC` path for Emscripten.

---------

Signed-off-by: anutosh491 <andersonbhat491@gmail.com>
diff --git a/runtime/src/iree/base/internal/sysfs_test.cc b/runtime/src/iree/base/internal/sysfs_test.cc
index e1147f6..8608761 100644
--- a/runtime/src/iree/base/internal/sysfs_test.cc
+++ b/runtime/src/iree/base/internal/sysfs_test.cc
@@ -11,7 +11,7 @@
 
 namespace {
 
-#if defined(IREE_PLATFORM_LINUX) && !defined(IREE_PLATFORM_EMSCRIPTEN)
+#if defined(IREE_PLATFORM_LINUX) && !defined(IREE_COMPILER_EMSCRIPTEN)
 
 using namespace iree::testing::status;
 
@@ -72,6 +72,6 @@
 
 TEST(SysfsTest, PlatformDisabled) {}
 
-#endif  // IREE_PLATFORM_LINUX && !IREE_PLATFORM_EMSCRIPTEN
+#endif  // IREE_PLATFORM_LINUX && !IREE_COMPILER_EMSCRIPTEN
 
 }  // namespace
diff --git a/runtime/src/iree/base/internal/time.c b/runtime/src/iree/base/internal/time.c
index 9a5f5d2..b8b90c7 100644
--- a/runtime/src/iree/base/internal/time.c
+++ b/runtime/src/iree/base/internal/time.c
@@ -9,7 +9,8 @@
 #include "iree/base/config.h"
 #include "iree/base/target_platform.h"
 
-#if defined(IREE_PLATFORM_WASM) && !defined(IREE_PLATFORM_WASI)
+#if defined(IREE_PLATFORM_WASM) && !defined(IREE_PLATFORM_WASI) && \
+    !defined(IREE_COMPILER_EMSCRIPTEN)
 
 // Freestanding wasm (browser/Node.js) uses a direct JS import that returns
 // nanoseconds as int64_t. This avoids the POSIX clock_gettime abstraction
@@ -45,7 +46,8 @@
   return seconds * 1000000000ll +
          (remainder * 1000000000ll) / frequency.QuadPart;
 #elif defined(IREE_PLATFORM_ANDROID) || defined(IREE_PLATFORM_APPLE) || \
-    defined(IREE_PLATFORM_LINUX) || defined(IREE_PLATFORM_WASI)
+    defined(IREE_PLATFORM_LINUX) || defined(IREE_PLATFORM_WASI) ||      \
+    defined(IREE_COMPILER_EMSCRIPTEN)
   // CLOCK_MONOTONIC is used across all POSIX-like platforms for consistency.
   // WASI libc provides clock_gettime backed by __wasi_clock_time_get.
   // CLOCK_MONOTONIC_RAW exists on Linux but can't be used with
@@ -60,4 +62,5 @@
 #endif  // IREE_PLATFORM_*
 }
 
-#endif  // IREE_PLATFORM_WASM && !IREE_PLATFORM_WASI
+#endif  // IREE_PLATFORM_WASM && !IREE_PLATFORM_WASI &&
+        // !IREE_COMPILER_EMSCRIPTEN
diff --git a/runtime/src/iree/base/target_platform.h b/runtime/src/iree/base/target_platform.h
index 834a6dd..d380b5a 100644
--- a/runtime/src/iree/base/target_platform.h
+++ b/runtime/src/iree/base/target_platform.h
@@ -31,6 +31,7 @@
 // IREE_MEMORY_ACCESS_ALIGNMENT_REQUIRED_64 (0/1)
 //
 // IREE_COMPILER_CLANG
+// IREE_COMPILER_EMSCRIPTEN
 // IREE_COMPILER_GCC
 // IREE_COMPILER_GCC_COMPAT
 // IREE_COMPILER_MSVC
@@ -200,6 +201,10 @@
 #error Unrecognized compiler.
 #endif  // compiler versions
 
+#if defined(__EMSCRIPTEN__)
+#define IREE_COMPILER_EMSCRIPTEN 1
+#endif  // __EMSCRIPTEN__
+
 #if defined(__has_feature)
 #if __has_feature(address_sanitizer)
 #define IREE_SANITIZER_ADDRESS 1