Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Cherry pick fixes develop #682

Merged
merged 8 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions libraries/eosiolib/eosiolib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ namespace eosio {
}

std::vector<name> get_active_producers() {
auto prod_cnt = get_active_producers(nullptr, 0)/8;
std::vector<name> active_prods(prod_cnt);
get_active_producers((uint64_t*)active_prods.data(), active_prods.size());
return active_prods;
const auto buffer_size = get_active_producers(nullptr, 0);
const auto prod_cnt = buffer_size / sizeof(name);
std::vector<name> active_prods(prod_cnt);
get_active_producers((uint64_t*)active_prods.data(), buffer_size);
return active_prods;
}

// powers.hpp
Expand Down
8 changes: 4 additions & 4 deletions libraries/libc++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ add_native_library(native_c++

target_include_directories(c++
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/libcxx/include
${CMAKE_SOURCE_DIR}/libc/musl/include
${CMAKE_SOURCE_DIR}/libc/musl/src/internal
${CMAKE_SOURCE_DIR}/libc/musl/src/crypt
${CMAKE_SOURCE_DIR}/libc/musl/arch/eos
${CMAKE_CURRENT_SOURCE_DIR}/libcxx/include)
${CMAKE_SOURCE_DIR}/libc/musl/arch/eos)

target_include_directories(native_c++
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/libcxx/include
${CMAKE_SOURCE_DIR}/libc/musl/include
${CMAKE_SOURCE_DIR}/libc/musl/src/internal
${CMAKE_SOURCE_DIR}/libc/musl/src/crypt
${CMAKE_SOURCE_DIR}/libc/musl/arch/eos
${CMAKE_CURRENT_SOURCE_DIR}/libcxx/include)
${CMAKE_SOURCE_DIR}/libc/musl/arch/eos)

