termux-packages/packages/lfortran/src-bin-lfortran.cpp.patch

71 lines
2.4 KiB
Diff
Raw Normal View History

2022-01-30 03:43:52 +01:00
--- a/src/bin/lfortran.cpp
+++ b/src/bin/lfortran.cpp
@@ -81,10 +81,15 @@
{
char *env_p = std::getenv("LFORTRAN_KOKKOS_DIR");
if (env_p) return env_p;
+#ifdef __ANDROID__
+ static std::string lfortran_kokkos_dir_default = "@TERMUX_PREFIX@";
+ return lfortran_kokkos_dir_default;
+#else
std::cerr << "The code C++ generated by the C++ LFortran backend uses the Kokkos library" << std::endl;
std::cerr << "(https://github.com/kokkos/kokkos). Please define the LFORTRAN_KOKKOS_DIR" << std::endl;
std::cerr << "environment variable to point to the Kokkos installation." << std::endl;
throw LFortran::LFortranException("LFORTRAN_KOKKOS_DIR is not defined");
+#endif
}
#ifdef HAVE_LFORTRAN_LLVM
@@ -873,7 +878,11 @@
out << " ";
}
char *env_CC = std::getenv("LFORTRAN_CC");
+#ifdef __ANDROID__
+ std::string CC="clang";
+#else
std::string CC="gcc";
+#endif
if (env_CC) CC = env_CC;
std::string cmd = CC + " -c " + outfile_empty + " -o " + outfile;
int err = system(cmd.c_str());
@@ -905,7 +914,11 @@
out << src;
}
+#ifdef __ANDROID__
+ std::string CXX = "clang++";
+#else
std::string CXX = "g++";
+#endif
std::string options;
if (openmp) {
options += "-fopenmp ";
@@ -1037,7 +1050,11 @@
}
return 0;
} else if (backend == Backend::cpp) {
+#ifdef __ANDROID__
+ std::string CXX = "clang++";
+#else
std::string CXX = "g++";
+#endif
std::string options, post_options;
if (static_executable) {
options += " -static ";
@@ -1047,8 +1064,13 @@
}
if (kokkos) {
std::string kokkos_dir = get_kokkos_dir();
- post_options += kokkos_dir + "/lib/libkokkoscontainers.a "
- + kokkos_dir + "/lib/libkokkoscore.a -ldl";
+ if (static_executable) {
+ post_options += kokkos_dir + "/lib/libkokkoscontainers.a "
+ + kokkos_dir + "/lib/libkokkoscore.a -ldl";
+ } else {
+ post_options += kokkos_dir + "/lib/libkokkoscontainers.so "
+ + kokkos_dir + "/lib/libkokkoscore.so -ldl";
+ }
}
std::string cmd = CXX + options + " -o " + outfile + " ";
for (auto &s : infiles) {