[flang-commits] [flang] [flang] add no-cpp-dep test for AIX 64 bit (PR #74637)

via flang-commits flang-commits at lists.llvm.org
Wed Dec 6 10:18:33 PST 2023


https://github.com/madanial0 created https://github.com/llvm/llvm-project/pull/74637

Add a new test for no-cpp-dep on AIX as it requires 64 bit OBJECT_MODE since only 64-bit AIX is supported. AIX does not allow `-o /dev/null` and requires `-lpthread` flag to be added. 

>From 4037ed0c1f90e267578a7cc832fac6cf028ab193 Mon Sep 17 00:00:00 2001
From: Mark Danial <madanial at dixon.rtp.raleigh.ibm.com>
Date: Wed, 6 Dec 2023 13:13:45 -0500
Subject: [PATCH] [flang] add no-cpp-dep test for AIX 64 bit

---
 flang/test/Runtime/no-cpp-dep-aix.c | 40 +++++++++++++++++++++++++++++
 flang/test/Runtime/no-cpp-dep.c     |  1 +
 2 files changed, 41 insertions(+)
 create mode 100644 flang/test/Runtime/no-cpp-dep-aix.c

diff --git a/flang/test/Runtime/no-cpp-dep-aix.c b/flang/test/Runtime/no-cpp-dep-aix.c
new file mode 100644
index 0000000000000..4d0591874dad0
--- /dev/null
+++ b/flang/test/Runtime/no-cpp-dep-aix.c
@@ -0,0 +1,40 @@
+/*
+This test makes sure that flang's runtime does not depend on the C++ runtime
+library. It tries to link this simple file against libFortranRuntime.a with
+a C compiler.
+
+REQUIRES: c-compiler, system-aix
+
+RUN: export OBJECT_MODE=64
+RUN: %cc -std=c99 %s -I%include %libruntime %libdecimal -lm -lpthread
+RUN: rm a.out
+*/
+
+#include "flang/Runtime/entry-names.h"
+#include <stdint.h>
+
+/*
+Manually add declarations for the runtime functions that we want to make sure
+we're testing. We can't include any headers directly since they likely contain
+C++ code that would explode here.
+*/
+struct EnvironmentDefaultList;
+struct Descriptor;
+
+double RTNAME(CpuTime)();
+
+void RTNAME(ProgramStart)(
+    int, const char *[], const char *[], const struct EnvironmentDefaultList *);
+int32_t RTNAME(ArgumentCount)();
+int32_t RTNAME(GetCommandArgument)(int32_t, const struct Descriptor *,
+    const struct Descriptor *, const struct Descriptor *);
+int32_t RTNAME(GetEnvVariable)();
+
+int main() {
+  double x = RTNAME(CpuTime)();
+  RTNAME(ProgramStart)(0, 0, 0, 0);
+  int32_t c = RTNAME(ArgumentCount)();
+  int32_t v = RTNAME(GetCommandArgument)(0, 0, 0, 0);
+  int32_t e = RTNAME(GetEnvVariable)("FOO", 0, 0);
+  return x + c + v + e;
+}
diff --git a/flang/test/Runtime/no-cpp-dep.c b/flang/test/Runtime/no-cpp-dep.c
index f8fe97b5bf78e..e760c27d1f156 100644
--- a/flang/test/Runtime/no-cpp-dep.c
+++ b/flang/test/Runtime/no-cpp-dep.c
@@ -4,6 +4,7 @@ library. It tries to link this simple file against libFortranRuntime.a with
 a C compiler.
 
 REQUIRES: c-compiler
+UNSUPPORTED: system-aix
 
 RUN: %cc -std=c99 %s -I%include %libruntime %libdecimal -lm -o /dev/null
 */



More information about the flang-commits mailing list