target_link_libraries(c++ c)
target_link_libraries(native_c++ native_c)
Expand Down
24 changes: 6 additions & 18 deletions tools/cc/eosio-cpp.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,12 @@ void generate(const std::vector<std::string>& base_options, std::string input, s
options.push_back(input); // don't remove oddity of CommonOptionsParser?
options.push_back(input);
options.push_back("--");
for (size_t i=1; i < base_options.size(); i++) {
if (llvm::sys::path::extension(input).equals(".c"))
options.push_back("-xc++");
for (size_t i=0; i < base_options.size(); i++) {
options.push_back(base_options[i]);
}
options.push_back("--target=wasm32");
options.push_back("-nostdlib");
options.push_back("-ffreestanding");
options.push_back("-fno-builtin");
options.push_back("-fno-rtti");
options.push_back("-fno-exceptions");
options.push_back("-I${Boost_INCLUDE_DIRS}");
options.push_back("-DBOOST_DISABLE_ASSERTS");
options.push_back("-DBOOST_EXCEPTION_DISABLE");
options.push_back("-Wno-everything");
options.push_back("-std=c++17");
options.push_back(std::string("-I")+eosio::cdt::whereami::where()+"/../include/libcxx");
options.push_back(std::string("-I")+eosio::cdt::whereami::where()+"/../include/libc");
options.push_back(std::string("-I")+eosio::cdt::whereami::where()+"/../include");
options.push_back(std::string("-I")+eosio::cdt::whereami::where()+"/../../../../../libraries/libc++/libcxx/include");
options.push_back(std::string("-I")+eosio::cdt::whereami::where()+"/../../../../../libraries/libc/musl/include");
options.push_back(std::string("-I")+eosio::cdt::whereami::where()+"/../../../../../libraries");
options.push_back(std::string("-I")+eosio::cdt::whereami::where()+"/../../../../../libraries/boost/include");

int size = options.size();
const char** new_argv = new const char*[size];
Expand Down Expand Up @@ -219,6 +204,9 @@ int main(int argc, const char **argv) {
new_opts.insert(new_opts.begin(), "-o "+output);
outputs.push_back(output);

if (llvm::sys::path::extension(input).equals(".c"))
new_opts.insert(new_opts.begin(), "-xc++");

if (!eosio::cdt::environment::exec_subprogram("clang-7", new_opts)) {
llvm::sys::fs::remove(tmp_file);
return -1;
Expand Down
107 changes: 54 additions & 53 deletions tools/include/compiler_options.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -555,54 +555,6 @@ static Options CreateOptions(bool add_defaults=true) {
#endif
#endif
#ifndef ONLY_LD
copts.emplace_back("-I./");
if (!sysroot_opt.empty()) {
copts.emplace_back("--sysroot="+sysroot_opt);
copts.emplace_back("-I"+sysroot_opt+"/include/libcxx");
copts.emplace_back("-I"+sysroot_opt+"/include/libc");

// only allow capi for native builds and for eosio-cc
if (fnative_opt) {
copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/capi");
copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/native");
}
#ifndef CPP_COMP
copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/capi");
#endif
copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/core");
copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/contracts");

ldopts.emplace_back("-L"+sysroot_opt+"/lib");
#ifndef __APPLE__
ldopts.emplace_back("-L"+sysroot_opt+"/lib64");
#endif
}
else {
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/libcxx");
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/libc");
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include");
copts.emplace_back("--sysroot="+eosio::cdt::whereami::where()+"/../");
agopts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/libcxx");
agopts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/libc");
agopts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include");
agopts.emplace_back("--sysroot="+eosio::cdt::whereami::where()+"/../");
ldopts.emplace_back("-L"+eosio::cdt::whereami::where()+"/../lib");

if (fnative_opt) {
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/capi");
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/native");
}
#ifndef CPP_COMP
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/capi");
#endif
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/core");
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/contracts");

#ifndef __APPLE__
ldopts.emplace_back("-L"+eosio::cdt::whereami::where()+"/../lib64");
#endif
}

if (!isystem_opt.empty()) {
copts.emplace_back("-isystem="+isystem_opt);
}
Expand Down Expand Up @@ -642,6 +594,10 @@ static Options CreateOptions(bool add_defaults=true) {
}
if(g_opt)
copts.emplace_back("-g");
if (!x_opt.empty()) {
// x_opt should precede input files
copts.insert(copts.begin(), "-x"+x_opt);
}
if (color_diag_opt) {
copts.emplace_back("-fcolor-diagnostics");
}
Expand Down Expand Up @@ -689,6 +645,52 @@ static Options CreateOptions(bool add_defaults=true) {
copts.emplace_back("-I"+inc_dir);
agopts.emplace_back("-I"+inc_dir);
}
if (!sysroot_opt.empty()) {
copts.emplace_back("--sysroot="+sysroot_opt);
copts.emplace_back("-I"+sysroot_opt+"/include/libcxx");
copts.emplace_back("-I"+sysroot_opt+"/include/libc");

// only allow capi for native builds and for eosio-cc
if (fnative_opt) {
copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/capi");
copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/native");
}
#ifndef CPP_COMP
copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/capi");
#endif
copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/core");
copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/contracts");

ldopts.emplace_back("-L"+sysroot_opt+"/lib");
#ifndef __APPLE__
ldopts.emplace_back("-L"+sysroot_opt+"/lib64");
#endif
}
else {
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/libcxx");
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/libc");
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include");
copts.emplace_back("--sysroot="+eosio::cdt::whereami::where()+"/../");
agopts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/libcxx");
agopts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/libc");
agopts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include");
agopts.emplace_back("--sysroot="+eosio::cdt::whereami::where()+"/../");
ldopts.emplace_back("-L"+eosio::cdt::whereami::where()+"/../lib");

if (fnative_opt) {
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/capi");
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/native");
}
#ifndef CPP_COMP
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/capi");
#endif
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/core");
copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/contracts");

#ifndef __APPLE__
ldopts.emplace_back("-L"+eosio::cdt::whereami::where()+"/../lib64");
#endif
}
if (O_opt.empty() && !g_opt) {
copts.emplace_back("-O3");
}
Expand Down Expand Up @@ -797,12 +799,11 @@ static Options CreateOptions(bool add_defaults=true) {
#ifndef ONLY_LD
#ifdef CPP_COMP
if (! std_opt.empty()) {
copts.emplace_back("--std="+std_opt);
agopts.emplace_back("--std="+std_opt);
copts.emplace_back("-std="+std_opt);
agopts.emplace_back("-std="+std_opt);
} else {
copts.emplace_back("--std=c++17");
agopts.emplace_back("--std=c++17");

copts.emplace_back("-std=c++17");
agopts.emplace_back("-std=c++17");
}

if (faligned_allocation_opt) {
Expand Down
20 changes: 15 additions & 5 deletions tools/include/eosio/abigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ namespace eosio { namespace cdt {
abi_struct ret;
if ( decl->getNumBases() == 1 ) {
ret.base = get_type(decl->bases_begin()->getType());
add_struct(decl->bases_begin()->getType().getTypePtr()->getAsCXXRecordDecl());
add_type(decl->bases_begin()->getType());
}
std::string sub_name = "";
for ( auto field : decl->fields() ) {
if ( field->getName() == "transaction_extensions") {
abi_struct ext;
Expand All @@ -173,7 +172,6 @@ namespace eosio { namespace cdt {
}
else {
ret.fields.push_back({field->getName().str(), get_type(field->getType())});
sub_name += "_" + get_type(field->getType());
add_type(field->getType());
}
}
Expand Down Expand Up @@ -389,6 +387,14 @@ namespace eosio { namespace cdt {
set_of_tables.insert(t);
}

std::function<std::string(const std::string&)> get_root_name;
get_root_name = [&] (const std::string& name) {
for (auto td : _abi.typedefs)
if (remove_suffix(name) == td.new_type_name)
return get_root_name(td.type);
return name;
};

auto validate_struct = [&]( abi_struct as ) {
if ( is_builtin_type(_translate_type(as.name)) )
return false;
Expand All @@ -403,7 +409,7 @@ namespace eosio { namespace cdt {
return true;
}
}
if (s.base == as.name)
if (get_root_name(s.base) == as.name)
return true;
}
for ( auto a : _abi.actions ) {
Expand All @@ -423,10 +429,14 @@ namespace eosio { namespace cdt {

auto validate_types = [&]( abi_typedef td ) {
for ( auto as : _abi.structs )
if (validate_struct(as))
if (validate_struct(as)) {
for ( auto f : as.fields )
if ( remove_suffix(f.type) == td.new_type_name )
return true;
if (as.base == td.new_type_name)
return true;
}

for ( auto v : _abi.variants ) {
for ( auto vt : v.types ) {
if ( remove_suffix(vt) == td.new_type_name )
Expand Down