Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename LFortran namespace to LCompilers #534

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# In Debug mode we enable assertions
set(WITH_LFORTRAN_ASSERT_DEFAULT yes)
set(WITH_LCOMPILERS_ASSERT_DEFAULT yes)
else()
set(WITH_LFORTRAN_ASSERT_DEFAULT no)
set(WITH_LCOMPILERS_ASSERT_DEFAULT no)
endif()


# LFORTRAN_ASSERT
set(WITH_LFORTRAN_ASSERT ${WITH_LFORTRAN_ASSERT_DEFAULT}
CACHE BOOL "Enable LFORTRAN_ASSERT macro")
# LCOMPILERS_ASSERT
set(WITH_LCOMPILERS_ASSERT ${WITH_LCOMPILERS_ASSERT_DEFAULT}
CACHE BOOL "Enable LCOMPILERS_ASSERT macro")

# LPYTHON_STATIC_BIN
set(LPYTHON_STATIC_BIN no CACHE BOOL "Build LPython as a static binary")

# WITH_LFORTRAN_BINARY_MODFILES
set(WITH_LFORTRAN_BINARY_MODFILES YES
# WITH_LCOMPILERS_BINARY_MODFILES
set(WITH_LCOMPILERS_BINARY_MODFILES YES
CACHE BOOL "Use binary modfiles")

set(WITH_RUNTIME_LIBRARY YES
Expand Down Expand Up @@ -188,22 +188,22 @@ if (WITH_LLVM)
target_link_directories(p::llvm BEFORE INTERFACE ${mypath})
message(STATUS "ZLIB LIBRARY PATH: ${mypath}")
endif()
set(HAVE_LFORTRAN_LLVM yes)
set(HAVE_LCOMPILERS_LLVM yes)
endif()

# XEUS (Fortran kernel)
set(WITH_XEUS no CACHE BOOL "Build with XEUS support")
if (WITH_XEUS)
find_package(xeus 0.24.1 REQUIRED)
set(HAVE_LFORTRAN_XEUS yes)
set(HAVE_LCOMPILERS_XEUS yes)

# Generate kernel.json with correct paths
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/fortran/kernel.json.in"
"${CMAKE_CURRENT_BINARY_DIR}/share/jupyter/kernels/fortran/kernel.json"
)

# Configuration and data directories for Jupyter and LFortran
# Configuration and data directories for Jupyter and LPython
set(XJUPYTER_DATA_DIR "share/jupyter" CACHE STRING "Jupyter data directory")

# Install Jupyter kernelspecs
Expand All @@ -218,15 +218,15 @@ set(WITH_JSON no CACHE BOOL "Build with JSON support")
set(WITH_LSP no CACHE BOOL "Build with LSP support")
if (WITH_JSON OR WITH_LSP)
find_package(RapidJSON REQUIRED)
set(HAVE_LFORTRAN_RAPIDJSON yes)
set(HAVE_LCOMPILERS_RAPIDJSON yes)
endif()

set(HAVE_LFORTRAN_DEMANGLE yes
set(HAVE_LCOMPILERS_DEMANGLE yes
CACHE BOOL "Build with C++ name demangling support (cxxabi.h)")

if (MSVC)
# MSVC doesn't have cxxabi.h
set(HAVE_LFORTRAN_DEMANGLE no)
set(HAVE_LCOMPILERS_DEMANGLE no)
endif()

# fmt (`conda install fmt`)
Expand Down Expand Up @@ -259,7 +259,7 @@ if (WITH_STACKTRACE)
set(WITH_LINKH yes)
set(WITH_BFD yes)
endif()
set(HAVE_LFORTRAN_STACKTRACE yes)
set(HAVE_LCOMPILERS_STACKTRACE yes)
endif()
if (WITH_RUNTIME_STACKTRACE)
set(WITH_UNWIND yes)
Expand All @@ -272,21 +272,21 @@ if (WITH_RUNTIME_STACKTRACE)
endif()
if (WITH_BFD)
find_package(BFD REQUIRED)
set(HAVE_LFORTRAN_BFD yes)
set(HAVE_LCOMPILERS_BFD yes)
endif()
if (WITH_DWARFDUMP)
set(HAVE_LFORTRAN_DWARFDUMP yes)
set(HAVE_LCOMPILERS_DWARFDUMP yes)
endif()
if (WITH_LINKH)
find_package(LINKH REQUIRED)
set(HAVE_LFORTRAN_LINK yes)
set(HAVE_LCOMPILERS_LINK yes)
endif()
if (WITH_MACHO)
find_package(MACHO REQUIRED)
set(HAVE_LFORTRAN_MACHO yes)
set(HAVE_LCOMPILERS_MACHO yes)
endif()
if (WITH_UNWIND)
set(HAVE_LFORTRAN_UNWIND yes)
set(HAVE_LCOMPILERS_UNWIND yes)
endif()

enable_testing()
Expand All @@ -307,7 +307,7 @@ else ()
message("C++ compiler flags : ${CMAKE_CXX_FLAGS_RELEASE}")
endif ()
message("Installation prefix: ${CMAKE_INSTALL_PREFIX}")
message("WITH_LFORTRAN_ASSERT: ${WITH_LFORTRAN_ASSERT}")
message("WITH_LCOMPILERS_ASSERT: ${WITH_LCOMPILERS_ASSERT}")
message("LPYTHON_STATIC_BIN: ${LPYTHON_STATIC_BIN}")
message("LPYTHON_BUILD_TO_WASM: ${LPYTHON_BUILD_TO_WASM}")
message("WITH_STACKTRACE: ${WITH_STACKTRACE}")
Expand All @@ -317,13 +317,13 @@ message("WITH_BFD: ${WITH_BFD}")
message("WITH_DWARFDUMP: ${WITH_DWARFDUMP}")
message("WITH_LINKH: ${WITH_LINKH}")
message("WITH_MACHO: ${WITH_MACHO}")
message("HAVE_LFORTRAN_DEMANGLE: ${HAVE_LFORTRAN_DEMANGLE}")
message("HAVE_LCOMPILERS_DEMANGLE: ${HAVE_LCOMPILERS_DEMANGLE}")
message("WITH_LLVM: ${WITH_LLVM}")
message("WITH_XEUS: ${WITH_XEUS}")
message("WITH_JSON: ${WITH_JSON}")
message("WITH_LSP: ${WITH_LSP}")
message("WITH_FMT: ${WITH_FMT}")
message("WITH_LFORTRAN_BINARY_MODFILES: ${WITH_LFORTRAN_BINARY_MODFILES}")
message("WITH_LCOMPILERS_BINARY_MODFILES: ${WITH_LCOMPILERS_BINARY_MODFILES}")
message("WITH_RUNTIME_LIBRARY: ${WITH_RUNTIME_LIBRARY}")
message("WITH_WHEREAMI: ${WITH_WHEREAMI}")
message("WITH_ZLIB: ${WITH_ZLIB}")
Expand Down
2 changes: 1 addition & 1 deletion build1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cmake \
-DWITH_STACKTRACE=yes \
-DWITH_RUNTIME_STACKTRACE=yes \
-DWITH_LSP=no \
-DWITH_LFORTRAN_BINARY_MODFILES=no \
-DWITH_LCOMPILERS_BINARY_MODFILES=no \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH_LPYTHON;$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
.
Expand Down
2 changes: 1 addition & 1 deletion build_to_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ emcmake cmake \
-DLPYTHON_BUILD_TO_WASM=yes \
-DWITH_STACKTRACE=no \
-DWITH_LSP=no \
-DWITH_LFORTRAN_BINARY_MODFILES=no \
-DWITH_LCOMPILERS_BINARY_MODFILES=no \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH_LFORTRAN;$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
.
Expand Down
18 changes: 9 additions & 9 deletions src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <emscripten/emscripten.h>
#endif

#ifdef HAVE_LFORTRAN_RAPIDJSON
#ifdef HAVE_LCOMPILERS_RAPIDJSON
#include <rapidjson/document.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
Expand Down Expand Up @@ -103,7 +103,7 @@ int visualize_json(std::string &astr_data_json, LCompilers::Platform os) {
return 0;
}

#ifdef HAVE_LFORTRAN_LLVM
#ifdef HAVE_LCOMPILERS_LLVM

#endif

Expand Down Expand Up @@ -480,7 +480,7 @@ int emit_wat(const std::string &infile,
return 0;
}

#ifdef HAVE_LFORTRAN_RAPIDJSON
#ifdef HAVE_LCOMPILERS_RAPIDJSON

int get_symbols (const std::string &infile,
const std::string &runtime_library_dir,
Expand Down Expand Up @@ -694,7 +694,7 @@ void print_time_report(std::vector<std::pair<std::string, double>> &times, bool
}
}

#ifdef HAVE_LFORTRAN_LLVM
#ifdef HAVE_LCOMPILERS_LLVM

int emit_llvm(const std::string &infile,
const std::string &runtime_library_dir,
Expand Down Expand Up @@ -1789,7 +1789,7 @@ int main(int argc, char *argv[])
return emit_wat(arg_file, runtime_library_dir, compiler_options);
}
if (show_document_symbols) {
#ifdef HAVE_LFORTRAN_RAPIDJSON
#ifdef HAVE_LCOMPILERS_RAPIDJSON
return get_symbols(arg_file, runtime_library_dir, compiler_options);
#else
std::cerr << "Compiler was not built with LSP support (-DWITH_LSP), please build it again." << std::endl;
Expand All @@ -1798,7 +1798,7 @@ int main(int argc, char *argv[])
}

if (show_errors) {
#ifdef HAVE_LFORTRAN_RAPIDJSON
#ifdef HAVE_LCOMPILERS_RAPIDJSON
return get_errors(arg_file, runtime_library_dir, compiler_options);
#else
std::cerr << "Compiler was not configured with LSP support (-DWITH_LSP), please build it again." << std::endl;
Expand All @@ -1807,7 +1807,7 @@ int main(int argc, char *argv[])
}
lpython_pass_manager.use_default_passes();
if (show_llvm) {
#ifdef HAVE_LFORTRAN_LLVM
#ifdef HAVE_LCOMPILERS_LLVM
return emit_llvm(arg_file, runtime_library_dir, lpython_pass_manager, compiler_options);
#else
std::cerr << "The --show-llvm option requires the LLVM backend to be enabled. Recompile with `WITH_LLVM=yes`." << std::endl;
Expand All @@ -1832,7 +1832,7 @@ int main(int argc, char *argv[])

if (arg_c) {
if (backend == Backend::llvm) {
#ifdef HAVE_LFORTRAN_LLVM
#ifdef HAVE_LCOMPILERS_LLVM
return compile_python_to_object_file(arg_file, outfile, runtime_library_dir, lpython_pass_manager, compiler_options, time_report,
arg_c);
#else
Expand Down Expand Up @@ -1864,7 +1864,7 @@ int main(int argc, char *argv[])
err = link_executable({emit_file_name}, outfile, runtime_library_dir,
backend, static_link, true, compiler_options, rtlib_header_dir);
} else if (backend == Backend::llvm) {
#ifdef HAVE_LFORTRAN_LLVM
#ifdef HAVE_LCOMPILERS_LLVM
std::string tmp_o = outfile + ".tmp.o";
err = compile_python_to_object_file(arg_file, tmp_o, runtime_library_dir,
lpython_pass_manager, compiler_options, time_report);
Expand Down
7 changes: 6 additions & 1 deletion src/libasr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ endif ()

if (NOT LFORTRAN_VERSION)
set(LFORTRAN_VERSION "0.1-git"
CACHE STRING "LFortran version" FORCE)
CACHE STRING "LCompilers version" FORCE)
endif ()

configure_file(config.h.in config.h)
Expand Down Expand Up @@ -75,6 +75,11 @@ set(SRC
serialization.cpp
utils2.cpp
)

if (WITH_WHEREAMI)
set(SRC ${SRC} ../bin/tpl/whereami/whereami.cpp)
endif()

if (WITH_LLVM)
set(SRC ${SRC}
codegen/evaluator.cpp
Expand Down
4 changes: 2 additions & 2 deletions src/libasr/alloc.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef LFORTRAN_PARSER_ALLOC_H
#define LFORTRAN_PARSER_ALLOC_H
#ifndef LIBASR_PARSER_ALLOC_H
#define LIBASR_PARSER_ALLOC_H

#include <algorithm>
#include <cstdlib>
Expand Down
6 changes: 3 additions & 3 deletions src/libasr/asdl_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2656,8 +2656,8 @@ def add_masks(fields, node):
self.optional_masks = optional_masks


HEAD = r"""#ifndef LFORTRAN_%(MOD2)s_H
#define LFORTRAN_%(MOD2)s_H
HEAD = r"""#ifndef LIBASR_%(MOD2)s_H
#define LIBASR_%(MOD2)s_H

// Generated by grammar/asdl_cpp.py

Expand Down Expand Up @@ -2714,7 +2714,7 @@ def add_masks(fields, node):

FOOT = r"""} // namespace LCompilers::%(MOD)s

#endif // LFORTRAN_%(MOD2)s_H
#endif // LIBASR_%(MOD2)s_H
"""

visitors = [ASTNodeVisitor0, ASTNodeVisitor1, ASTNodeVisitor,
Expand Down
6 changes: 3 additions & 3 deletions src/libasr/asr_scopes.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef LFORTRAN_SEMANTICS_ASR_SCOPES_H
#define LFORTRAN_SEMANTICS_ASR_SCOPES_H
#ifndef LIBASR_SEMANTICS_ASR_SCOPES_H
#define LIBASR_SEMANTICS_ASR_SCOPES_H

#include <map>

Expand Down Expand Up @@ -100,4 +100,4 @@ struct SymbolTable {

} // namespace LCompilers

#endif // LFORTRAN_SEMANTICS_ASR_SCOPES_H
#endif // LIBASR_SEMANTICS_ASR_SCOPES_H
6 changes: 3 additions & 3 deletions src/libasr/asr_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ ASR::Module_t* load_module(Allocator &al, SymbolTable *symtab,
PassUtils::UpdateDependenciesVisitor v(al);
v.visit_TranslationUnit(*tu);
if (run_verify) {
#if defined(WITH_LFORTRAN_ASSERT)
#if defined(WITH_LCOMPILERS_ASSERT)
diag::Diagnostics diagnostics;
if (!asr_verify(*tu, true, diagnostics)) {
std::cerr << diagnostics.render2();
Expand Down Expand Up @@ -618,7 +618,7 @@ bool use_overloaded(ASR::expr_t* left, ASR::expr_t* right,
}
if (ASRUtils::symbol_parent_symtab(a_name)->get_counter() != curr_scope->get_counter()) {
ADD_ASR_DEPENDENCIES_WITH_NAME(curr_scope, a_name, current_function_dependencies, s2c(al, matched_func_name));
}
}
ASRUtils::insert_module_dependency(a_name, al, current_module_dependencies);
ASRUtils::set_absent_optional_arguments_to_null(a_args, func, al);
asr = ASRUtils::make_FunctionCall_t_util(al, loc, a_name, sym,
Expand Down Expand Up @@ -703,7 +703,7 @@ void process_overloaded_unary_minus_function(ASR::symbol_t* proc, ASR::expr_t* o
}
if (ASRUtils::symbol_parent_symtab(a_name)->get_counter() != curr_scope->get_counter()) {
ADD_ASR_DEPENDENCIES_WITH_NAME(curr_scope, a_name, current_function_dependencies, s2c(al, matched_func_name));
}
}
ASRUtils::insert_module_dependency(a_name, al, current_module_dependencies);
ASRUtils::set_absent_optional_arguments_to_null(a_args, func, al);
asr = ASRUtils::make_FunctionCall_t_util(al, loc, a_name, proc,
Expand Down
6 changes: 3 additions & 3 deletions src/libasr/asr_utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef LFORTRAN_ASR_UTILS_H
#define LFORTRAN_ASR_UTILS_H
#ifndef LIBASR_ASR_UTILS_H
#define LIBASR_ASR_UTILS_H

#include <functional>
#include <map>
Expand Down Expand Up @@ -4633,4 +4633,4 @@ inline ASR::ttype_t* make_Pointer_t_util(Allocator& al, const Location& loc, ASR

} // namespace LCompilers

#endif // LFORTRAN_ASR_UTILS_H
#endif // LIBASR_ASR_UTILS_H
4 changes: 2 additions & 2 deletions src/libasr/asr_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
}

SymbolTable* temp_scope = current_symtab;

if (temp_scope->get_counter() != ASRUtils::symbol_parent_symtab(x.m_name)->get_counter() &&
!ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) && !ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name) &&
!ASR::is_a<ASR::Variable_t>(*x.m_name)) {
Expand Down Expand Up @@ -1035,7 +1035,7 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
}

SymbolTable* temp_scope = current_symtab;

if (asr_owner_sym && temp_scope->get_counter() != ASRUtils::symbol_parent_symtab(x.m_name)->get_counter() &&
!ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) && !ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name) &&
!ASR::is_a<ASR::Variable_t>(*x.m_name)) {
Expand Down
6 changes: 3 additions & 3 deletions src/libasr/asr_verify.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef LFORTRAN_ASR_VERIFY_H
#define LFORTRAN_ASR_VERIFY_H
#ifndef LIBASR_ASR_VERIFY_H
#define LIBASR_ASR_VERIFY_H

#include <libasr/asr.h>

Expand Down Expand Up @@ -40,4 +40,4 @@ namespace LCompilers {

} // namespace LCompilers

#endif // LFORTRAN_ASR_VERIFY_H
#endif // LIBASR_ASR_VERIFY_H
Loading
Loading