-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Compile Lapack #1232
Comments
The cmake build system seems to be running some diagnostic Fortran compilation at the beginning to determine capabilities and it fails with LFortran (even wiht LAPACKE disabled with the patch above). It would be good to get things working so that one can just use their cmake build system. But if it is too much work, we can write our own build system, as the most important task is to get the actual Lapack Fortran files to compile and run correctly. Others can then help us get all the corner cases working with regards to the build system. |
Lfortran seems to pass the cmake tests now. |
For some reason cmake is not calling lfortran with --fixed-form, as lapack is a mix of 77 and 90 we get some errors. |
I'm working on adding support for lfortran on cmake, this should take care of these problems and #1538 |
I'm using |
I will work on implementing radix next, from what I understand it should always return 2. |
|
@meow464 can you post exact instructions? Here is what I tried on macOS: $ git clone https://github.com/Reference-LAPACK/lapack
$ cd lapack
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_Fortran_COMPILER=lfortran -DCBLAS=no -DLAPACKE=no -DBUILD_TESTING=no -DBUILD_DOUBLE=no -DBUILD_COMPLEX=no -DBUILD_COMPLEX16=no -DLAPACKE_WITH_TMG=no -DCMAKE_Fortran_PREPROCESS=yes -DCMAKE_Fortran_FLAGS="--fixed-form-infer --implicit-interface"
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- 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
-- Setting build type to 'Release' as none was specified.
-- Checking if build type is 'Coverage'
-- Checking if build type is 'Coverage': 0
-- Build tests: no
-- Build deprecated routines: OFF
-- Build single precision real: ON
-- Build double precision real: no
-- Build single precision complex: no
-- Build double precision complex: no
-- Using supplied NETLIB BLAS implementation
-- The Fortran compiler identification is unknown
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /Users/ondrej/bin/lfortran - skipped
CMake Warning at CMAKE/CheckLAPACKCompilerFlags.cmake:236 (message):
Fortran local arrays should be allocated on the stack. Please use a
compiler which guarantees that feature. See
https://github.com/Reference-LAPACK/lapack/pull/188 and references therein.
Call Stack (most recent call first):
BLAS/CMakeLists.txt:5 (CheckLAPACKCompilerFlags)
-- Using supplied NETLIB LAPACK implementation
CMake Warning at CMAKE/CheckLAPACKCompilerFlags.cmake:236 (message):
Fortran local arrays should be allocated on the stack. Please use a
compiler which guarantees that feature. See
https://github.com/Reference-LAPACK/lapack/pull/188 and references therein.
Call Stack (most recent call first):
CMakeLists.txt:322 (CheckLAPACKCompilerFlags)
-- Looking for Fortran NONE - not found
-- Looking for Fortran INT_CPU_TIME - not found
-- Looking for Fortran EXT_ETIME - not found
-- Looking for Fortran EXT_ETIME_ - not found
-- Looking for Fortran INT_ETIME - not found
-- --> Will use second_NONE.f and dsecnd_NONE.f as timing function.
-- Detecting Fortran/C Interface
Failed to compile
-- Verifying Fortran/C Compiler Compatibility
Failed to compile
CMake Warning (dev) at /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface.cmake:309 (message):
No FortranCInterface mangling known for VerifyFortran
Call Stack (most recent call first):
/Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface/Verify/CMakeLists.txt:16 (FortranCInterface_HEADER)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Verifying Fortran/C Compiler Compatibility - Failed
CMake Error at /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface.cmake:400 (message):
The Fortran compiler:
/Users/ondrej/bin/lfortran
and the C compiler:
/Library/Developer/CommandLineTools/usr/bin/cc
failed to compile a simple test project using both languages. The output
was:
Change Dir: /Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC
Run Build Command(s):/usr/bin/make -f Makefile VerifyFortranC && /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/bin/cmake -S/Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface/Verify -B/Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC --check-build-system CMakeFiles/Makefile.cmake 0
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/Makefile2 VerifyFortranC
/Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/bin/cmake -S/Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface/Verify -B/Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC --check-build-system CMakeFiles/Makefile.cmake 0
/Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/bin/cmake -E cmake_progress_start /Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC/CMakeFiles 5
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/Makefile2 CMakeFiles/VerifyFortranC.dir/all
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/VerifyFortran.dir/build.make CMakeFiles/VerifyFortran.dir/depend
cd /Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC && /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/bin/cmake -E cmake_depends "Unix Makefiles" /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface/Verify /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface/Verify /Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC /Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC /Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC/CMakeFiles/VerifyFortran.dir/DependInfo.cmake
Scanning dependencies of target VerifyFortran
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/VerifyFortran.dir/build.make CMakeFiles/VerifyFortran.dir/build
[ 20%] Building Fortran object CMakeFiles/VerifyFortran.dir/VerifyFortran.f.o
/Users/ondrej/bin/lfortran -I/Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC --fixed-form-infer --implicit-interface -c /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface/Verify/VerifyFortran.f -o CMakeFiles/VerifyFortran.dir/VerifyFortran.f.o
[ 40%] Linking Fortran static library libVerifyFortran.a
/Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/bin/cmake -P CMakeFiles/VerifyFortran.dir/cmake_clean_target.cmake
/Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/bin/cmake -E cmake_link_script CMakeFiles/VerifyFortran.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/ar qc libVerifyFortran.a CMakeFiles/VerifyFortran.dir/VerifyFortran.f.o
/Library/Developer/CommandLineTools/usr/bin/ranlib libVerifyFortran.a
warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: archive library: libVerifyFortran.a the table of contents is empty (no object file members in the library define global symbols)
[ 40%] Built target VerifyFortran
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/VerifyFortranC.dir/build.make CMakeFiles/VerifyFortranC.dir/depend
cd /Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC && /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/bin/cmake -E cmake_depends "Unix Makefiles" /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface/Verify /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface/Verify /Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC /Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC /Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC/CMakeFiles/VerifyFortranC.dir/DependInfo.cmake
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/VerifyFortranC.dir/build.make CMakeFiles/VerifyFortranC.dir/build
[ 60%] Building C object CMakeFiles/VerifyFortranC.dir/main.c.o
/Library/Developer/CommandLineTools/usr/bin/cc -I/Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -MD -MT CMakeFiles/VerifyFortranC.dir/main.c.o -MF CMakeFiles/VerifyFortranC.dir/main.c.o.d -o CMakeFiles/VerifyFortranC.dir/main.c.o -c /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface/Verify/main.c
[ 80%] Building C object CMakeFiles/VerifyFortranC.dir/VerifyC.c.o
/Library/Developer/CommandLineTools/usr/bin/cc -I/Users/ondrej/repos/lapack/build/CMakeFiles/FortranCInterface/VerifyC -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -MD -MT CMakeFiles/VerifyFortranC.dir/VerifyC.c.o -MF CMakeFiles/VerifyFortranC.dir/VerifyC.c.o.d -o CMakeFiles/VerifyFortranC.dir/VerifyC.c.o -c /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/share/cmake-3.23/Modules/FortranCInterface/Verify/VerifyC.c
[100%] Linking C executable VerifyFortranC
/Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/cmake-3.23.1-3geuicgdlylivqqft4pjwrdnmb63dfxr/bin/cmake -E cmake_link_script CMakeFiles/VerifyFortranC.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/cc -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/VerifyFortranC.dir/main.c.o CMakeFiles/VerifyFortranC.dir/VerifyC.c.o -o VerifyFortranC libVerifyFortran.a
Undefined symbols for architecture arm64:
"_VerifyFortran", referenced from:
_main in main.c.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [VerifyFortranC] Error 1
make[2]: *** [CMakeFiles/VerifyFortranC.dir/all] Error 2
make[1]: *** [CMakeFiles/VerifyFortranC.dir/rule] Error 2
make: *** [VerifyFortranC] Error 2
Call Stack (most recent call first):
LAPACKE/include/CMakeLists.txt:17 (FortranCInterface_VERIFY)
-- Configuring incomplete, errors occurred!
See also "/Users/ondrej/repos/lapack/build/CMakeFiles/CMakeOutput.log".
See also "/Users/ondrej/repos/lapack/build/CMakeFiles/CMakeError.log". |
I don't get that. Maybe because I'm on linux amd64? |
Yes, I think that's it. Can you post your full compilation log at https://gist.github.com/? I want to see how far it gets. |
I excluded two files from the compilation process because they use |
Ok, so it got to about 12%. That's not bad! I think the remaining issues will be relatively minor, we just have to implement all the intrinsic functions and compile time evaluation. |
Hopefully! I'm currently trying to implement fdefault-integer-8. |
I opened issue to implement |
Are there any resources from where we can see underlying mathematics to implement |
You can look at the definitions in the Fortran standard: https://www.fortran90.org/, or the GFortran documentation of these functions. |
The ifort documentation was the best resource I found. |
I'm still working on fdefault-integer-8, I expect to be finished in the following weeks. |
Perfect, thanks! |
@certik The error you were having is caused by the cmake check You can skip the error by commenting out:
In the top CMakeLists.txt. |
|
After removing some tests, it seems I am able to build I shared my build commands and outputs here https://github.com/Shaikh-Ubaid/lapack/blob/lf_01/LF_README.md. PS: I just tested building |
Great job. I think you built an empty library --- all the object files are empty. So you tested compiling to ASR, which succeeded, and that's great news. Now we need to test the LLVM backend. Use |
Here is how to get started:
With LFortran you can do:
I also had to apply the following patch:
The text was updated successfully, but these errors were encountered: