From 6967f8e660013f640fbfa59191433f417f131b1f Mon Sep 17 00:00:00 2001 From: anutosh491 Date: Thu, 20 Jul 2023 11:09:01 +0530 Subject: [PATCH 1/2] Added the llvm_sym backend --- .github/workflows/CI.yml | 4 ++-- integration_tests/CMakeLists.txt | 23 ++++++++++++++++++++++- integration_tests/run_tests.py | 4 ++-- src/bin/lpython.cpp | 6 ++++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7f282a8a14..74e20ea76a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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 diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 617e964973..98d78b08c0 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -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 @@ -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) diff --git a/integration_tests/run_tests.py b/integration_tests/run_tests.py index 66011f3a67..804380e4b9 100755 --- a/integration_tests/run_tests.py +++ b/integration_tests/run_tests.py @@ -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" @@ -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) diff --git a/src/bin/lpython.cpp b/src/bin/lpython.cpp index f9f1c5f3e5..3f744d9bf5 100644 --- a/src/bin/lpython.cpp +++ b/src/bin/lpython.cpp @@ -1218,8 +1218,14 @@ int link_executable(const std::vector &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; From 6dd12298e043f2b1482dafbb6de7d0ff5ee90fe4 Mon Sep 17 00:00:00 2001 From: anutosh491 Date: Thu, 20 Jul 2023 12:09:54 +0530 Subject: [PATCH 2/2] disabled fast flag for now --- integration_tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 98d78b08c0..7e2be504a5 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -645,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 llvm_sym) +RUN(NAME symbolics_07 LABELS cpython_sym c_sym llvm_sym NOFAST) RUN(NAME sizeof_01 LABELS llvm c EXTRAFILES sizeof_01b.c)