Build Environment

https://github.com/MiSTer-devel/Main_MiSTer/wiki

Moderators: Mug UK, Zorro 2, spiny, Greenious, Sorgelig, Moderator Team

bernouilli
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 100
Joined: Fri Jan 06, 2017 5:02 pm
Location: Paris/France

Re: Build Environment

Postby bernouilli » Wed Nov 15, 2017 4:49 pm

Sorgelig wrote:hmm.. It requires a special linker - gold. I don't want to require additional tool without a good reason.
So, i won't include such changes into repository. You can use it if it helps. I believe you can use my Makefile. It's just something wrong with your build environment.

The linker gold is provided with the gnu-arm tool chain, or isn't it ?

I did some searching, it appears that when you use the linker, it's better to put the libraries at the end of the command line.
I tried and it works without using gold.

If I replace the line
@$(LD) $(LFLAGS) -o $@ $+
with
@$(LD) -o $@ $+ $(LFLAGS)

it compiles even with the regular ld

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2083
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Build Environment

Postby Sorgelig » Wed Nov 15, 2017 5:01 pm

bernouilli wrote:If I replace the line
@$(LD) $(LFLAGS) -o $@ $+
with
@$(LD) -o $@ $+ $(LFLAGS)

it compiles even with the regular ld

This also works for me. Accepted.
Actually linker is a weakest part of GCC. It still has problems even with libraries order. So, i'm not surprised if simple change of parameters order solves the problem.

udo
Atariator
Atariator
Posts: 24
Joined: Fri Jun 02, 2017 10:47 am

Re: Build Environment

Postby udo » Sun Dec 31, 2017 6:23 pm

Hi,

I did some experiments with this gcc Version: gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4)

Some observations while building the MiSTer binary:
1. It throws a lot of warnings about wrong printf format parameters, some of them might cause trouble ...

2. Line 450 of boot.c causes a runtime error because the buffer "rtl_ver" is to small:

char rtl_ver[45];
siprintf(rtl_ver, "MINIMIG-AGA%s v%d.%d.%d by Rok Krajnc. MiSTer port by Sorgelig.", ver_beta ? " BETA" : "", ver_major, ver_minor, ver_minion);

Probably other Versions of gcc do not have this runtime check, but the buffer is to small in any case.

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2083
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Build Environment

Postby Sorgelig » Sun Dec 31, 2017 6:54 pm

I will increase the buffer, thanks.

lorenko
Atarian
Atarian
Posts: 6
Joined: Mon Apr 30, 2018 4:10 pm

Re: Build Environment

Postby lorenko » Thu Jun 14, 2018 5:48 pm

I’m a beginner, I try the makefile on Linux manjaro, MiSTer build with some warning, I copy the MiSter binary on SD but still no video output. With your release binary it’s all ok.
Used -fuse-ld=gold (otherwise I have to use -lm -lpthread for build).
Do you know what’s the problem
:( :(

I'm using arm-linux-gnueabihf-gcc (GCC) 8.1.0

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2083
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Build Environment

Postby Sorgelig » Fri Jun 15, 2018 5:40 am

probably gcc you use is incompatible.

lorenko
Atarian
Atarian
Posts: 6
Joined: Mon Apr 30, 2018 4:10 pm

Re: Build Environment

Postby lorenko » Sun Jun 24, 2018 4:27 pm

Solved :D

using gcc8 there are two major warnings

brightness.cpp(114, 1): warning: no return statement in function returning non-void [-Wreturn-type]
user_io.cpp(2203, 22): warning: control reaches end of non-void function [-Wreturn-type]
user_io.cpp(2113, 1): warning: no return statement in function returning non-void [-Wreturn-type]
input.cpp(2187, 1): warning: control reaches end of non-void function [-Wreturn-type]

Added return EXIT_SUCCESS solve those

menu.cpp: In function 'int changeDir(char*)':
menu.cpp(252, 11): warning: 'char* strncpy(char*, const char*, size_t)' specified bound depends on the length of the source argument [-Wstringop-overflow=]
strncpy(curdir, SelectedPath, len);
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
menu.cpp(250, 20): note: length computed here
int len = strlen(SelectedPath);
~~~~~~^~~~~~~~~~~~~~
menu.cpp(246, 11): warning: 'char* strncpy(char*, const char*, size_t)' specified bound depends on the length of the source argument [-Wstringop-overflow=]
strncpy(curdir, p+1, len);
~~~~~~~^~~~~~~~~~~~~~~~~~
menu.cpp(244, 20): note: length computed here
int len = strlen(p+1);
~~~~~~^~~~~

changed in

size_t len = strlen(p+1);
if (len > strlen(curdir- 1)) len = strlen(curdir - 1);

and

size_t len = strlen(SelectedPath);
if (len > strlen(curdir-1)) len = strlen(curdir - 1);

other warning
st_tos.cpp(1129, 8): warning: 'void* memcpy(void*, const void*, size_t)' reading 12 bytes from a region of size 8 [-Wstringop-overflow=]
memcpy(config.tos_img, "TOS.IMG", 12);
used snprintf

now works good compiled with arm-linux-gnueabihf-gcc (GCC) 8.1.0

:coffe:

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2083
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Build Environment

Postby Sorgelig » Sun Jun 24, 2018 4:40 pm

i will check it and fix.

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2083
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Build Environment

Postby Sorgelig » Sun Jun 24, 2018 4:53 pm

lorenko wrote:strlen(curdir- 1)

this is completely wrong!

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2083
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Build Environment

Postby Sorgelig » Sun Jun 24, 2018 5:04 pm

warnings in menu.cpp are bullshit. Compiler doesn't see I compare the source length with destination size and limit it if source is bigger.
Basically all of them are warnings, not errors. So compiler should produce the binary anyway.

lorenko
Atarian
Atarian
Posts: 6
Joined: Mon Apr 30, 2018 4:10 pm

Re: Build Environment

Postby lorenko » Sun Jun 24, 2018 5:05 pm

Ops, you're right, remove -1 sorry

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2083
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Build Environment

Postby Sorgelig » Sun Jun 24, 2018 5:06 pm

strlen is wrong itself as well. it should be sizeof(curdir)-1

lorenko
Atarian
Atarian
Posts: 6
Joined: Mon Apr 30, 2018 4:10 pm

Re: Build Environment

Postby lorenko » Sun Jun 24, 2018 7:17 pm

Sorgelig wrote:warnings in menu.cpp are bullshit. Compiler doesn't see I compare the source length with destination size and limit it if source is bigger.
Basically all of them are warnings, not errors. So compiler should produce the binary anyway.


I thought so too but obviously it is not, otherwise why it works now and without removing the warming does not work? At least with gcc8

https://developers.redhat.com/blog/2018 ... ith-gcc-8/

But as I said I'm an hobbiest so do not pretend to be right :wink:

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2083
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Build Environment

Postby Sorgelig » Sun Jun 24, 2018 7:35 pm

probably default setting in your GCC treat warnings as errors


Return to “MiSTer”

Who is online

Users browsing this forum: No registered users and 4 guests