Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit 03aba6a

Browse files
authored
Merge pull request #3568 from ethereum/cleanups
Compiler flags cleanups
2 parents b1036cf + fc101bc commit 03aba6a

File tree

12 files changed

+10
-351
lines changed

12 files changed

+10
-351
lines changed

cmake/EthCompilerSettings.cmake

Lines changed: 9 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,21 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
4242
# TODO - Track down what breaks if we do NOT do this.
4343
add_compile_options(-Wno-unknown-pragmas)
4444

45-
# To get the code building on FreeBSD and Arch Linux we seem to need the following
46-
# warning suppression to work around some issues in Boost headers.
47-
#
48-
# See the following reports:
49-
# https://github.com/ethereum/webthree-umbrella/issues/384
50-
# https://github.com/ethereum/webthree-helpers/pull/170
51-
#
52-
# The issue manifest as warnings-as-errors like the following:
53-
#
54-
# /usr/local/include/boost/multiprecision/cpp_int.hpp:181:4: error:
55-
# right operand of shift expression '(1u << 63u)' is >= than the precision of the left operand
56-
#
57-
# -fpermissive is a pretty nasty way to address this. It is described as follows:
58-
#
59-
# Downgrade some diagnostics about nonconformant code from errors to warnings.
60-
# Thus, using -fpermissive will allow some nonconforming code to compile.
61-
#
62-
# NB: Have to use this form for the setting, so that it only applies to C++ builds.
63-
# Applying -fpermissive to a C command-line (ie. secp256k1) gives a build error.
64-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
65-
66-
# Build everything as shared libraries (.so files)
67-
add_definitions(-DSHAREDLIB)
68-
69-
# If supported for the target machine, emit position-independent code, suitable for dynamic
70-
# linking and avoiding any limit on the size of the global offset table.
71-
add_compile_options(-fPIC)
72-
7345
# Configuration-specific compiler settings.
7446
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -DETH_DEBUG")
7547
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG -DETH_RELEASE")
7648
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -DETH_RELEASE")
7749
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DETH_RELEASE")
7850

51+
option(USE_LD_GOLD "Use GNU gold linker" ON)
52+
if (USE_LD_GOLD)
53+
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
54+
if ("${LD_VERSION}" MATCHES "GNU gold")
55+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
56+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
57+
endif ()
58+
endif ()
59+
7960
# Additional GCC-specific compiler settings.
8061
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
8162

@@ -122,40 +103,14 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
122103
message(WARNING "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}")
123104
endif()
124105

125-
# A couple of extra warnings suppressions which we seemingly
126-
# need when building with Clang.
127-
#
128-
# TODO - Nail down exactly where these warnings are manifesting and
129-
# try to suppress them in a more localized way. Notes in this file
130-
# indicate that the first is needed for sepc256k1 and that the
131-
# second is needed for the (clog, cwarn) macros. These will need
132-
# testing on at least OS X and Ubuntu.
133-
add_compile_options(-Wno-unused-function)
134-
add_compile_options(-Wno-dangling-else)
135-
136106
# Some Linux-specific Clang settings. We don't want these for OS X.
137107
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
138108

139-
# TODO - Is this even necessary? Why?
140-
# See http://stackoverflow.com/questions/19774778/when-is-it-necessary-to-use-use-the-flag-stdlib-libstdc.
141-
add_compile_options(-stdlib=libstdc++)
142-
143109
# Tell Boost that we're using Clang's libc++. Not sure exactly why we need to do.
144110
add_definitions(-DBOOST_ASIO_HAS_CLANG_LIBCXX)
145111

146112
# Use fancy colors in the compiler diagnostics
147113
add_compile_options(-fcolor-diagnostics)
148-
149-
# See "How to silence unused command line argument error with clang without disabling it?"
150-
# When using -Werror with clang, it transforms "warning: argument unused during compilation" messages
151-
# into errors, which makes sense.
152-
# http://stackoverflow.com/questions/21617158/how-to-silence-unused-command-line-argument-error-with-clang-without-disabling-i
153-
add_compile_options(-Qunused-arguments)
154-
endif()
155-
156-
if (EMSCRIPTEN)
157-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --memory-init-file 0 -O3 -s LINKABLE=1 -s DISABLE_EXCEPTION_CATCHING=0 -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_DYNAMIC_EXECUTION=1")
158-
add_definitions(-DETH_EMSCRIPTEN=1)
159114
endif()
160115
endif()
161116

@@ -223,14 +178,3 @@ if (PROFILING AND (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")))
223178
set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS} -lprofiler")
224179
set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS} -lprofiler")
225180
endif ()
226-
227-
if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
228-
option(USE_LD_GOLD "Use GNU gold linker" ON)
229-
if (USE_LD_GOLD)
230-
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
231-
if ("${LD_VERSION}" MATCHES "GNU gold")
232-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold")
233-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
234-
endif ()
235-
endif ()
236-
endif ()

cmake/EthPolicy.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ macro (eth_policy)
99

1010
# CMake 2.8.12 and lower allowed the use of targets and files with double
1111
# colons in target_link_libraries,
12-
cmake_policy(SET CMP0028 OLD)
12+
cmake_policy(SET CMP0028 NEW)
1313

