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

enh: add LFortran as submodule with sparse checkout for src/libasr #2832

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Pranavchiku
Copy link
Collaborator

@Pranavchiku Pranavchiku commented Mar 26, 2025

These are the steps you have to follow (clone repository and checkout to this branch )

git clone --recursive https://github.com/lcompilers/lpython.git
cd lpython
gh pr checkout 2832
git submodule update --init --recursive
cd lfortran
git sparse-checkout init --cone
git sparse-checkout set src/libasr
git checkout HEAD
cd ../
% ./build0.sh 
+ ci/version.sh
++ git describe --tags --dirty
+ version=v0.22.0-64-gdf5fbf32e
+ version=0.22.0-64-gdf5fbf32e
+ echo 0.22.0-64-gdf5fbf32e
+ python grammar/asdl_py.py
Assuming default values of Python.asdl and python_ast.py
+ python src/libasr/asdl_cpp.py grammar/Python.asdl src/lpython/python_ast.h
+ python lfortran/src/libasr/asdl_cpp.py lfortran/src/libasr/ASR.asdl lfortran/src/libasr/asr.h
+ python lfortran/src/libasr/wasm_instructions_visitor.py
Assuming default values of wasm_instructions.txt and wasm_visitor.h
+ python lfortran/src/libasr/intrinsic_func_registry_util_gen.py
Assuming default values of intrinsic_function_registry_util.h
+ cd src/lpython/parser
+ re2c -W -b tokenizer.re -o tokenizer.cpp
+ cd src/lpython/parser
+ bison -Wall -d -r all parser.yy
./+ python -c 'file = '\''src/lpython/parser/parser.tab.cc'\''
with open(file, '\''r'\'') as f: text = f.read()
with open(file, '\''w'\'') as f:
    f.write('\''[[maybe_unused]] int yynerrs'\''.join(text.split('\''int yynerrs'\'')))'
