[libcxx-commits] [libcxx] 2be4014 - [libc++] Reimplement platform detection features without running on the test host
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 8 11:05:47 PDT 2020
Author: Louis Dionne
Date: 2020-07-08T14:05:33-04:00
New Revision: 2be4014fe6005e310b9e24c88d407c7a14eb625e
URL: https://github.com/llvm/llvm-project/commit/2be4014fe6005e310b9e24c88d407c7a14eb625e
DIFF: https://github.com/llvm/llvm-project/commit/2be4014fe6005e310b9e24c88d407c7a14eb625e.diff
LOG: [libc++] Reimplement platform detection features without running on the test host
It's sufficient to sniff the platform we're running on using the compiler
macros -- we don't need to run any code.
Added:
Modified:
libcxx/utils/libcxx/test/features.py
Removed:
################################################################################
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 5229cf67b959..f3d8e782be8e 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -110,22 +110,10 @@
]
-# Add a feature representing the platform name: darwin, linux, windows, etc...
+# Add features representing the platform name: darwin, linux, windows, etc...
features += [
- Feature(name=lambda cfg: programOutput(cfg, """
- #include <cstdio>
- int main() {
- #if defined(__APPLE__)
- std::printf("darwin");
- #elif defined(_WIN32)
- std::printf("windows");
- #elif defined(__NetBSD__)
- std::printf("netbsd");
- #elif defined(__linux__)
- std::printf("linux");
- #else
- std::printf("unknown-platform");
- #endif
- }
- """))
+ Feature(name='darwin', when=lambda cfg: '__APPLE__' in compilerMacros(cfg)),
+ Feature(name='windows', when=lambda cfg: '_WIN32' in compilerMacros(cfg)),
+ Feature(name='linux', when=lambda cfg: '__linux__' in compilerMacros(cfg)),
+ Feature(name='netbsd', when=lambda cfg: '__NetBSD__' in compilerMacros(cfg))
]
More information about the libcxx-commits
mailing list