Skip to content

Commit

Permalink
Added the llvm_sym backend
Browse files Browse the repository at this point in the history
  • Loading branch information
anutosh491 authored and certik committed Jul 21, 2023
1 parent 45c05ee commit 6967f8e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -441,5 +441,5 @@ jobs:
shell: bash -e -l {0}
run: |
cd integration_tests
./run_tests.py -b c_sym cpython_sym
./run_tests.py -b c_sym cpython_sym -f
./run_tests.py -b c_sym cpython_sym llvm_sym
./run_tests.py -b c_sym cpython_sym llvm_sym -f
23 changes: 22 additions & 1 deletion integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXT
if (${fail})
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
endif()
elseif(KIND STREQUAL "llvm_sym")
add_custom_command(
OUTPUT ${name}.o
COMMAND ${LPYTHON} -c ${extra_args} ${CMAKE_CURRENT_SOURCE_DIR}/${file_name}.py -o ${name}.o
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file_name}.py
VERBATIM)
add_executable(${name} ${name}.o ${extra_files})
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE C)
if (APPLE)
set(SYMENGINE_LIB "${Python_LIBRARY_DIRS}/libsymengine.dylib")
else()
set(SYMENGINE_LIB "${Python_LIBRARY_DIRS}/libsymengine.so")
endif()
target_link_libraries(${name} lpython_rtlib ${SYMENGINE_LIB})
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
if (labels)
set_tests_properties(${name} PROPERTIES LABELS "${labels}")
endif()
if (${fail})
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
endif()
elseif(KIND STREQUAL "c")
add_custom_command(
OUTPUT ${name}.c
Expand Down Expand Up @@ -624,7 +645,7 @@ RUN(NAME symbolics_03 LABELS cpython_sym c_sym)
RUN(NAME symbolics_04 LABELS cpython_sym c_sym)
RUN(NAME symbolics_05 LABELS cpython_sym c_sym)
RUN(NAME symbolics_06 LABELS cpython_sym c_sym)
RUN(NAME symbolics_07 LABELS cpython_sym c_sym)
RUN(NAME symbolics_07 LABELS cpython_sym c_sym llvm_sym)

RUN(NAME sizeof_01 LABELS llvm c
EXTRAFILES sizeof_01b.c)
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Initialization
DEFAULT_THREADS_TO_USE = 8 # default no of threads is 8
SUPPORTED_BACKENDS = ['llvm', 'c', 'wasm', 'cpython', 'x86', 'wasm_x86', 'wasm_x64', 'c_py', 'c_sym', 'cpython_sym']
SUPPORTED_BACKENDS = ['llvm', 'c', 'wasm', 'cpython', 'x86', 'wasm_x86', 'wasm_x64', 'c_py', 'c_sym', 'cpython_sym', 'llvm_sym']
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
LPYTHON_PATH = f"{BASE_DIR}/../src/bin"

Expand Down Expand Up @@ -62,7 +62,7 @@ def main():
DEFAULT_THREADS_TO_USE = args.no_of_threads or DEFAULT_THREADS_TO_USE
fast_tests = "yes" if args.fast else "no"
for backend in args.backends:
python_libs_req = "yes" if backend in ["c_py", "c_sym"] else "no"
python_libs_req = "yes" if backend in ["c_py", "c_sym", "llvm_sym"] else "no"
test_backend(backend)


Expand Down
6 changes: 6 additions & 0 deletions src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,8 +1218,14 @@ int link_executable(const std::vector<std::string> &infiles,
for (auto &s : infiles) {
cmd += s + " ";
}
if (compiler_options.enable_symengine) {
cmd += " -I${CONDA_PREFIX}/include";
}
cmd += + " -L"
+ base_path + " -Wl,-rpath," + base_path + " -l" + runtime_lib + " -lm";
if (compiler_options.enable_symengine) {
cmd += " -L$CONDA_PREFIX/lib -Wl,-rpath -Wl,$CONDA_PREFIX/lib -lsymengine";
}
int err = system(cmd.c_str());
if (err) {
std::cout << "The command '" + cmd + "' failed." << std::endl;
Expand Down

0 comments on commit 6967f8e

Please sign in to comment.