+ grep -n ''\''' src/lpython/parser/parser.yy
+ echo OK
OK
% ./build1.sh 
++ pwd
+ cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_LLVM=yes -DLPYTHON_BUILD_ALL=yes -DWITH_STACKTRACE=yes -DWITH_RUNTIME_STACKTRACE=yes -DWITH_LSP=no -DWITH_LFORTRAN_BINARY_MODFILES=no '-DCMAKE_PREFIX_PATH=;/Users/pranavchiku/mambaforge/envs/lf' -DCMAKE_INSTALL_PREFIX=/Users/pranavchiku/repos/lpython/inst .
-- The C compiler identification is AppleClang 15.0.0.15000309
-- The CXX compiler identification is AppleClang 15.0.0.15000309
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /Users/pranavchiku/mambaforge/envs/lf/lib/libz.a (found version "1.3.1")
-- Found LLVM 11.1.0
-- Using LLVMConfig.cmake in: /Users/pranavchiku/mambaforge/envs/lf/lib/cmake/llvm
-- Found MACHO: /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include


Configuration results
---------------------
LPYTHON_VERSION: 0.22.0-64-gdf5fbf32e
CPACK_PACKAGE_FILE_NAME: lpython-0.22.0-64-gdf5fbf32e-Darwin
C compiler      : /Library/Developer/CommandLineTools/usr/bin/cc
C++ compiler    : /Library/Developer/CommandLineTools/usr/bin/c++
Build type: Debug
C compiler flags      : -g
C++ compiler flags    : -Wall -Wextra -g -ggdb
Installation prefix: /Users/pranavchiku/repos/lpython/inst
WITH_LFORTRAN_ASSERT: yes
LPYTHON_STATIC_BIN: no
LPYTHON_BUILD_TO_WASM: no
WITH_STACKTRACE: yes
WITH_RUNTIME_STACKTRACE: yes
WITH_UNWIND: yes
WITH_BFD: no
WITH_DWARFDUMP: yes
WITH_LINKH: no
WITH_MACHO: yes
HAVE_LFORTRAN_DEMANGLE: yes
WITH_LLVM: yes
WITH_XEUS: no
WITH_JSON: no
WITH_LSP: no
WITH_FMT: no
WITH_LFORTRAN_BINARY_MODFILES: no
WITH_RUNTIME_LIBRARY: YES
WITH_WHEREAMI: yes
WITH_ZLIB: yes
WITH_TARGET_AARCH64: yes
WITH_TARGET_X86: no
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/pranavchiku/repos/lpython
+ cmake --build . -j16 --target install
[  1%] Building CXX object libasr/CMakeFiles/lfortran_utils.dir/diagnostics.cpp.o
[  2%] Building CXX object libasr/CMakeFiles/lfortran_utils.dir/stacktrace.cpp.o
[  3%] Building CXX object libasr/CMakeFiles/lfortran_utils.dir/string_utils.cpp.o
[  4%] Building CXX object libasr/CMakeFiles/lfortran_utils.dir/utils2.cpp.o
[  5%] Building C object src/runtime/legacy/CMakeFiles/lpython_runtime.dir/__/__/libasr/runtime/lfortran_intrinsics.c.o
[  6%] Building CXX object src/tests/CMakeFiles/doctest.dir/doctest.cpp.o
[  7%] Building C object src/runtime/legacy/CMakeFiles/lpython_runtime_static.dir/__/__/libasr/runtime/lfortran_intrinsics.c.o
In file included from /Users/pranavchiku/repos/lpython/lfortran/src/libasr/diagnostics.cpp:1:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/iomanip:47:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/istream:164:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__iterator/istreambuf_iterator.h:15:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__iterator/iterator.h:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/cstddef:41:
/Users/pranavchiku/repos/lpython/libasr/../version:1:1: error: expected unqualified-id
0.22.0-64-gdf5fbf32e
^
In file included from /Users/pranavchiku/repos/lpython/lfortran/src/libasr/utils2.cpp:6:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/iostream:38:
/Users/pranavchiku/repos/lpython/libasr/../version:1:1: error: expected unqualified-id
0.22.0-64-gdf5fbf32e
^
In file included from /Users/pranavchiku/repos/lpython/lfortran/src/libasr/diagnostics.cpp:1:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/iomanip:47:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/istream:164:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__iterator/istreambuf_iterator.h:15:
/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__iterator/iterator.h:22:56: error: reference to unresolved using declaration
template<class _Category, class _Tp, class _Distance = ptrdiff_t,
                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/cstddef:60:1: note: using declaration annotated with 'using_if_exists' here
using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
^
In file included from /Users/pranavchiku/repos/lpython/lfortran/src/libasr/string_utils.cpp:2:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/regex:790:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__algorithm/find.h:13:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__algorithm/unwrap_iter.h:13:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__iterator/iterator_traits.h:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__concepts/constructible.h:12:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__concepts/convertible_to.h:13:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__type_traits/is_convertible.h:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/__type_traits/is_array.h:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/cstddef:41:
/Users/pranavchiku/repos/lpython/libasr/../version:1:1: error: expected unqualified-id
0.22.0-64-gdf5fbf32e
^
......

@certik
Copy link
Contributor

certik commented Mar 26, 2025

Instead of calling the directory lfortran, I wonder if we should just call it libasr. Because we are only caring about the src/libasr directory of LFortran, nothing else, and we do not care that the LFortran frontend is used to test it. Also, later if we wanted to extract just the src/libasr directory into a dedicated repository (without the rest of lfortran), then we can.

@assem2002
Copy link
Contributor

assem2002 commented Mar 27, 2025

Try

diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index be49aa179..c46f2893b 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -25,7 +25,6 @@ jobs:
       - uses: actions/checkout@v3
         with:
           fetch-depth: 0
-          submodules: true
 
       - name: Cache conda
         uses: actions/cache@v3

We will still have errors with the CI because of the sync issues, so #2827 needs to get merged first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants