English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 31 December 2019, 13:05   #1
MartinW
Registered User
 
Join Date: Mar 2017
Location: Minehead / UK
Posts: 608
Basics of gcc

Apologies if this is covered somewhere - I may have even asked myself before

Is there somewhere that explains what all the different options like '-noiexemul' and the like do? And why you might want one over the other or add one in some cases but not others?

It feels a bit like this is stuff that you're meant to just know. Maybe it's because I've pretty much always used IDEs when it comes to modern development and maybe they shield you from this kind of stuff?
MartinW is offline  
Old 31 December 2019, 14:17   #2
Cowcat
Registered User
 
Join Date: Apr 2013
Location: Mallorca
Posts: 758
With gcc in amiga land "-noixemul" makes a turn regarding posix functions: Instead of using ixemul library it uses at link time libnix (no unix): Small size and less overhead, but with the possibility of missing some gnu unix functions. Or something like that.
Cowcat is offline  
Old 31 December 2019, 14:25   #3
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,232
on latest gcc 6.5 by beebo, if you don't use "-noixemul", it may crash randomly. Didn't happen with 6.4. But 6.5 is much better. So I strongly recommend using the switch, always.

I use IDEs to develop, but I always choose options myself.

my base options: -Wall -Wextra -Werror -noixemul

(all warnings, no ixemul)

debug mode: -O0 -g

(don't optimize, add debug symbols)

release mode: -O2 -DNDEBUG

standard optim switches+define NDEBUG so "assert" checks and other stuff are eliminated from build, making it smaller, faster, and unsafe

I still use real time exceptions (C++). I'd like to know if there's a switch that drastically reduces code size, as my program still takes 1.2MB (release mode, no debug), and gets down to 1.0MB when using "strip" on it (even if I never use -g ..., strange). Using powerpacker "reduces" executable to 400MB on disk...
jotd is offline  
Old 31 December 2019, 15:18   #4
MartinW
Registered User
 
Join Date: Mar 2017
Location: Minehead / UK
Posts: 608
Thanks for the info guys.
MartinW is offline  
Old 31 December 2019, 16:16   #5
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
Quote:
Originally Posted by jotd View Post

I still use real time exceptions (C++). I'd like to know if there's a switch that drastically reduces code size, as my program still takes 1.2MB (release mode, no debug), and gets down to 1.0MB when using "strip" on it (even if I never use -g ..., strange). Using powerpacker "reduces" executable to 400MB on disk...
try adding -s on release builds to have it stripped
alkis is offline  
Old 31 December 2019, 16:35   #6
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,232
Great it works: "-Wl,--strip-debug" failed, but -s worked...
jotd is offline  
Old 14 January 2020, 15:54   #7
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
For a release build I use

Code:
-Os -Wall -Wno-unused-function -fomit-frame-pointer -fno-rtti -fno-exceptions -noixemul -Dlinux
And then strip it, might think about adding the -s directly instead of calling strip in the makefile.

Produces a 65k binary for 10.000 lines c++ code:-)
thyslo is offline  
Old 14 January 2020, 20:06   #8
MartinW
Registered User
 
Join Date: Mar 2017
Location: Minehead / UK
Posts: 608
Why -Dlinux ?
MartinW is offline  
Old 14 January 2020, 20:58   #9
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,232
-Wall -Wno-unused-function are warnings options. They don't affect the code generation.

-Os: optimize for size (not necessarily for speed)

-fno-exceptions reduces by 20% in my case. But you have to remove/#ifdef all the try/catch statements.

-noixemul is just MANDATORY. Without it, it just locks up randomly on system calls.

-fno-rtti doesn't save a lot of space, and you probably cannot use dynamic_cast with that.

I'll try the other options (not -Dlinux )

Last edited by jotd; 15 January 2020 at 16:59.
jotd is offline  
Old 15 January 2020, 09:34   #10
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
Quote:
Originally Posted by MartinW View Post
Why -Dlinux ?
I had nearly forgotten it, but a look in the code revealed: It defines a macro which is needed because sometimes I also build the project with StormC4.

The macro is used to #include <new> when build in in Linux/gcc6.5, whereas <new.h> must be included for StormC4.

Last edited by thyslo; 15 January 2020 at 09:58.
thyslo is offline  
Old 15 January 2020, 14:33   #11
MartinW
Registered User
 
Join Date: Mar 2017
Location: Minehead / UK
Posts: 608
OK, so that one is pretty specific to your project, or use case. Understood
MartinW is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for WB set up with some basics TenLeftFingers request.Apps 9 14 July 2015 03:26
Help with: Bio Challenge : The Basics apachacha support.Games 19 11 November 2012 01:59
Amiga basics? stefcep2 support.Apps 7 08 September 2010 04:02
some basics diamond request.UAE Wishlist 1 26 March 2005 03:03
Amiga DOS Basics Fred the Fop Amiga websites reviews 3 21 August 2002 07:02

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:17.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08340 seconds with 15 queries