1414
if (${CMAKE_VERSION} VERSION_GREATER 3.0)
1515

libdevcore/Log.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
#ifdef __APPLE__
2828
#include <pthread.h>
2929
#endif
30-
#if !defined(ETH_EMSCRIPTEN)
31-
#include <boost/asio/ip/tcp.hpp>
32-
#endif
3330
#include "Guards.h"
3431
using namespace std;
3532
using namespace dev;
@@ -110,13 +107,6 @@ LogOutputStreamBase::LogOutputStreamBase(char const* _id, std::type_info const*
110107
}
111108
}
112109

113-
#if !defined(ETH_EMSCRIPTEN)
114-
void LogOutputStreamBase::append(boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> const& _t)
115-
{
116-
m_sstr << EthNavyUnder "tcp://" << _t << EthReset;
117-
}
118-
#endif
119-
120110
/// Associate a name with each thread for nice logging.
121111
struct ThreadLocalLogName
122112
{

libdevcore/Log.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ class LogOutputStreamBase
176176
void append(std::string const& _t) { m_sstr << EthGreen "\"" + _t + "\"" EthReset; }
177177
void append(bytes const& _t) { m_sstr << EthYellow "%" << toHex(_t) << EthReset; }
178178
void append(bytesConstRef _t) { m_sstr << EthYellow "%" << toHex(_t) << EthReset; }
179-
#if !defined(ETH_EMSCRIPTEN)
180-
void append(boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> const& _t);
181-
#endif
182179
template <class T> void append(std::vector<T> const& _t)
183180
{
184181
m_sstr << EthWhite "[" EthReset;

utils/secp256k1/field_5x52_impl.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,6 @@
3030
* output.
3131
*/
3232

33-
#ifdef VERIFY
34-
static void secp256k1_fe_verify(const secp256k1_fe_t *a) {
35-
const uint64_t *d = a->n;
36-
int m = a->normalized ? 1 : 2 * a->magnitude, r = 1;
37-
/* secp256k1 'p' value defined in "Standards for Efficient Cryptography" (SEC2) 2.7.1. */
38-
r &= (d[0] <= 0xFFFFFFFFFFFFFULL * m);
39-
r &= (d[1] <= 0xFFFFFFFFFFFFFULL * m);
40-
r &= (d[2] <= 0xFFFFFFFFFFFFFULL * m);
41-
r &= (d[3] <= 0xFFFFFFFFFFFFFULL * m);
42-
r &= (d[4] <= 0x0FFFFFFFFFFFFULL * m);
43-
r &= (a->magnitude >= 0);
44-
r &= (a->magnitude <= 2048);
45-
if (a->normalized) {
46-
r &= (a->magnitude <= 1);
47-
if (r && (d[4] == 0x0FFFFFFFFFFFFULL) && ((d[3] & d[2] & d[1]) == 0xFFFFFFFFFFFFFULL)) {
48-
r &= (d[0] < 0xFFFFEFFFFFC2FULL);
49-
}
50-
}
51-
VERIFY_CHECK(r == 1);
52-
}
53-
#else
54-
static void secp256k1_fe_verify(const secp256k1_fe_t *a) {
55-
(void)a;
56-
}
57-
#endif
58-
5933
static void secp256k1_fe_normalize(secp256k1_fe_t *r) {
6034
uint64_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4];
6135

utils/secp256k1/group.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ typedef struct {
3838

3939
#define SECP256K1_GE_STORAGE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {SECP256K1_FE_STORAGE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_STORAGE_CONST((i),(j),(k),(l),(m),(n),(o),(p))}
4040

41-
/** Set a group element equal to the point at infinity */
42-
static void secp256k1_ge_set_infinity(secp256k1_ge_t *r);
43-
4441
/** Set a group element equal to the point with given X and Y coordinates */
4542
static void secp256k1_ge_set_xy(secp256k1_ge_t *r, const secp256k1_fe_t *x, const secp256k1_fe_t *y);
4643

@@ -66,9 +63,6 @@ static void secp256k1_ge_set_all_gej_var(size_t len, secp256k1_ge_t *r, const se
6663
/** Set a group element (jacobian) equal to the point at infinity. */
6764
static void secp256k1_gej_set_infinity(secp256k1_gej_t *r);
6865

69-
/** Set a group element (jacobian) equal to the point with given X and Y coordinates. */
70-
static void secp256k1_gej_set_xy(secp256k1_gej_t *r, const secp256k1_fe_t *x, const secp256k1_fe_t *y);
71-
7266
/** Set a group element (jacobian) equal to another which is given in affine coordinates. */
7367
static void secp256k1_gej_set_ge(secp256k1_gej_t *r, const secp256k1_ge_t *a);
7468

utils/secp256k1/group_impl.h

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ static const secp256k1_ge_t secp256k1_ge_const_g = SECP256K1_GE_CONST(
2323
0xFD17B448UL, 0xA6855419UL, 0x9C47D08FUL, 0xFB10D4B8UL
2424
);
2525

26-
static void secp256k1_ge_set_infinity(secp256k1_ge_t *r) {
27-
r->infinity = 1;
28-
}
29-
3026
static void secp256k1_ge_set_xy(secp256k1_ge_t *r, const secp256k1_fe_t *x, const secp256k1_fe_t *y) {
3127
r->infinity = 0;
3228
r->x = *x;
@@ -110,13 +106,6 @@ static void secp256k1_gej_set_infinity(secp256k1_gej_t *r) {
110106
secp256k1_fe_set_int(&r->z, 0);
111107
}
112108

113-
static void secp256k1_gej_set_xy(secp256k1_gej_t *r, const secp256k1_fe_t *x, const secp256k1_fe_t *y) {
114-
r->infinity = 0;
115-
r->x = *x;
116-
r->y = *y;
117-
secp256k1_fe_set_int(&r->z, 1);
118-
}
119-
120109
static void secp256k1_gej_clear(secp256k1_gej_t *r) {
121110
r->infinity = 0;
122111
secp256k1_fe_clear(&r->x);
@@ -176,26 +165,6 @@ static int secp256k1_gej_is_infinity(const secp256k1_gej_t *a) {
176165
return a->infinity;
177166
}
178167

179-
static int secp256k1_gej_is_valid_var(const secp256k1_gej_t *a) {
180-
secp256k1_fe_t y2, x3, z2, z6;
181-
if (a->infinity) {
182-
return 0;
183-
}
184-
/** y^2 = x^3 + 7
185-
* (Y/Z^3)^2 = (X/Z^2)^3 + 7
186-
* Y^2 / Z^6 = X^3 / Z^6 + 7
187-
* Y^2 = X^3 + 7*Z^6
188-
*/
189-
secp256k1_fe_sqr(&y2, &a->y);
190-
secp256k1_fe_sqr(&x3, &a->x); secp256k1_fe_mul(&x3, &x3, &a->x);
191-
secp256k1_fe_sqr(&z2, &a->z);
192-
secp256k1_fe_sqr(&z6, &z2); secp256k1_fe_mul(&z6, &z6, &z2);
193-
secp256k1_fe_mul_int(&z6, 7);
194-
secp256k1_fe_add(&x3, &z6);
195-
secp256k1_fe_normalize_weak(&x3);
196-
return secp256k1_fe_equal_var(&y2, &x3);
197-
}
198-
199168
static int secp256k1_ge_is_valid_var(const secp256k1_ge_t *a) {
200169
secp256k1_fe_t y2, x3, c;
201170
if (a->infinity) {

utils/secp256k1/num.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
#error "Please select num implementation"
2020
#endif
2121

22-
/** Copy a number. */
23-
static void secp256k1_num_copy(secp256k1_num_t *r, const secp256k1_num_t *a);
24-
2522
/** Convert a number's absolute value to a binary big-endian string.
2623
* There must be enough place. */
2724
static void secp256k1_num_get_bin(unsigned char *r, unsigned int rlen, const secp256k1_num_t *a);
@@ -32,37 +29,6 @@ static void secp256k1_num_set_bin(secp256k1_num_t *r, const unsigned char *a, un
3229
/** Compute a modular inverse. The input must be less than the modulus. */
3330
static void secp256k1_num_mod_inverse(secp256k1_num_t *r, const secp256k1_num_t *a, const secp256k1_num_t *m);
3431

35-
/** Compare the absolute value of two numbers. */
36-
static int secp256k1_num_cmp(const secp256k1_num_t *a, const secp256k1_num_t *b);
37-
38-
/** Test whether two number are equal (including sign). */
39-
static int secp256k1_num_eq(const secp256k1_num_t *a, const secp256k1_num_t *b);
40-
41-
/** Add two (signed) numbers. */
42-
static void secp256k1_num_add(secp256k1_num_t *r, const secp256k1_num_t *a, const secp256k1_num_t *b);
43-
44-
/** Subtract two (signed) numbers. */
45-
static void secp256k1_num_sub(secp256k1_num_t *r, const secp256k1_num_t *a, const secp256k1_num_t *b);
46-
47-
/** Multiply two (signed) numbers. */
48-
static void secp256k1_num_mul(secp256k1_num_t *r, const secp256k1_num_t *a, const secp256k1_num_t *b);
49-
50-
/** Replace a number by its remainder modulo m. M's sign is ignored. The result is a number between 0 and m-1,
51-
even if r was negative. */
52-
static void secp256k1_num_mod(secp256k1_num_t *r, const secp256k1_num_t *m);
53-
54-
/** Right-shift the passed number by bits bits. */
55-
static void secp256k1_num_shift(secp256k1_num_t *r, int bits);
56-
57-
/** Check whether a number is zero. */
58-
static int secp256k1_num_is_zero(const secp256k1_num_t *a);
59-
60-
/** Check whether a number is strictly negative. */
61-
static int secp256k1_num_is_neg(const secp256k1_num_t *a);
62-
63-
/** Change a number's sign. */
64-
static void secp256k1_num_negate(secp256k1_num_t *r);
65-
6632
#endif
6733

6834
#endif

0 commit comments

Comments
 (0)