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

Compiler warnings aren't displayed when compiling through eosfactory.build #180

Open
tj800x opened this issue Aug 16, 2019 · 4 comments
Open

Comments

@tj800x
Copy link

tj800x commented Aug 16, 2019

When compiling throuigh eosfactory.build certain compiler warnings are not being displayed:

This command is missing the compiler warnings:

$ python3 -m eosfactory.build `pwd`/..
######## command line:
eosio-cpp -o /Users/trj/projects/freeu/eos/contracts/fupm/build/fupm.wasm -I=/Users/trj/projects/freeu/eos/contracts/fupm -I=/Users/trj/projects/freeu/eos/contracts/fupm/include -abigen -R=/Users/trj/projects/freeu/eos/contracts/fupm/../ricardian /Users/trj/projects/freeu/eos/contracts/fupm/src/fupm.cpp
eosio-cpp: .....
Warning, empty ricardian clause file
Warning, empty ricardian clause file
Warning, action <emplaceusr> does not have a ricardian contract
Warning, action <addrtg> does not have a ricardian contract
Warning, action <addproc> does not have a ricardian contract

ABI file writen to file: 
    /Users/trj/projects/freeu/eos/contracts/fupm/build/fupm.abi
WASM file writen to file: 
    /Users/trj/projects/freeu/eos/contracts/fupm/build/fupm.wasm
eosio-cpp: OK

Running the eosio command directly will show the compiler warning:

$ eosio-cpp -o /Users/trj/projects/freeu/eos/contracts/fupm/build/fupm.wasm -I=/Users/trj/projects/freeu/eos/contracts/fupm -I=/Users/trj/projects/freeu/eos/contracts/fupm/include -abigen -R=/Users/trj/projects/freeu/eos/contracts/fupm/../ricardian /Users/trj/projects/freeu/eos/contracts/fupm/src/fupm.cpp
Warning, empty ricardian clause file
Warning, empty ricardian clause file
Warning, action <emplaceusr> does not have a ricardian contract
Warning, action <addrtg> does not have a ricardian contract
Warning, action <addproc> does not have a ricardian contract
/var/folders/0f/6vs58vd94v7f89zlxt9rxync0000gn/T//fupm.cpp:154:71: warning: shift count >= width of type [-Wshift-count-overflow]
        uint128_t get_composite() const { return (procRaterName.value << 64 || procDevName.value);};
                                                                      ^  ~~
1 warning generated.

@stefanzarembinski
Copy link
Contributor

You say that you execute the same command line that EOSFactory uses and you get the different warning message.
I cannot reproduce this effect.

@stefanzarembinski
Copy link
Contributor

OK, now I see the point. I will elaborate it.

@stefanzarembinski
Copy link
Contributor

Thank you for pointing at the bad mistake. I have corrected it. If you do not want to wait for the next edition of EOSFactory, and if you use a GitHub cloned repository, you can correct the file eosfactory/core/utils.py:

@@ -139,7 +139,7 @@ error message:
139 139      if cwd:
140 140          shutil.rmtree(cwd)
141 141
142     -    if returncode:
    142 +    if returncode or stderr:
143 143        raise errors.Error('''
144 144   command line:
145 145   =============

Now, EOSFactory throws an exception:

ERROR:
command line:
=============
eosio-cpp -o /mnt/c/Workspaces/EOS/contracts/token/build/token.wasm -I=/mnt/c/Users/cartman/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/opt/eosio.cdt/1.6.1/include -I=/mnt/c/Users/cartman/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/opt/eosio.cdt/1.6.1/include/libcxx -I=/mnt/c/Users/cartman/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/opt/eosio.cdt/1.6.1/include/eosiolib/core -I=/mnt/c/Users/cartman/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/opt/eosio.cdt/1.6.1/include/eosiolib/contracts -I=/mnt/c/Workspaces/EOS/contracts/token -I=/mnt/c/Workspaces/EOS/contracts/token/include -abigen -R=/mnt/c/Workspaces/EOS/contracts/token/ricardian /mnt/c/Workspaces/EOS/contracts/token/src/token.cpp

error message:
==============
In file included from /tmp/token.cpp:6:
/mnt/c/Workspaces/EOS/contracts/token/include/token.hpp:23:72: warning: shift count >= width of type [-Wshift-count-overflow]
         uint128_t get_composite(name user) const { return (user.value << 64 || user.value);};
                                                                       ^  ~~
1 warning generated.

@stefanzarembinski
Copy link
Contributor

I see that the correction is too restrictive as it crushes the process in case of any compiler warning. I refine the correction. In the file eosfactory/core/utils, the function long_process, starting at the line 88:

def long_process(command_line, build_dir=None, is_verbose=True, prompt=None, 
                                shell=False):
    stop = False
    PERIOD = 2

    def thread_function():
        if prompt:
            print("{}: ".format(prompt), end="", flush=True)
        while True:
            print(".", end="", flush=True)
            time.sleep(PERIOD)
            if stop:
                break

    cwd = None
    if build_dir:
        cwd = os.path.join(build_dir, "cwd")
        if os.path.exists(cwd):
            try:
                shutil.rmtree(cwd)
            except Exception as e:
                raise errors.Error("""
Cannot remove the directory {}.
error message:
==============
{}
                """.format(cwd, str(e)))
        os.mkdir(cwd)

    threading.Thread(target=thread_function).start()
    try:
        p = subprocess.run(
            command_line,
            cwd=cwd,
            shell=shell,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
    except Exception as e:
        stop = True
        time.sleep(PERIOD)
        print(str(e))
        exit()

    stop = True
    time.sleep(PERIOD)
    print()
    stdout = p.stdout.decode("ISO-8859-1")
    stderr = p.stderr.decode("ISO-8859-1")
    returncode = p.returncode

    if cwd:
        shutil.rmtree(cwd)

    if returncode:
        raise errors.Error("""
command line:
=============
{}

error message:
==============
{}
        """.format(" ".join(command_line), stderr))

    if is_verbose:
        print(stdout)
        print(stderr)

    return p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants