diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..0cfd2c52 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,79 @@ +name: Build Tnn-miner on Ubuntu 22.04 + +on: + push: + branches: + - '*dev*' + tags: + - "v*.*.*" + +jobs: + ubuntu-22: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: 'Update system' + run: | + sudo update-alternatives --display clang + sudo update-alternatives --display clang++ + sudo update-alternatives --list clang + sudo update-alternatives --list clang++ + sudo update-alternatives --get-selections + sudo apt update && sudo apt upgrade -y + - name: 'Setup pre-reqs' + run: | + sudo apt install git wget build-essential cmake clang libssl-dev libudns-dev libfmt-dev libc++-dev + #sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100 --slave /usr/bin/gcc gcc /usr/bin/gcc-10 + - name: 'Install clang 18' + run: | + version=18 + echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" | sudo tee /etc/apt/sources.list.d/clang.list + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc + sudo apt update + sudo apt install -y "clang-$version" "lldb-$version" "lld-$version" "clang-format-$version" "clang-tidy-$version" + - name: 'Update default clang' + run: | + version=18 + # https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/install-clang.sh#L17 + sudo update-alternatives --display clang++ + sudo update-alternatives --display clang + echo "Make Clang ${version} default" + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${version} 100 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${version} 100 + sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-${version} 100 + sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-${version} 100 + sudo update-alternatives --install /usr/bin/run-clang-tidy run-clang-tidy /usr/bin/run-clang-tidy-${version} 100 + sudo update-alternatives --set clang++ /usr/bin/clang++-${version} + sudo update-alternatives --set clang /usr/bin/clang-${version} + sudo update-alternatives --display clang++ + sudo update-alternatives --display clang + clang --version + clang++ --version + - name: 'Compile boost' + run: | + wget -q https://github.com/boostorg/boost/releases/download/boost-1.82.0/boost-1.82.0.tar.gz + tar -xf boost-1.82.0.tar.gz + cd boost-1.82.0/ + ./bootstrap.sh --with-toolset=clang + ./b2 clean + ./b2 toolset=clang cxxflags=-std=c++20 -stdlib=libc++ linkflags=-stdlib=libc++ link=static + - name: 'Compile Tnn-miner' + run: | + mkdir build + cd build + cmake .. + make -j$(nproc) + tar -zcvf ../tnn-miner.tar.gz Tnn-miner + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + make_latest: "true" + files: | + tnn-miner.tar.gz + - name: Archive tnn-miner.tar.gz + uses: actions/upload-artifact@v4 + with: + name: tnn-miner.tar.gz + path: ./tnn-miner.tar.gz + retention-days: 5 diff --git a/.gitignore b/.gitignore index 4d0e4df1..b1ccd01d 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ /cpp_modules /build /tests +/boost-1.82.0/** # Misc **.txt diff --git a/src/miner/miner.cpp b/src/miner/miner.cpp index 429a95e4..80b83180 100644 --- a/src/miner/miner.cpp +++ b/src/miner/miner.cpp @@ -435,15 +435,28 @@ int main(int argc, char **argv) bool lockThreads = true; devFee = 2.5; - po::options_description opts = get_prog_opts(); - int style = get_prog_style(); po::variables_map vm; - po::store(po::command_line_parser(argc, argv).options(opts).style(style).run(), vm); - po::notify(vm); + po::options_description opts = get_prog_opts(); + try { + int style = get_prog_style(); + po::store(po::command_line_parser(argc, argv).options(opts).style(style).run(), vm); + po::notify(vm); + } + catch(std::exception& e) + { + std::cerr << "Error: " << e.what() << "\n"; + std::cerr << "Remember: Long options now use a double-dash -- instead of a signle-dash -\n"; + return -1; + } + catch(...) + { + std::cerr << "Unknown error!" << "\n"; + return -1; + } if (vm.count("help")) { std::cout << opts << std::endl; - boost::this_thread::sleep_for(boost::chrono::seconds(5)); + boost::this_thread::sleep_for(boost::chrono::seconds(1)); return 0; } if (vm.count("sabench")) { @@ -474,14 +487,14 @@ int main(int argc, char **argv) printf("ERROR: dev fee must be at least %.2f", minFee); std::cout << "%" << std::endl; setcolor(BRIGHT_WHITE); - boost::this_thread::sleep_for(boost::chrono::seconds(5)); + boost::this_thread::sleep_for(boost::chrono::seconds(1)); return 1; } } catch (...) { printf("ERROR: invalid dev fee parameter... format should be for example '1.0'"); - boost::this_thread::sleep_for(boost::chrono::seconds(5)); + boost::this_thread::sleep_for(boost::chrono::seconds(1)); return 1; } } @@ -510,7 +523,7 @@ int main(int argc, char **argv) printf("Use Lookup\n"); useLookupMine = true; } - + // Ensure we capture *all* of the other options before we start using goto if (vm.count("test")) { goto Testing; @@ -614,7 +627,7 @@ int main(int argc, char **argv) TestAstroBWTv3(); // TestAstroBWTv3_cuda(); // TestAstroBWTv3repeattest(); - boost::this_thread::sleep_for(boost::chrono::seconds(30)); + boost::this_thread::sleep_for(boost::chrono::seconds(3)); return 0; } Benchmarking: