Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
199 user(s) are online (171 user(s) are browsing Forums)

Members: 2
Guests: 197

NinjaCyborg, FlynnTheAvatar, more...

Support us!

Headlines

 
  Register To Post  

« 1 ... 12 13 14 (15) 16 17 18 ... 22 »
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@Raziel

If you call your file name as .c, then when you will try to compile with ppc-amigaos-gcc , you will fail, as a compiler will think it pure C and will not include CPP includes (if at the end of include there are no .h, then its cpp includes).

So, you have 2 solutions :

1). rename the file so it will be .CPP, and then you can build it and with "gcc" and with "g++" binaries. Through when you will build it with "gcc" you must add at the end -lstdc++

2). didn't rename it, keep as .C, but then build it with g++ binary.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@kas1e

it is a .c file and i was already using g++

renaming it to .cpp did the trick, without any further hassle


Thank you

Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
What is the difference between -O2 and -O3?

Most of the time i see -O2 used.
I understand that it will optimize the binary hence reducing it in size.

Is it safe to switch to -O3?
Will ther be drawbacks, maybe inconsistencies on AmigaOS4?

Thanks

Go to top
Re: Porting to AmigaOS4 thread
Quite a regular
Quite a regular


See User information
I have used -O3 with at least (prebuilt) sdl (1). Eg. Simutrans build.
Before anyone asks, it stopped compiling "as before" since an update years ago.

Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@Raziel
Quote:

Is it safe to switch to -O3?
Will ther be drawbacks, maybe inconsistencies on AmigaOS4?


-O3 will bring you problems only if the code has bugs. Usual practice enables full optimization. Those who sort the bugs by switching to lower optimization level not fixing bugs, but hide them.

I use -O3 all the time

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@kas1e
@Thematic

What kind of bugs?
Or all kind of bugs? That would make hunting them difficult.

I see from configure that some platforms use -O3 while others use -O2, not consistent either.

Maybe i'll do a test build and see where the differences lie.

Thanks for the answer

Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@all

Fundamental question about the difference of newlib and clib2.

1) If I wanted to compile for clib2, would the switch -mcrt=clib2 be sufficient or fo i have to introduce more changes?
2) Does clib2 also make use of libstdc++.so or does it use something else?
3) If I have used third party libs, like libsdl, libflac, libmpeg etc., with newlib, do I need to use a special clib2 build of those libs or can I simply recycle them for clib2?
4) Are shared builds possible with clib2?
5) is there something like clib2.library available? Just like newlib.library?

Thank you

Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@Raziel

Quote:

1) If I wanted to compile for clib2, would the switch -mcrt=clib2 be sufficient or fo i have to introduce more changes?


Just -mcrt=clib2 enough. By default we have -mcrt=newlib , you just didn't see it when run gcc, but if you do "ppc-amigaos-gcc -v test.c -o test", then you will see :

Quote:

/usr/local/amiga/libexec/gcc/ppc-amigaos/8.2.0/cc1plus.exe -quiet -v -mcrt=newlib -idirafter /usr/local/amiga/ppc-amigaos/SDK/newlib/include -idirafter /usr/local/amiga/ppc-amigaos/SDK/local/newlib/include -idirafter /usr/local/amiga/ppc-amigaos/SDK/include/include_h -idirafter /usr/local/amiga/ppc-amigaos/SDK/include/netinclude -idirafter /usr/local/amiga/ppc-amigaos/SDK/local/common/include rename.cpp -quiet -dumpbase rename.cpp -auxbase rename -version -o /tmp/ccjfomzD.s



Quote:

2) Does clib2 also make use of libstdc++.so or does it use something else?


It have its own libstdc++.so (and others), check in sdk/ppc-amigaos/lib/clib2/ directory


Quote:

3) If I have used third party libs, like libsdl, libflac, libmpeg etc., with newlib, do I need to use a special clib2 build of those libs or can I simply recycle them for clib2?


For clib2 programs, all the libs should be as clib2 ones. You can't mix newlib build with clib2 libs (i.e. you can, sometime it will even compile, but will cause all sort of issues). That another issue for big projects: some of our 3d party libs compiled only for newlib.

Quote:

4) Are shared builds possible with clib2?


As i know clib2 do not support .so as expected, clib2 is not threadsafe, so how it all will works is unclear (i.e. bugs)


Quote:

5) is there something like clib2.library available? Just like newlib.library?


Dunno about.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@Raziel

https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

-O3 takes longer time to compile, -O2 is faster.

Time increases is a factor of around 1.45 to compile it.

It might be really noticeable on larger project, with horrible makefiles, but on smaller project you should not notice any different.

-O0
Is standard does no optimization, there also fastest to compile.

-O3 used to be buggy in some conditions, it invokes more optimizing tricks, so if there is bug in the compiler it can result in buggy exe file.

So, people removed -O3 if did not work, not sure if that’s true anymore.

Anyway, if you like to find bugs you should compile with -Wall, code can be messy sometimes, often unused variables are left behind, or there some casting that is ignored, that can result in signs bugs, its better to have enabled to begin with, then having to clean up your code, after few 1000 lines of code.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@Raziel

Clib2 makes your exe file fat, its statically linked. While newlib is opened as Amiga library before your program starts, somewhere in the background.

But I’m not sure everything is in the .library, lets say your exe file will be less fat with newlib.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@LiveForIt
Quote:

-O3 takes longer time to compile, -O2 is faster.


Compiling times only matter if you compile on a1200. What is the matter: bug-free app, and not how long and fast it compiles on developers' machines. My removing -O3 you hide bugs in the app.


Quote:

-O3 used to be buggy in some conditions, it invokes more optimizing tricks, so if there is a bug in the compiler it can result in a buggy exe file.



No, if -O3 show you bugs, it means your code buggy.

Quote:

So, people removed -O3 if did not work, not sure if that’s true anymore.


They hide their own bugs by that, -O3 is very well tested by millions of ppls already for a years.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Porting to AmigaOS4 thread
Just popping in
Just popping in


See User information
@LiveForIt
Quote:
-O3 used to be buggy in some conditions, it invokes more optimizing tricks, so if there is bug in the compiler it can result in buggy exe file.
I wouldn't call it tricks. The main difference between O2 and O3 is that O3 sacrifices a bit of memory to run faster. This might not always succeed due to decreases in code density (resulting in cache misses). To find out how it affects your code you need to do some benchmarking. It could be that projects used O2 for performance reasons, not because the compiler is buggy.

Go to top
Re: Porting to AmigaOS4 thread
Amigans Defender
Amigans Defender


See User information
@Raziel

Quote:
I see from configure that some platforms use -O3 while others use -O2, not consistent either.

As others have pointed out, -O3 will also trigger new warnings, which is a good thing. I always compile with

-Wall -Wwrite-strings -Wextra -O3

to get enough feedback on my code from the compiler.

The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top
Re: Porting to AmigaOS4 thread
Just popping in
Just popping in


See User information
@trixie
Quote:
As others have pointed out, -O3 will also trigger new warnings, which is a good thing.


With gcc 10 you can also use the -fanalyzer option to find even more bugs, see: https://gcc.gnu.org/wiki/DavidMalcolm/StaticAnalyzer

Haven't tried it on OS4 though.

Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@sTix
Quote:

With gcc 10 you can also use the -fanalyzer option to find even more bugs


Wow, tried simple test case with wrong-double-free:

#include<stdio.h>
#include <stdlib.h>

int main()
{
        
int *ptr_one;

        
ptr_one = (int *)malloc(sizeof(int));

        if (
ptr_one == 0)
        {
                
printf("ERROR: Out of memory\n");
                return 
1;
        }

        *
ptr_one 25;
        
printf("%d\n", *ptr_one);

        
free(ptr_one);
        
free(ptr_one);

        return 
0;
}


And -fanalyzer works, see:

user@DESKTOP-3NFAB0O /amiga
ppc-amigaos-gcc -fanalyzer 1.c -o 1
1.c
In function ‘main’:
1.c:20:9warningdouble-‘free’ of ‘ptr_one’ [CWE-415] [-Wanalyzer-double-free]
   
20 |         free(ptr_one);
      |         ^~~~~~~~~~~~~
  
‘main’events 1-6
    
|
    |    
|         ptr_one = (int *)malloc(sizeof(int));
    |      |                          ^~~~~~~~~~~~~~~~~~~
    |      |                          |
    |      |                          (
1allocated here
    
|    |
    |   
10 |         if (ptr_one == 0)
    |      |            ~
    |      |            |
    |      |            (
2assuming ‘ptr_one’ is non-NULL
    
|      |            (3following ‘false’ branch (when ‘ptr_one’ is non-NULL)...
    |......
    |   
16 |         *ptr_one 25;
    |      |         ~~~~~~~~~~~~~
    |      |                  |
    |      |                  (
4) ...to here
    
|      |                  (5first ‘free’ here
    
|......
    |   
20 |         free(ptr_one);
    |      |         ~~~~~~~~~~~~~
    |      |         |
    |      |         (
6second ‘free’ herefirst ‘free’ was at (5)
    |

user@DESKTOP-3NFAB0O /amiga

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Porting to AmigaOS4 thread
Just popping in
Just popping in


See User information
@kas1e

Without full memory protection we need all the help we can get :)

Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@kas1e

If clib2 cant do shared then it's no alternative for me.

Thank you for your always thorough feedback.

Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@LiveForIt

Thank you for your feedback

Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
@sTix
@trixie

I'll definitely try -O3 when I have some free time from work.

Thank you for your feedback

I'll try -fanalyzer as well, who knows, maybe it will show something new in the shared crashes.

Go to top
Re: Porting to AmigaOS4 thread
Home away from home
Home away from home


See User information
I am nowhere near my amiga right now but I remember reading the readme from new GCC builds and always wanted to ask.

There is a snippet about shared obhects/builds in there that says to avoid shared builds due to some planned restructuring.

What is needed for this restructuring?
Has this restructuring already started and messed up shared builds...what may cause the many issues we are having?
Would it be possible to revert these changes to get an outdated, but working, shared support back?

Thank you

Go to top

  Register To Post
« 1 ... 12 13 14 (15) 16 17 18 ... 22 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project