Skip to content

Commit

Permalink
Fix build issue for libbeamhash on Ubuntu 22.04
Browse files Browse the repository at this point in the history
  • Loading branch information
ceedii committed Feb 7, 2025
1 parent 5bb86a0 commit b3bfff3
Show file tree
Hide file tree
Showing 16 changed files with 996 additions and 1,108 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy as BUILDER
WORKDIR /app
RUN apt-get update && \
apt-get -y install cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libzmq3-dev golang-go libgmp-dev libc++-dev
apt-get -y install cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libzmq3-dev golang-go libgmp-dev libc++-dev zlib1g-dev
COPY . .
WORKDIR /app/src/Miningcore
RUN dotnet publish -c Release --framework net6.0 -o ../../build
Expand Down
2 changes: 1 addition & 1 deletion build-debian-11.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rm packages-microsoft-prod.deb

# install dev-dependencies
sudo apt-get update; \
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5-dev libgmp-dev libc++-dev
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5-dev libgmp-dev libc++-dev zlib1g-dev

(cd src/Miningcore && \
BUILDIR=${1:-../../build} && \
Expand Down
2 changes: 1 addition & 1 deletion build-debian-12.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rm packages-microsoft-prod.deb

# install dev-dependencies
sudo apt-get update; \
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5-dev libgmp-dev libc++-dev
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5-dev libgmp-dev libc++-dev zlib1g-dev

(cd src/Miningcore && \
BUILDIR=${1:-../../build} && \
Expand Down
2 changes: 1 addition & 1 deletion build-ubuntu-20.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rm packages-microsoft-prod.deb

# install dev-dependencies
sudo apt-get update; \
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev libc++-dev
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev libc++-dev zlib1g-dev

(cd src/Miningcore && \
BUILDIR=${1:-../../build} && \
Expand Down
2 changes: 1 addition & 1 deletion build-ubuntu-21.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rm packages-microsoft-prod.deb

# install dev-dependencies
sudo apt-get update; \
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev libc++-dev
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev libc++-dev zlib1g-dev

(cd src/Miningcore && \
BUILDIR=${1:-../../build} && \
Expand Down
2 changes: 1 addition & 1 deletion build-ubuntu-22.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# install dev-dependencies
sudo apt-get update; \
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev libc++-dev
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev libc++-dev zlib1g-dev

(cd src/Miningcore && \
BUILDIR=${1:-../../build} && \
Expand Down
1 change: 1 addition & 0 deletions examples/handshake_pool.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"percentage": 1
}
],
"enableAsicBoost": true,
"blockRefreshInterval": 250,
"jobRebroadcastTimeout": 0,
"clientConnectionTimeout": 600,
Expand Down
55 changes: 28 additions & 27 deletions src/Native/libbeamhash/blake/blake2-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,68 +15,69 @@
#define __BLAKE2_CONFIG_H__

#if defined(_M_IX86_FP)
#if _M_IX86_FP == 2
#define HAVE_SSE2
#ifndef HAVE_AVX
#define HAVE_AVX
#endif
#endif
#if _M_IX86_FP == 2
#define HAVE_SSE2
#ifndef HAVE_AVX
#define HAVE_AVX
#endif
#endif
#elif defined(_M_AMD64) || defined(_M_X64)
#define HAVE_SSSE3
#define HAVE_SSSE3
#endif

// These don't work everywhere
#if defined(__SSE2__)
#define HAVE_SSE2
#if defined(__SSE2__)
#define HAVE_SSE2
#endif

#if defined(__SSSE3__)
#define HAVE_SSSE3
#define HAVE_SSSE3
#endif

#if defined(__SSE4_1__)
#define HAVE_SSE41
#define HAVE_SSE41
#endif

#if defined(__AVX__) || defined(__AVX2__)
#define HAVE_AVX
#define HAVE_AVX
#endif

#if defined(__XOP__)
#define HAVE_XOP
#define HAVE_XOP
#endif


#ifdef HAVE_AVX2
#ifndef HAVE_AVX
#define HAVE_AVX
#endif
#ifndef HAVE_AVX
#define HAVE_AVX
#endif
#endif

#ifdef HAVE_XOP
#ifndef HAVE_AVX
#define HAVE_AVX
#endif
#ifndef HAVE_AVX
#define HAVE_AVX
#endif
#endif

#ifdef HAVE_AVX
#ifndef HAVE_SSE41
#define HAVE_SSE41
#endif
#ifndef HAVE_SSE41
#define HAVE_SSE41
#endif
#endif

#ifdef HAVE_SSE41
#ifndef HAVE_SSSE3
#define HAVE_SSSE3
#endif
#ifndef HAVE_SSSE3
#define HAVE_SSSE3
#endif
#endif

#ifdef HAVE_SSSE3
#define HAVE_SSE2
#define HAVE_SSE2
#endif

#if !defined(HAVE_SSE2)
#error "This code requires at least SSE2."
#error "This code requires at least SSE2."
#endif

#endif

162 changes: 75 additions & 87 deletions src/Native/libbeamhash/blake/blake2-impl.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/*
BLAKE2 reference source code package - optimized C implementations
Written in 2012 by Samuel Neves <[email protected]>
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with
this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
Expand All @@ -13,136 +16,121 @@

#include <stdint.h>

static inline uint32_t load32(const void* src)
static inline uint32_t load32( const void *src )
{
#if defined(NATIVE_LITTLE_ENDIAN)
uint32_t w;
memcpy(&w, src, sizeof w);
return w;
uint32_t w;
memcpy(&w, src, sizeof w);
return w;
#else
const uint8_t* p = (const uint8_t*)src;
uint32_t w = *p++;
w |= (uint32_t)(*p++) << 8;
w |= (uint32_t)(*p++) << 16;
w |= (uint32_t)(*p++) << 24;
return w;
const uint8_t *p = ( const uint8_t * )src;
uint32_t w = *p++;
w |= ( uint32_t )( *p++ ) << 8;
w |= ( uint32_t )( *p++ ) << 16;
w |= ( uint32_t )( *p++ ) << 24;
return w;
#endif
}

static inline uint64_t load64(const void* src)
static inline uint64_t load64( const void *src )
{
#if defined(NATIVE_LITTLE_ENDIAN)
uint64_t w;
memcpy(&w, src, sizeof w);
return w;
uint64_t w;
memcpy(&w, src, sizeof w);
return w;
#else
const uint8_t* p = (const uint8_t*)src;
uint64_t w = *p++;
w |= (uint64_t)(*p++) << 8;
w |= (uint64_t)(*p++) << 16;
w |= (uint64_t)(*p++) << 24;
w |= (uint64_t)(*p++) << 32;
w |= (uint64_t)(*p++) << 40;
w |= (uint64_t)(*p++) << 48;
w |= (uint64_t)(*p++) << 56;
return w;
const uint8_t *p = ( const uint8_t * )src;
uint64_t w = *p++;
w |= ( uint64_t )( *p++ ) << 8;
w |= ( uint64_t )( *p++ ) << 16;
w |= ( uint64_t )( *p++ ) << 24;
w |= ( uint64_t )( *p++ ) << 32;
w |= ( uint64_t )( *p++ ) << 40;
w |= ( uint64_t )( *p++ ) << 48;
w |= ( uint64_t )( *p++ ) << 56;
return w;
#endif
}

static inline void store32(void* dst, uint32_t w)
static inline void store32( void *dst, uint32_t w )
{
#if defined(NATIVE_LITTLE_ENDIAN)
memcpy(dst, &w, sizeof w);
memcpy(dst, &w, sizeof w);
#else
uint8_t* p = (uint8_t*)dst;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
uint8_t *p = ( uint8_t * )dst;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w;
#endif
}

static inline void store64(void* dst, uint64_t w)
static inline void store64( void *dst, uint64_t w )
{
#if defined(NATIVE_LITTLE_ENDIAN)
memcpy(dst, &w, sizeof w);
memcpy(dst, &w, sizeof w);
#else
uint8_t* p = (uint8_t*)dst;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
uint8_t *p = ( uint8_t * )dst;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w;
#endif
}

static inline uint64_t load48(const void* src)
static inline uint64_t load48( const void *src )
{
const uint8_t* p = (const uint8_t*)src;
uint64_t w = *p++;
w |= (uint64_t)(*p++) << 8;
w |= (uint64_t)(*p++) << 16;
w |= (uint64_t)(*p++) << 24;
w |= (uint64_t)(*p++) << 32;
w |= (uint64_t)(*p++) << 40;
return w;
const uint8_t *p = ( const uint8_t * )src;
uint64_t w = *p++;
w |= ( uint64_t )( *p++ ) << 8;
w |= ( uint64_t )( *p++ ) << 16;
w |= ( uint64_t )( *p++ ) << 24;
w |= ( uint64_t )( *p++ ) << 32;
w |= ( uint64_t )( *p++ ) << 40;
return w;
}

static inline void store48(void* dst, uint64_t w)
static inline void store48( void *dst, uint64_t w )
{
uint8_t* p = (uint8_t*)dst;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
w >>= 8;
*p++ = (uint8_t)w;
uint8_t *p = ( uint8_t * )dst;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w; w >>= 8;
*p++ = ( uint8_t )w;
}

static inline uint32_t rotl32(const uint32_t w, const unsigned c)
static inline uint32_t rotl32( const uint32_t w, const unsigned c )
{
return (w << c) | (w >> (32 - c));
return ( w << c ) | ( w >> ( 32 - c ) );
}

static inline uint64_t rotl64(const uint64_t w, const unsigned c)
static inline uint64_t rotl64( const uint64_t w, const unsigned c )
{
return (w << c) | (w >> (64 - c));
return ( w << c ) | ( w >> ( 64 - c ) );
}

static inline uint32_t rotr32(const uint32_t w, const unsigned c)
static inline uint32_t rotr32( const uint32_t w, const unsigned c )
{
return (w >> c) | (w << (32 - c));
return ( w >> c ) | ( w << ( 32 - c ) );
}

static inline uint64_t rotr64(const uint64_t w, const unsigned c)
static inline uint64_t rotr64( const uint64_t w, const unsigned c )
{
return (w >> c) | (w << (64 - c));
return ( w >> c ) | ( w << ( 64 - c ) );
}

/* prevents compiler optimizing out memset() */
static inline void secure_zero_memory(void* v, size_t n)
static inline void secure_zero_memory( void *v, size_t n )
{
volatile uint8_t* p = (volatile uint8_t*)v;
while (n--)
*p++ = 0;
volatile uint8_t *p = ( volatile uint8_t * )v;
while( n-- ) *p++ = 0;
}

#endif
#endif

Loading

0 comments on commit b3bfff3

Please sign in to comment.