Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation of test contracts in spring (using cdt 4.1.0-rc3) #677

Open
greg7mdp opened this issue Aug 30, 2024 · 2 comments · Fixed by #678 or #680
Open

Fix compilation of test contracts in spring (using cdt 4.1.0-rc3) #677

greg7mdp opened this issue Aug 30, 2024 · 2 comments · Fixed by #678 or #680
Assignees

Comments

@greg7mdp
Copy link
Contributor

When trying to build the test contracts in spring (with -DEOSIO_COMPILE_TEST_CONTRACTS=1), and using a cdt at tag 4.1.0-rc3 built with clang-18, there are multiple compilation issues:

In file included from /home/greg/github/enf/cdt/build_clang18_debug/bin/../include/eosiolib/contracts/eosio/eosio.hpp:8:
/home/greg/github/enf/cdt/build_clang18_debug/bin/../include/eosiolib/contracts/eosio/multi_index.hpp:442:96: error: function 'primary_key' with deduced return type cannot be used before it is defined
      static_assert( std::is_same_v<decltype(_multi_index_detail::to_raw_key(std::declval<T>().primary_key())), uint64_t>,
                                                                                               ^
/home/greg/github/enf/spring/unittests/contracts/eosio.mechanics/eosmechanics.cpp:41:27: note: in instantiation of template class 'eosio::multi_index<13376978854124453888, eosmechanics::ramdata>' requested here
            ramdata_index ramdata(_self, _self.value);
                          ^
/home/greg/github/enf/spring/unittests/contracts/eosio.mechanics/eosmechanics.cpp:111:18: note: 'primary_key' declared here
            auto primary_key()const { return id; }
                 ^
1 error generated.
FAILED: eosio.system/CMakeFiles/eosio.system.dir/eosio.system.cpp.obj 
/home/greg/github/enf/cdt/build_clang18_debug/bin/cdt-cpp  -I/home/greg/github/enf/spring/unittests/contracts/eosio.system/include -I/home/greg/github/enf/spring/unittests/contracts/eosio.system/../eosio.token -O3 -fcolor-diagnostics -abigen -abigen_output=/home/greg/github/enf/spring/build_clang18_debug/unittests/contracts/eosio.system/eosio.system.abi -contract eosio.system -MD -MT eosio.system/CMakeFiles/eosio.system.dir/eosio.system.cpp.obj -MF eosio.system/CMakeFiles/eosio.system.dir/eosio.system.cpp.obj.d -o eosio.system/CMakeFiles/eosio.system.dir/eosio.system.cpp.obj -c /home/greg/github/enf/spring/unittests/contracts/eosio.system/eosio.system.cpp
/home/greg/github/enf/spring/unittests/contracts/eosio.system/eosio.system.cpp:304:1: error: case value is not a constant expression
EOSIO_DISPATCH( eosiosystem::system_contract,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/greg/github/enf/cdt/build_clang18_debug/bin/../include/eosiolib/contracts/eosio/dispatcher.hpp:126:13: note: expanded from macro 'EOSIO_DISPATCH'
            EOSIO_DISPATCH_HELPER( TYPE, MEMBERS ) \
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/greg/github/enf/cdt/build_clang18_debug/bin/../include/eosiolib/contracts/eosio/dispatcher.hpp:103:33: note: expanded from macro 'EOSIO_DISPATCH_HELPER'
    BLUEGRASS_META_FOREACH_SEQ( EOSIO_DISPATCH_INTERNAL, TYPE, MEMBERS )
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/greg/github/enf/cdt/build_clang18_debug/bin/../include/bluegrass/meta/preprocessor.hpp:196:157: note: expanded from macro 'BLUEGRASS_META_FOREACH_SEQ'
   BLUEGRASS_META_EXPAND(BLUEGRASS_META_EXPAND(BLUEGRASS_META_GET_NTH_ARG BLUEGRASS_META_GET_NTH_ARG_SEQ_ARGS(__VA_ARGS__)) BLUEGRASS_META_FOREACH_SEQ_ARGS(MAC, D, ##__VA_ARGS__))
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/home/greg/github/enf/cdt/build_clang18_debug/bin/../include/bluegrass/meta/preprocessor.hpp:122:40: note: expanded from macro 'BLUEGRASS_META_FE1'
#define BLUEGRASS_META_FE1(MAC,  A, B) MAC(A, B)
                                       ^
/home/greg/github/enf/cdt/build_clang18_debug/bin/../include/eosiolib/contracts/eosio/dispatcher.hpp:97:10: note: expanded from macro 'EOSIO_DISPATCH_INTERNAL'
    case eosio::name( BLUEGRASS_META_STRINGIZE(elem) ).value: \
         ^
/home/greg/github/enf/cdt/build_clang18_debug/bin/../include/bluegrass/meta/preprocessor.hpp:10:36: note: expanded from macro 'BLUEGRASS_META_EXPAND_I'
#define BLUEGRASS_META_EXPAND_I(x) x
                                   ^
/home/greg/github/enf/cdt/build_clang18_debug/bin/../include/eosiolib/core/eosio/name.hpp:81:13: note: non-constexpr function 'check' cannot be used in a constant expression
            eosio::check( false, "string is too long to be a valid name" );
            ^
/home/greg/github/enf/spring/unittests/contracts/eosio.system/eosio.system.cpp:304:1: note: in call to 'name({&"BLUEGRASS_META_SEQ_ENUM_BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_33(closerex) (buyrambytes)(buyram)(sellram)(delegatebw)(undelegatebw)(refund) (regproducer)(unregprod)(voteproducer)(regproxy) (onblock)(claimrewards) (newaccount)(updateauth)(deleteauth)(linkauth)(unlinkauth)(canceldelay)(onerror)(setabi) (init)(setram)(setramrate)(setparams)(setpriv)(setalimits)(rmvproducer)(updtrevision)(bidname)(bidrefund) (deposit)(withdraw)(buyrex)(unstaketorex)(sellrex)(cnclrexorder)(rentcpu)(rentnet)(fundcpuloan)(fundnetloan) (defcpuloan)(defnetloan)(updaterex)(consolidate)(rexexec)(closerex) (buyrambytes)(buyram)(sellram)(delegatebw)(undelegatebw)(refund) (regproducer)(unregprod)(voteproducer)(regproxy) (onblock)(claimrewards)"[0], 732})'
EOSIO_DISPATCH( eosiosystem::system_contract,
^
/home/greg/github/enf/cdt/build_clang18_debug/bin/../include/eosiolib/contracts/eosio/dispatcher.hpp:126:13: note: expanded from macro 'EOSIO_DISPATCH'
            EOSIO_DISPATCH_HELPER( TYPE, MEMBERS ) \
            ^
/home/greg/github/enf/cdt/build_clang18_debug/bin/../include/eosiolib/contracts/eosio/dispatcher.hpp:103:33: note: expanded from macro 'EOSIO_DISPATCH_HELPER'
    BLUEGRASS_META_FOREACH_SEQ( EOSIO_DISPATCH_INTERNAL, TYPE, MEMBERS )

These need to be fixed.

@ericpassmore
Copy link
Contributor

Possible related issues in CDT
AntelopeIO/cdt#191
AntelopeIO/cdt#27

@ericpassmore
Copy link
Contributor

Note:start
group: STABILITY
category: TEST
summary: Fix type detection error in test contracts that prevent compilation of contracts on the CI/CD system.
Note:end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment