--- a/src/bin/lfortran.cpp +++ b/src/bin/lfortran.cpp @@ -95,10 +95,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 @@ -1082,7 +1087,11 @@ out << src; } +#ifdef __ANDROID__ + std::string CXX = "clang++"; +#else std::string CXX = "g++"; +#endif std::string options; if (compiler_options.openmp) { options += "-fopenmp "; @@ -1212,7 +1221,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 "; @@ -1222,8 +1235,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) { @@ -1304,7 +1322,7 @@ bool show_asm = false; bool time_report = false; bool static_link = false; - std::string arg_backend = "llvm"; + std::string arg_backend = "cpp"; std::string arg_kernel_f; bool print_targets = false;