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

Compilation issue on Fedora 28 #5

Closed
denifednu opened this issue Jul 9, 2018 · 5 comments
Closed

Compilation issue on Fedora 28 #5

denifednu opened this issue Jul 9, 2018 · 5 comments
Assignees

Comments

@denifednu
Copy link

On Fedora 28, fails to compile many files due to error:
use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
One example:
safexcore/src/crypto/chacha.h:77:46: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘using chacha_key = tools::scrubbed_arr<unsigned char, 32>’ {aka ‘struct tools::scrubbed<std::array<unsigned char, 32> >’}; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
As a kludgy workaround I commented out the following line in:
src/CMakeLists.txt and contrib/CMakeLists.txt: add_compile_options("${WARNINGS_AS_ERRORS_FLAG}")
Then it built successfully.

@atanmarko
Copy link
Contributor

atanmarko commented Jul 9, 2018

What is compiler version/libc version? Seems like some strange compiler issue.

Would you be able to investigate more on this topic?

@denifednu
Copy link
Author

denifednu commented Jul 9, 2018

Here is requested info:

$ g++ --version
g++ (GCC) 8.1.1 20180502 (Red Hat 8.1.1-1)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ldd --version
ldd (GNU libc) 2.27
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

Yes, would be willing to investigate more. Please advise how I could help.

The WARNINGS_AS_ERRORS_FLAG is turning on -Werror=class-memaccess which causes the warning to turn into an error. I did a little research and found many projects (including monero) hitting this issue with gcc 8.1 compiler and they updated their code so it no longer fails, examples:
monero-project/monero#3797
ColinDuquesnoy/MellowPlayer#193

As a workround Linux/GCC could be added to the if statement in CMakeLists.txt:

# warnings are cleared only for GCC on Linux`
if (NOT (MINGW OR APPLE OR FREEBSD OR OPENBSD OR DRAGONFLY))`
   add_compile_options("${WARNINGS_AS_ERRORS_FLAG}") # applies only to targets that follow`
endif()`

@atanmarko
Copy link
Contributor

Well, any kind of help is more than welcomed :)

You could try to figure out the real reason behind this compiler error, what in the source code of safexcore/src/crypto/chacha.h itself is triggering this compiler warning (and hence error). That would be the better way to solve it.

Worse way would be to disable warning as error for this particular warning -Wno-error=class-memaccess, but also to isolate this workaround as much as possible, i.e. only for GCC version >8, Linux OS and only in safexcore/src/crypto/CMakeLists.txt. CMake gives much flexibility and power for this kind of configurations. We do not want to globally disable warnings as errors as they remind us and force us to pay more attention to code quality.

If you have some good proposal for solution feel free to make fork and pull request ;)

@razgadjanje
Copy link
Contributor

razgadjanje commented Jul 10, 2018

@denifednu can you try to build with latest code? We merged some changes that fix the build issues with gcc 8.1

@razgadjanje razgadjanje self-assigned this Jul 10, 2018
@denifednu
Copy link
Author

@hitripekac built with latest code, issue is resolved, thank you!

Safex 'Safex Blockchain Launch v0.1' (v0.1-master-b541aae)

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

3 participants