compiling on Linux Errors

eulercauchy

New member
So after a couple of weeks I finally figured out how to build for linux.  GCC9 cannot build this because of the various errors sprintf and strncpy give when you truncate on purpose. 

To fix this in the makefile I changed the line

CC          = $(LNXDEV)/$(PREFIX)gcc
to
CC          = $(LNXDEV)/$(PREFIX)gcc-8

Sorry if this is obvious to others but it took me a week of trying many different things to figure this out.

Hopefully it can save somebody some time or make someone else's life easier.
 
Workaround didn't work for me as I don't have GCC8 installed. I was able to workaround this by updating Makefile:

Code:
CFLAGS 	       += -g -Wall -Werror -fsigned-char -std=gnu99

Replaced -Werror with -Wno-error:

Code:
CFLAGS 	       += -g -Wall -Wno-error -fsigned-char -std=gnu99
 
I'm trying to fix the errors without disabling -Werror because it is important for code quality.

Newer GCC verisons (8 and 9) have more deep checks and are aware of strcpy/strncpy/sprintf/snprintf calls to analyse them and verify if the output buffer won't be truncated (this is considered a form of data corruption).

I installed GCC-9 in my Debian box and started fixing these errors. And while I thought they'd be easy that's not the case.

Anyway I will try keep everyone up-to-date and send a PR when it is done.

Here are some explanations about these errors: https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/

Thank you.
 
I fixed the build break errors in GCC-9 but I can't push a branch in Github repo to create a PR for someone to review and merge.

The fix is not the thing I like to do the most but it works: I've disabled the GCC checking warnings in each point they are generated and leave other parts of the code with the checks enabled. I just started with OpenBOR code and I think a *real* fix in those places will need some refactoring.

The great news is that OpenBOR can be built with both GCC-8 and GCC-9, even if there is no actual fix for the build breaks.
 
Got the modifications for gcc 9 on my fork (github.com/openhandhelds/openbor, branch pandora-dev) if you want to review
I have to add a verbose in case of error.
 
fantomid & danielt3

Thanks guys. I'd like to import fixes to main source, but I'm unwilling to just turn the errors off. That's poor coding practice and causes bigger problems in the long run. We need to figure out the real reason and correct them. Or if it turns out there's a specific reason we can't change the code and must disable the error, we at least need a well documented reason why.

I have been away from engine coding for a while working on my own stuff, but I'm starting to get the itch again, so I should be back at it soon.

DC
 
I updated my branch with the warning message.
And the compilation was done with default options in the Makefile.
I compile with cygwin too, to check for problems with the modifications on Windows.
 
Back
Top Bottom