提交 ddd2e0a7 编写于 作者: A Anton Perkov

enable almost all compiler warnings on wasm side, disable all warnings from libc, libc++ and boost

上级 ddd18636
......@@ -59,7 +59,8 @@ if( NOT ("${WASM_CLANG}" STREQUAL "" OR "${WASM_LLC}" STREQUAL "" OR "${WASM_LLV
endif()
macro(compile_wast)
cmake_parse_arguments(ARG "" "TARGET" "SOURCE_FILES;INCLUDE_FOLDERS" ${ARGN})
#read arguments include ones that we don't since arguments get forwared "as is" and we don't want to threat unknown argument names as values
cmake_parse_arguments(ARG "NOWARNINGS" "TARGET;DESTINATION_FOLDER" "SOURCE_FILES;INCLUDE_FOLDERS;SYSTEM_INCLUDE_FOLDERS;LIBRARIES" ${ARGN})
set(target ${ARG_TARGET})
# NOTE: Setting SOURCE_FILE and looping over it to avoid cmake issue with compilation ${target}.bc's rule colliding with
......@@ -106,10 +107,28 @@ macro(compile_wast)
-nostdlib -nostdlibinc -fno-threadsafe-statics -fno-rtti -fno-exceptions
-c ${infile} -o ${outfile}.bc
)
if (${ARG_NOWARNINGS})
list(APPEND WASM_COMMAND -Wno-everything)
else()
list(APPEND WASM_COMMAND -Weverything -Wno-c++98-compat -Wno-old-style-cast -Wno-vla -Wno-vla-extension -Wno-c++98-compat-pedantic
-Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-packed -Wno-sign-compare -Wno-sign-conversion)
endif()
foreach(folder ${ARG_INCLUDE_FOLDERS})
list(APPEND WASM_COMMAND -I ${folder})
endforeach()
if ("${ARG_SYSTEM_INCLUDE_FOLDERS}" STREQUAL "")
set (ARG_SYSTEM_INCLUDE_FOLDERS ${DEFAULT_SYSTEM_INCLUDE_FOLDERS})
endif()
foreach(folder ${ARG_SYSTEM_INCLUDE_FOLDERS})
list(APPEND WASM_COMMAND -isystem ${folder})
endforeach()
foreach(folder ${ARG_SYSTEM_INCLUDE_FOLDERS})
list(APPEND WASM_COMMAND -isystem ${folder})
endforeach()
add_custom_command(OUTPUT ${outfile}.bc
DEPENDS ${infile}
COMMAND ${WASM_COMMAND}
......@@ -128,9 +147,9 @@ macro(compile_wast)
endmacro(compile_wast)
macro(add_wast_library)
cmake_parse_arguments(ARG "" "TARGET;DESTINATION_FOLDER" "SOURCE_FILES;INCLUDE_FOLDERS" ${ARGN})
cmake_parse_arguments(ARG "NOWARNINGS" "TARGET;DESTINATION_FOLDER" "SOURCE_FILES;INCLUDE_FOLDERS;SYSTEM_INCLUDE_FOLDERS" ${ARGN})
set(target ${ARG_TARGET})
compile_wast(TARGET ${ARG_TARGET} SOURCE_FILES ${ARG_SOURCE_FILES} INCLUDE_FOLDERS ${ARG_INCLUDE_FOLDERS})
compile_wast(${ARGV})
get_filename_component("${ARG_TARGET}_BC_FILENAME" "${ARG_DESTINATION_FOLDER}/${ARG_TARGET}.bc" ABSOLUTE CACHE)
add_custom_target(${target} ALL DEPENDS ${${ARG_TARGET}_BC_FILENAME})
......@@ -146,11 +165,11 @@ macro(add_wast_library)
endmacro(add_wast_library)
macro(add_wast_executable)
cmake_parse_arguments(ARG "" "TARGET;DESTINATION_FOLDER" "SOURCE_FILES;INCLUDE_FOLDERS;LIBRARIES" ${ARGN})
cmake_parse_arguments(ARG "NOWARNINGS" "TARGET;DESTINATION_FOLDER" "SOURCE_FILES;INCLUDE_FOLDERS;SYSTEM_INCLUDE_FOLDERS;LIBRARIES" ${ARGN})
set(target ${ARG_TARGET})
set(DESTINATION_FOLDER ${ARG_DESTINATION_FOLDER})
compile_wast(TARGET ${ARG_TARGET} SOURCE_FILES ${ARG_SOURCE_FILES} INCLUDE_FOLDERS ${ARG_INCLUDE_FOLDERS})
compile_wast(${ARGV})
foreach(lib ${ARG_LIBRARIES})
list(APPEND LIBRARIES ${${lib}_BC_FILENAME})
......
set(STANDARD_INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts ${CMAKE_SOURCE_DIR}/contracts/libc++/upstream/include ${CMAKE_SOURCE_DIR}/contracts/musl/upstream/include ${Boost_INCLUDE_DIR})
# will be implictly used for any compilation unit if not overrided by SYSTEM_INCLUDE_FOLDERS parameter
# these directories go as -isystem <dir> to avoid warnings from code of third-party libraries
set(DEFAULT_SYSTEM_INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts/libc++/upstream/include ${CMAKE_SOURCE_DIR}/contracts/musl/upstream/include ${Boost_INCLUDE_DIR})
set(STANDARD_INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts)
add_subdirectory(eosiolib)
add_subdirectory(musl)
......
......@@ -68,13 +68,13 @@ struct PACKED(account_balance) {
/**
* @brief Retrieve a populated balance structure
* @details Retrieve a populated balance structure
* @param account_balance stream to write
* @ret true if account's balance is found
* @param acnt - account
* @return true if account's balance is found
*/
bool get(account_balance& b)
bool get(account_balance& acnt)
{
return account_balance_get(&b, sizeof(account_balance));
return account_balance_get(&acnt, sizeof(account_balance));
}
/// @} eosio
......
......@@ -112,8 +112,8 @@ extern "C" {
/**
* Send an inline action in the context of this action's parent transaction
* @param serialized_action
* @param size
* @param serialized_action - serialized action
* @param size - size of serialized action in bytes
*/
void send_inline(char *serialized_action, size_t size);
......
......@@ -18,7 +18,7 @@ template<typename T>
class datastream {
public:
datastream( T start, size_t s )
:_start(start),_pos(start),_end(start+s){};
:_start(start),_pos(start),_end(start+s){}
/**
* Skips a specified number of bytes from this stream
......@@ -119,7 +119,7 @@ class datastream {
template<>
class datastream<size_t> {
public:
datastream( size_t init_size = 0):_size(init_size){};
datastream( size_t init_size = 0):_size(init_size){}
inline bool skip( size_t s ) { _size += s; return true; }
inline bool write( const char* ,size_t s ) { _size += s; return true; }
inline bool put(char ) { ++_size; return true; }
......
......@@ -75,7 +75,6 @@ namespace eosio {
adjust_to_mem_block(size);
// first pass of loop never has to initialize the slot in _available_heap
uint32_t needs_init = 0;
char* buffer = nullptr;
memory* current = nullptr;
// need to make sure
......@@ -129,7 +128,6 @@ namespace eosio {
return nullptr;
}
const uint32_t REMOVE = size;
adjust_to_mem_block(size);
char* realloc_ptr = nullptr;
......
......@@ -157,7 +157,7 @@ extern "C" {
* Convert double (interpreted as 64 bit unsigned integer) to 64 bit unsigned integer.
* This function will first reinterpret_cast the input to double (50 decimal digit precision) then convert it to double, then reinterpret_cast it to 64 bit unsigned integer.
* @brief Convert double to 64 bit unsigned integer
* @param self Value in double interpreted as 64 bit unsigned integer
* @param a - value in double interpreted as 64 bit unsigned integer
* @return Result of conversion in 64 bit unsigned integer
*
* Example:
......@@ -173,7 +173,7 @@ extern "C" {
* Convert 64 bit unsigned integer to double (interpreted as 64 bit unsigned integer).
* This function will convert the input to double (50 decimal digit precision) then reinterpret_cast it to 64 bit unsigned integer.
* @brief Convert 64 bit unsigned integer to double (interpreted as 64 bit unsigned integer)
* @param self Value to be converted
* @param a - value to be converted
* @return Result of conversion in double (interpreted as 64 bit unsigned integer)
*
* Example:
......
......@@ -266,7 +266,7 @@ class multi_index
const T* operator->()const { return *static_cast<const T*>(_item); }
private:
friend class index;
friend struct index;
const_iterator( const index& idx, const typename MultiIndexType::item* i = nullptr )
:_idx(idx), _item(i){}
......
......@@ -51,7 +51,7 @@ extern "C" {
/**
* Prints value as a 64 bit unsigned integer
* @brief Prints value as a 64 bit unsigned integer
* @param Value of 64 bit unsigned integer to be printed
* @param value of 64 bit unsigned integer to be printed
*
* Example:
* @code
......@@ -76,7 +76,7 @@ extern "C" {
/**
* Prints value as double
* @brief Prints value as double
* @param Value of double (interpreted as 64 bit unsigned integer) to be printed
* @param value of double (interpreted as 64 bit unsigned integer) to be printed
*
* Example:
* @code
......@@ -89,7 +89,7 @@ extern "C" {
/**
* Prints a 64 bit names as base32 encoded string
* @brief Prints a 64 bit names as base32 encoded string
* @param Value of 64 bit names to be printed
* @param name - 64 bit name to be printed
*
* Example:
* @code
......
......@@ -14,7 +14,7 @@ namespace eosio {
/**
* Prints string
* @brief Prints string
* @param cstr - a null terminated string
* @param ptr - a null terminated string
*/
inline void print( const char* ptr ) {
prints(ptr);
......@@ -23,7 +23,7 @@ namespace eosio {
/**
* Prints 64 bit unsigned integer as a 64 bit unsigned integer
* @brief Prints integer 64 bit unsigned integer
* @param Value to be printed
* @param num to be printed
*/
inline void print( uint64_t num ) {
printi(num);
......@@ -32,7 +32,7 @@ namespace eosio {
/**
* Prints 32 bit unsigned integer as a 64 bit unsigned integer
* @brief Prints integer 32 bit unsigned integer
* @param Value to be printed
* @param num to be printed
*/
inline void print( uint32_t num ) {
printi(num);
......@@ -41,7 +41,7 @@ namespace eosio {
/**
* Prints integer as a 64 bit unsigned integer
* @brief Prints integer
* @param Value to be printed
* @param num to be printed
*/
inline void print( int num ) {
printi(num);
......@@ -50,7 +50,7 @@ namespace eosio {
/**
* Prints unsigned integer as a 64 bit unsigned integer
* @brief Prints unsigned integer
* @param Value to be printed
* @param num to be printed
*/
inline void print( unsigned int num ) {
printi(num);
......@@ -59,7 +59,7 @@ namespace eosio {
/**
* Prints uint128 struct as 128 bit unsigned integer
* @brief Prints uint128 struct
* @param Value to be printed
* @param num to be printed
*/
inline void print( uint128 num ) {
printi128((uint128_t*)&num);
......@@ -68,7 +68,7 @@ namespace eosio {
/**
* Prints 128 bit unsigned integer
* @brief Prints 128 bit unsigned integer
* @param Value to be printed
* @param num to be printed
*/
inline void print( uint128_t num ) {
printi128((uint128_t*)&num);
......@@ -77,7 +77,7 @@ namespace eosio {
/**
* Prints a 64 bit names as base32 encoded string
* @brief Prints a 64 bit names as base32 encoded string
* @param Value of 64 bit names to be printed
* @param name 64 bit name to be printed
*/
inline void print( name name ) {
printn(name.value);
......
......@@ -92,8 +92,6 @@ namespace eosio {
* @brief Compares two double variables c1 and c2
*
* @details Compares two double variables c1 and c2
* @param c1
* @param c2
* @return if c1 == c2, return true, otherwise false
*/
bool operator==(const real &c1, const real &c2) {
......@@ -105,8 +103,6 @@ namespace eosio {
* @brief Compares two double variables c1 and c2
*
* @details Compares two double variables c1 and c2
* @param c1
* @param c2
* @return if c1 > c2, return true, otherwise false
*/
bool operator>(const real &c1, const real &c2) {
......@@ -118,8 +114,6 @@ namespace eosio {
* @brief Compares two double variables c1 and c2
*
* @details Compares two double variables c1 and c2
* @param c1
* @param c2
* @return if c1 < c2, return true, otherwise false
*/
bool operator<(const real &c1, const real &c2) {
......
......@@ -49,7 +49,7 @@ namespace eosio {
* @brief Constructor for token given quantity of tokens available
* @param v - quantity of tokens available
*/
explicit token( NumberType v ):quantity(v){};
explicit token( NumberType v ):quantity(v){}
/**
* Quantity of tokens available
......
......@@ -72,26 +72,22 @@ extern "C" {
/**
* get the size of the currently executing transaction
* @return
*/
size_t transaction_size();
/**
* get the block number used for TAPOS on the currently executing transaction
*
* @return
*/
int tapos_block_num();
/**
* get the block prefix used for TAPOS on the currently executing transaction
* @return
*/
int tapos_block_prefix();
/**
* get the expiration of the currently executing transaction
* @return
*/
time expiration();
......
......@@ -24,8 +24,8 @@ namespace eosio {
class transaction {
public:
transaction(time expiration = now() + 60, region_id region = 0)
:expiration(expiration),region(region)
transaction(time exp = now() + 60, region_id r = 0)
:expiration(exp),region(r)
{}
void send(uint32_t sender_id, time delay_until = 0) const {
......@@ -43,7 +43,7 @@ namespace eosio {
vector<action> context_free_actions;
vector<action> actions;
EOSLIB_SERIALIZE( transaction, (expiration)(region)(ref_block_num)(ref_block_prefix)(packed_bandwidth_words)(context_free_cpu_bandwidth)(context_free_actions)(actions) );
EOSLIB_SERIALIZE( transaction, (expiration)(region)(ref_block_num)(ref_block_prefix)(packed_bandwidth_words)(context_free_cpu_bandwidth)(context_free_actions)(actions) )
};
class deferred_transaction : public transaction {
......
......@@ -13,7 +13,7 @@ namespace eosio {
* @details Converts a base32 symbol into its binary representation, used by string_to_name()
* @ingroup types
*/
static constexpr char char_to_symbol( char c ) {
static constexpr char char_to_symbol( char c ) {
if( c >= 'a' && c <= 'z' )
return (c - 'a') + 6;
if( c >= '1' && c <= '5' )
......
......@@ -23,7 +23,7 @@ struct unsigned_int {
template<typename T>
operator T()const { return static_cast<T>(value); }
unsigned_int& operator=( int32_t v ) { value = v; return *this; }
unsigned_int& operator=( uint32_t v ) { value = v; return *this; }
uint32_t value;
......
......@@ -9,6 +9,7 @@ FOREACH(FN ${SRC_FILENAMES})
ENDFOREACH(FN)
add_wast_library(TARGET libc++
NOWARNINGS
SOURCE_FILES "${SRC_FILES}"
INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}"
DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR}
......
......@@ -2,7 +2,7 @@
file(GLOB ABI_FILES "*.abi")
set(ABI_FILES "multi_index_test.abi")
add_wast_executable(TARGET multi_index_test
INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}" /usr/local/include
INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}"
LIBRARIES libc++ libc eosiolib
DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR}
)
......
......@@ -16,6 +16,7 @@ file(GLOB THREAD_SOURCES "upstream/src/thread/*.c") #only for __lock __unlock
set(INTERNAL_SOURCES upstream/src/internal/intscan.c upstream/src/internal/shgetc.c upstream/src/internal/libc.c)
add_wast_library(TARGET libc
NOWARNINGS
SOURCE_FILES ${CRYPT_SOURCES} ${CTYPE_SOURCES} ${ENV_SOURCES} ${ERRNO_SOURCES} ${EXIT_SOURCES} ${INTERNAL_SOURCES} ${LOCALE_SOURCES} ${MBYTE_SOURCES}
${MISC_SOURCES} ${SEARCH_SOURCES} ${STDIO_SOURCES} ${STDLIB_SOURCES} ${STRING_SOURCES} ${TIME_SOURCES} ${THREAD_SOURCES}
INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts/musl/upstream/include
......
......@@ -2,8 +2,6 @@
* @file
* @copyright defined in eos/LICENSE.txt
*/
#include <stltest/stltest.hpp> /// defines transfer struct (abi)
// include entire libc
#include <alloca.h>
#include <assert.h>
......
#pragma once
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册