fix debian build

pull/66/head
Jeff Becker 6 years ago
parent 3298cd549a
commit 9db99d4d04
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -69,6 +69,12 @@
"variant": "cpp",
"any": "cpp",
"tuntap.h": "c",
"hashtable": "cpp"
"hashtable": "cpp",
"crypto_stream_salsa20.h": "c",
"implementations.h": "c",
"stream_salsa20.h": "c",
"salsa20_xmm6int-sse2.h": "c",
"salsa20_ref.h": "c",
"salsa20_xmm6int-avx2.h": "c"
}
}

@ -82,8 +82,10 @@ if(TESTNET)
add_definitions(-DTESTNET=1)
endif()
if(NOT DEBIAN)
set(OPTIMIZE_FLAGS -O3)
set(DEBUG_FLAGS -O0 -g3)
endif()
if(ASAN)
set(DEBUG_FLAGS "${DEBUG_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
@ -113,6 +115,7 @@ if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
add_compile_options( ${DEBUG_FLAGS} )
endif()
if(NOT DEBIAN)
if(NOT ANDROID)
if (NOT USE_AVX2)
set(CRYPTO_FLAGS -march=core2 -mtune=native)
@ -122,6 +125,7 @@ set(CRYPTO_FLAGS -march=haswell -mtune=native)
set(CMAKE_ASM_FLAGS "-march=haswell -mtune=native ${CMAKE_ASM_FLAGS} $ENV{ASFLAGS}")
endif()
endif()
endif()
if(RPI)
add_definitions(-DRPI)

@ -5,8 +5,7 @@ SIGN = gpg --sign --detach
REPO := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
DESTDIR ?= /usr/local
PREFIX = $(DESTDIR)
prefix = $(DESTDIR)/usr/local
CC ?= cc
CXX ?= c++
@ -53,8 +52,6 @@ RPI ?= OFF
STATIC_LINK ?= OFF
CMAKE_GEN ?= Unix Makefiles
INSTALL = install -m 755
BUILD_ROOT = $(REPO)/build
CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DSTATIC_LINK=$(STATIC_LINK) -DUSE_AVX2=$(AVX2) -DUSE_CXX17=$(CXX17) -DUSE_LIBABYSS=$(JSONRPC) -DRPI=$(RPI) '$(REPO)'")
@ -206,15 +203,20 @@ debian-configure:
debian: debian-configure
$(MAKE) -C '$(BUILD_ROOT)'
cp $(BUILD_ROOT)/lokinet lokinet
cp $(EXE) lokinet
cp $(BUILD_ROOT)/rcutil lokinet-rcutil
install:
$(INSTALL) $(EXE) $(PREFIX)
$(INSTALL) $(REPO)/lokinet-bootstrap $(PREFIX)
debian-test:
$(TEST_EXE)
install-bins:
install -T $(EXE) $(prefix)/bin/lokinet
install -T $(REPO)/lokinet-bootstrap $(prefix)/bin/lokinet-bootstrap
setcap:
$(SETCAP) $(PREFIX)/bin/lokinet || true
install-setcap: install-bins
$(SETCAP) $(prefix)/bin/lokinet || true
install: install-setcap
fuzz-configure: clean
cmake -GNinja -DCMAKE_BUILD_TYPE=Fuzz -DCMAKE_C_COMPILER=afl-gcc -DCMAKE_CXX_COMPILER=afl-g++
@ -224,3 +226,5 @@ fuzz-build: fuzz-configure
fuzz: fuzz-build
$(EXE)
.PHONY: debian-install

@ -48,7 +48,7 @@ sodium_init(void)
{
return -1; /* LCOV_EXCL_LINE */
}
return 0;
return initialized ? 0 : -1;
}
#ifdef _WIN32

@ -9,7 +9,7 @@
#include "xmm6int/salsa20_xmm6int-sse2.h"
#include "xmm6int/salsa20_xmm6int-avx2.h"
static const crypto_stream_salsa20_implementation *implementation;
static crypto_stream_salsa20_implementation *implementation = NULL;
size_t
crypto_stream_salsa20_keybytes(void)
@ -33,6 +33,7 @@ int
crypto_stream_salsa20(unsigned char *c, unsigned long long clen,
const unsigned char *n, const unsigned char *k)
{
_crypto_stream_salsa20_pick_best_implementation();
return implementation->stream(c, clen, n, k);
}
@ -41,6 +42,7 @@ crypto_stream_salsa20_xor_ic(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
uint64_t ic, const unsigned char *k)
{
_crypto_stream_salsa20_pick_best_implementation();
return implementation->stream_xor_ic(c, m, mlen, n, ic, k);
}
@ -49,6 +51,7 @@ crypto_stream_salsa20_xor(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
const unsigned char *k)
{
_crypto_stream_salsa20_pick_best_implementation();
return implementation->stream_xor_ic(c, m, mlen, n, 0U, k);
}
@ -61,12 +64,8 @@ crypto_stream_salsa20_keygen(unsigned char k[crypto_stream_salsa20_KEYBYTES])
int
_crypto_stream_salsa20_pick_best_implementation(void)
{
#if __AVX2__ && __amd64__
implementation = &crypto_stream_salsa20_xmm6_implementation;
#else
implementation = &crypto_stream_salsa20_ref_implementation;
#endif
if(implementation)
return 0;
#if __AVX2__
if(sodium_runtime_has_avx2())
{
@ -81,5 +80,7 @@ _crypto_stream_salsa20_pick_best_implementation(void)
return 0;
}
#endif
if(implementation == NULL)
implementation = &crypto_stream_salsa20_ref_implementation;
return 0; /* LCOV_EXCL_LINE */
}

@ -8,7 +8,7 @@
#include <sodium/private/sse2_64_32.h>
#include <sodium/utils.h>
#if __AVX2__
#if __AVX2__ && __amd64__
#ifdef __GNUC__
#pragma GCC target("sse2")
@ -24,15 +24,17 @@
#ifndef __amd64__
#ifdef __clang__
#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse2")))
#define __DEFAULT_FN_ATTRS \
__attribute__((__always_inline__, __nodebug__, __target__("sse2")))
#else
#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __target__("sse2")))
#define __DEFAULT_FN_ATTRS \
__attribute__((__always_inline__, __target__("sse2")))
#endif
static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_cvtsi64_si128(long long __a)
{
return (__m128i){ __a, 0 };
return (__m128i){__a, 0};
}
#endif

6
debian/rules vendored

@ -19,3 +19,9 @@ endif
override_dh_auto_build:
$(MAKE) debian
override_dh_auto_test:
$(MAKE) debian-test
override_dh_auto_install:
$(MAKE) debian-install

@ -178,7 +178,7 @@ namespace llarp
void
llarp_crypto_init(struct llarp_crypto *c)
{
assert(sodium_init() != -1);
assert(sodium_init() == 0);
char *avx2 = getenv("AVX2_FORCE_DISABLE");
if(avx2 && std::string(avx2) == "1")
ntru_init(1);

Loading…
Cancel
Save