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

Unable to compile on machines with insufficient ram #143

Closed
cmkpl opened this issue Mar 13, 2018 · 13 comments
Closed

Unable to compile on machines with insufficient ram #143

cmkpl opened this issue Mar 13, 2018 · 13 comments

Comments

@cmkpl
Copy link

cmkpl commented Mar 13, 2018

I tried to compile tdlib by using the instructions, but I found that while compiling, it just consumes all of my ram and unable to proceed.

My machine has 4GB ram.

@arseny30
Copy link
Contributor

arseny30 commented Mar 13, 2018

Which compiler do you use?
You should try clang, especially if you are using g++.
And also may want to comment line 26 in CMakeLists.txt: https://github.com/tdlib/td/blob/master/CMakeLists.txt#L26, to disable link-time optimisations.

@cmkpl
Copy link
Author

cmkpl commented Mar 13, 2018

I used gcc. Let me try to switch to clang.

@cmkpl
Copy link
Author

cmkpl commented Mar 13, 2018

By using clang and clang++, it returns the following

$ cmake --build .
[  1%] Built target tdsqlite
[  2%] Built target generate_mime_types_gperf
[  3%] Built target tdmime_auto
[ 18%] Built target tdutils
[ 20%] Built target tdactor
[ 23%] Built target tddb
[ 25%] Built target tdtl
[ 26%] Linking CXX executable generate_common
../../tdtl/libtdtl.a: error adding symbols: Archive has no index; run ranlib to add one
clang: error: linker command failed with exit code 1 (use -v to see invocation)
td/generate/CMakeFiles/generate_common.dir/build.make:251: recipe for target 'td/generate/generate_common' failed
make[2]: *** [td/generate/generate_common] Error 1
CMakeFiles/Makefile2:809: recipe for target 'td/generate/CMakeFiles/generate_common.dir/all' failed
make[1]: *** [td/generate/CMakeFiles/generate_common.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

@levlam
Copy link
Contributor

levlam commented Mar 13, 2018

Have you removed build directory before switching to clang and rerun cmake from scratch?

@cmkpl
Copy link
Author

cmkpl commented Mar 13, 2018

yes, the folder "build" was recreated. Still has same error.

@levlam
Copy link
Contributor

levlam commented Mar 13, 2018

Could you show, how you invoked cmake to switch to clang++?

@cmkpl
Copy link
Author

cmkpl commented Mar 13, 2018

$ export CC=clang
$ export CXX=clang++

$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ cmake --build .

@levlam
Copy link
Contributor

levlam commented Mar 13, 2018

Could you try to use

cmake -D_CMAKE_TOOLCHAIN_PREFIX=llvm- -DCMAKE_BUILD_TYPE=Release ..

instead of

cmake -DCMAKE_BUILD_TYPE=Release ..

?

@cmkpl
Copy link
Author

cmkpl commented Mar 13, 2018

seems like even worse

$ cmake --build .
Scanning dependencies of target tdsqlite
[  1%] Building C object sqlite/CMakeFiles/tdsqlite.dir/sqlite/sqlite3.c.o
[  1%] Linking C static library libtdsqlite.a
Error running link command: No such file or directory
sqlite/CMakeFiles/tdsqlite.dir/build.make:94: recipe for target 'sqlite/libtdsqlite.a' failed
make[2]: *** [sqlite/libtdsqlite.a] Error 2
CMakeFiles/Makefile2:1122: recipe for target 'sqlite/CMakeFiles/tdsqlite.dir/all' failed
make[1]: *** [sqlite/CMakeFiles/tdsqlite.dir/all] Error 2
Makefile:128: recipe for target 'all' failed
make: *** [all] Error 2

@cmkpl
Copy link
Author

cmkpl commented Mar 13, 2018

$ cmake -D_CMAKE_TOOLCHAIN_PREFIX=llvm- -DCMAKE_BUILD_TYPE=Release ..
-- The CXX compiler identification is Clang 4.0.1
-- The C compiler identification is Clang 4.0.1
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Could NOT find ccache
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.0.2g")
-- Found OpenSSL: /usr/include /usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so
-- Performing Test HAVE_STD14
-- Performing Test HAVE_STD14 - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Performing Test HAVE_CXX_FLAG_WALL
-- Performing Test HAVE_CXX_FLAG_WALL - Success
-- Performing Test HAVE_CXX_FLAG_WEXTRA
-- Performing Test HAVE_CXX_FLAG_WEXTRA - Success
-- Performing Test HAVE_CXX_FLAG_WIMPLICIT_FALLTHROUGH_2
-- Performing Test HAVE_CXX_FLAG_WIMPLICIT_FALLTHROUGH_2 - Failed
-- Performing Test HAVE_CXX_FLAG_WPOINTER_ARITH
-- Performing Test HAVE_CXX_FLAG_WPOINTER_ARITH - Success
-- Performing Test HAVE_CXX_FLAG_WCAST_QUAL
-- Performing Test HAVE_CXX_FLAG_WCAST_QUAL - Success
-- Performing Test HAVE_CXX_FLAG_WSIGN_COMPARE
-- Performing Test HAVE_CXX_FLAG_WSIGN_COMPARE - Success
-- Performing Test HAVE_CXX_FLAG_WDUPLICATED_BRANCHES
-- Performing Test HAVE_CXX_FLAG_WDUPLICATED_BRANCHES - Failed
-- Performing Test HAVE_CXX_FLAG_WDUPLICATED_COND
-- Performing Test HAVE_CXX_FLAG_WDUPLICATED_COND - Failed
-- Performing Test HAVE_CXX_FLAG_WALLOC_ZERO
-- Performing Test HAVE_CXX_FLAG_WALLOC_ZERO - Failed
-- Performing Test HAVE_CXX_FLAG_WLOGICAL_OP
-- Performing Test HAVE_CXX_FLAG_WLOGICAL_OP - Failed
-- Performing Test HAVE_CXX_FLAG_WTAUTOLOGICAL_COMPARE
-- Performing Test HAVE_CXX_FLAG_WTAUTOLOGICAL_COMPARE - Success
-- Performing Test HAVE_CXX_FLAG_WVLA
-- Performing Test HAVE_CXX_FLAG_WVLA - Success
-- Performing Test HAVE_CXX_FLAG_WNON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_FLAG_WNON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_CXX_FLAG_WUNUSED_PARAMETER
-- Performing Test HAVE_CXX_FLAG_WUNUSED_PARAMETER - Success
-- Performing Test HAVE_CXX_FLAG_WCONVERSION
-- Performing Test HAVE_CXX_FLAG_WCONVERSION - Success
-- Performing Test HAVE_CXX_FLAG_WSIGN_CONVERSION
-- Performing Test HAVE_CXX_FLAG_WSIGN_CONVERSION - Success
-- Performing Test HAVE_CXX_FLAG_WCXX14_COMPAT_PEDANTIC
-- Performing Test HAVE_CXX_FLAG_WCXX14_COMPAT_PEDANTIC - Success
-- Performing Test HAVE_CXX_FLAG_QUNUSED_ARGUMENTS
-- Performing Test HAVE_CXX_FLAG_QUNUSED_ARGUMENTS - Success
-- Performing Test HAVE_CXX_FLAG_WODR
-- Performing Test HAVE_CXX_FLAG_WODR - Success
-- Performing Test HAVE_CXX_FLAG_FLTO_ODR_TYPE_MERGING
-- Performing Test HAVE_CXX_FLAG_FLTO_ODR_TYPE_MERGING - Failed
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- Found ZLIB: /usr/include /usr/lib/x86_64-linux-gnu/libz.so
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Performing Test GNU_READLINE_FOUND
-- Performing Test GNU_READLINE_FOUND - Success
-- Found Readline: /usr/include
-- Found Readline: /usr/include /usr/lib/x86_64-linux-gnu/libreadline.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/td/build

@levlam
Copy link
Contributor

levlam commented Mar 13, 2018

It looks like some binutils problem, but cmake invocations looks right for me.

If you are on Ubuntu you can try to switch to clang++ using this advice: https://stackoverflow.com/a/12843988.

@isopen
Copy link
Contributor

isopen commented Mar 14, 2018

apt install clang
CXX=clang++ CC=clang cmake ..
cmake --build . (the effect is the same as g ++)
#6
But you should try ninja.:)

In my opinion, global switching to clang is not the best plan. Perhaps it's worth setting limits on consumption of RAM at the level of the operating system.

When assembling jni. Cmake begins to eat strongly by 50%

@cmkpl
Copy link
Author

cmkpl commented Mar 14, 2018

It is compiled eventually by using the command @isopen provided. Thanks!

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

No branches or pull requests

4 participants