2

I have a Linux, and another person has a Mac. We have the same solc compiler version, except for the OS extension (I have 0.4.24+commit.e67f0147.Linux.g++, they have 0.4.24+commit.e67f0147.Darwin.appleclang). When we compile a list of contracts with solc --combined-json abi,bin ./*.sol, the resulting bytecode is different for each contract, in the few bytes at the end. When we compile one contract with just --bin, the bytecode is the same.

Why? Is anything about the EVM bytecode actually dependent on the OS? How could this make sense, given that it's uploaded to ethereum which runs on any machine? Do we need to use some solc flags to get the same output?

  • 2
    That's interesting since yes, EVM bytecode is OS independent. Imho it's more likely a difference of g++ vs clang (or libstdc++ vs libc++), but if you are correct this should be seen as a bug in solc. – mafrasi2 May 29 '18 at 0:42
1

The end of the contract bytecode contains a hash of a metadata file. This metadata file includes things like the exact list of filenames that you ran the compiler command with, and also the exact compiler version. Since we were on different OSes, our compiler versions had different names; these names would show up in the metadata file, and its hash would therefore differ.

Documentation; https://solidity.readthedocs.io/en/v0.4.25/metadata.html#encoding-of-the-metadata-hash-in-the-bytecode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.