solana-labs / solana

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
https://solanalabs.com
Apache License 2.0
13.02k stars 4.19k forks source link

bpf-tools/llvm/bin/ld.lld: not found when build c-project #21085

Closed workivan closed 2 years ago

workivan commented 2 years ago

Problem

I am trying to build a c-project on Ubuntu 18.04 according to the instructions on the website, but I get an error

[lld] build/main.so () /home/ivan/.local/share/solana/solana-release/bin/sdk/bpf/c/bpf.mk:214: recipe for target 'build/main.so' failed /bin/sh: 1: /home/ivan/.local/share/solana/solana-release/bin/sdk/bpf/c/../dependencies/bpf-tools/llvm/bin/ld.lld: not found at the same time, the installation was completed successfully and rust was installed too

Proposed Solution

my attempts to install llvm, clang and lld were successful but it did not become a solution and the error did not change

my make file OUT_DIR := build include ~/.local/share/solana/solana-release/bin/sdk/bpf/c/bpf.mk Can you help me ?

dmakarov commented 2 years ago

Can you change the include line in your makefile to

include ~/.local/share/solana/install/active_release/bin/sdk/bpf/c/bpf.mk

and try to build your project again?

workivan commented 2 years ago

@dmakarov, no, changing to the path you suggested leads to the same error

I tried to build solana from sources on two ubuntu machines: on one failed when compiling the 858th package, and on the second (on a clean one) during compilation of the 830th package with the same error

error: linking with cc failed: exit status:

I won't post the full stacktrace - it's huge

= note: collect2: fatal error: ld terminated with signal 9 [Killed] compilation terminated.
error: could not compile solana-watchtower due to previous error

trying to rebuild didn't help at all :( maybe I didn't install some dependencies not listed in the README.txt ?

dmakarov commented 2 years ago

Is the machine you're building on a virtual machine? How much RAM does it have? ld terminated with signal 9 [Killed] compilation terminated. usually means that linker ran out of memory.

workivan commented 2 years ago

@dmakarov 8 gb ((

dmakarov commented 2 years ago

At least you don't see the error that ld.lld is not found anymore? Maybe you can try to set the environment variable CARGO_BUILD_JOBS=1 and see if that helps. With this setting the build will be slower, but there will be only one job running at a time and 8G may be sufficient.

workivan commented 2 years ago

@dmakarov, unfortunately, this did not become a solution (( I want to add that RAM is not loaded during compilation of all packages except the latest ones

error that ld.lld is not found I still encounter

workivan commented 2 years ago

@dmakarov, good evening I tried to repeat the installation on windows: 1) successfully installed rust 2) installing solana using the tool also completed without errors, but the deps file is empty again and the attempt to run cargo-build-bpf ends as follows

Solana Rust BPF toolchain is not available on Windows

Can you tell me now, maybe this output is more understandable than the previous error ? waiting for your reply

dmakarov commented 2 years ago

Solana is not supported to run natively on Windows. Normally people use Windows Subsystem for Linux to run Solana or develop for Solana on Windows. Recently @joncinque made significant efforts to enable the Solana BPF toolchain to run natively on Windows. However it looks like cargo-build-bpf still does not work on Windows. The error that you're seeing is issued here https://github.com/solana-labs/solana/blob/1b46d1d54d275ece517a5525082450186a19e088/sdk/cargo-build-bpf/src/main.rs#L684 which means that cargo-build-bpf is not supposed to be run on Windows.

@joncinque should we remove this check https://github.com/solana-labs/solana/blob/1b46d1d54d275ece517a5525082450186a19e088/sdk/cargo-build-bpf/src/main.rs#L683-L686 and let corgo-build-bpf run natively on Windows?

joncinque commented 2 years ago

I have to update #20276 and get that working, then we can certainly have this working for windows!

workivan commented 2 years ago

thank you all for your help, in the end it turned out to solve the problem using the prebuilt version on pure ubuntu 20.04

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any activity in past 7 days after it was closed. Please open a new issue for related bugs.