Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
who can talk about CXXFLAGS?
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
cnhnln
n00b
n00b


Joined: 20 Nov 2004
Posts: 11

PostPosted: Thu Aug 31, 2006 9:44 am    Post subject: who can talk about CXXFLAGS? Reply with quote

e.g. "-fvisibility-inlines-hidden" Parameters

thanks
Back to top
View user's profile Send private message
vipernicus
Veteran
Veteran


Joined: 17 Jan 2005
Posts: 1462
Location: Your College IT Dept.

PostPosted: Thu Aug 31, 2006 4:32 pm    Post subject: Re: who can talk about CXXFLAGS? Reply with quote

cnhnln wrote:
e.g. "-fvisibility-inlines-hidden" Parameters

thanks


Also "-fno-enforce-eh-specs" (i use it)

Thanks
_________________
Viper-Sources Maintainer || nesl247 Projects || vipernicus.org blog
Back to top
View user's profile Send private message
tsunam
Retired Dev
Retired Dev


Joined: 23 Feb 2004
Posts: 343

PostPosted: Thu Aug 31, 2006 5:51 pm    Post subject: Reply with quote

Now here's the question, do either of you actually really know what those two do? Seriously, reading what the man pages say about those functions and actually knowing what they will do are entirely two different things. I'd like to hear the answer.
_________________
I'm not afraid of happy endings, just afraid my life wont work that way.
Back to top
View user's profile Send private message
Gergan Penkov
Veteran
Veteran


Joined: 17 Jul 2004
Posts: 1464
Location: das kleinste Kuhdorf Deutschlands :)

PostPosted: Thu Aug 31, 2006 6:05 pm    Post subject: Reply with quote

tsunam wrote:
Now here's the question, do either of you actually really know what those two do? Seriously, reading what the man pages say about those functions and actually knowing what they will do are entirely two different things. I'd like to hear the answer.

I wonder what ldd -r on all the libs and binaries will show on system recompiled with -fvisibility-inlines-hidden, this aside all the packages which could use this flag safely are already using it.
_________________
"I knew when an angel whispered into my ear,
You gotta get him away, yeah
Hey little bitch!
Be glad you finally walked away or you may have not lived another day."
Godsmack
Back to top
View user's profile Send private message
ciaranm
Retired Dev
Retired Dev


Joined: 19 Jul 2003
Posts: 1719
Location: In Hiding

PostPosted: Thu Aug 31, 2006 6:33 pm    Post subject: Reply with quote

Messing with visibility options can cause standard compliant code to break. Don't do it.
Back to top
View user's profile Send private message
cnhnln
n00b
n00b


Joined: 20 Nov 2004
Posts: 11

PostPosted: Thu Aug 31, 2006 7:01 pm    Post subject: Reply with quote

This reduces code size and also improves performance of the runtime
Mandrake's kde packages are built with "-fvisibility=hidden" and "-fvisibility-inlines-hidden"
Back to top
View user's profile Send private message
ciaranm
Retired Dev
Retired Dev


Joined: 19 Jul 2003
Posts: 1719
Location: In Hiding

PostPosted: Thu Aug 31, 2006 7:07 pm    Post subject: Reply with quote

cnhnln wrote:
This reduces code size and also improves performance of the runtime

And causes compile failures on legal code.
Back to top
View user's profile Send private message
Gergan Penkov
Veteran
Veteran


Joined: 17 Jul 2004
Posts: 1464
Location: das kleinste Kuhdorf Deutschlands :)

PostPosted: Thu Aug 31, 2006 7:12 pm    Post subject: Reply with quote

kdehiddenvisibility - use flags
_________________
"I knew when an angel whispered into my ear,
You gotta get him away, yeah
Hey little bitch!
Be glad you finally walked away or you may have not lived another day."
Godsmack
Back to top
View user's profile Send private message
vipernicus
Veteran
Veteran


Joined: 17 Jan 2005
Posts: 1462
Location: Your College IT Dept.

PostPosted: Thu Aug 31, 2006 8:15 pm    Post subject: Reply with quote

I use "-fno-enforce-eh-specs" because it reduces binary size. Judging from the manpage, it looks to if it tells the C++ compiler to not include debugging capability. I have been using this as a CXXFLAG for over 6 months without issues, but am open to criticism.


GCC Manpage:
Code:
-fno-enforce-eh-specs
Don't generate code to check for violation of exception specifications at runtime. This option violates the C++ standard, but may be useful for reducing code size in production builds, much like defining `NDEBUG'. This does not give user code permission to throw exceptions in violation of the exception specifications; the compiler will still optimize based on the specifications, so throwing an unexpected exception will result in undefined behavior.


My question:
1. In what situations can this flag be harmful?

Sidenote:
When needed, I will recompile what is needed for debugging. For instance not too long ago I ran into a GAIM bug, and contacted the developers. I recompiled GAIM and it's dependencies with debugging enabled, provided the results and helped fix a bug in CVS code.
_________________
Viper-Sources Maintainer || nesl247 Projects || vipernicus.org blog
Back to top
View user's profile Send private message
ciaranm
Retired Dev
Retired Dev


Joined: 19 Jul 2003
Posts: 1719
Location: In Hiding

PostPosted: Thu Aug 31, 2006 8:23 pm    Post subject: Reply with quote

vipernicus wrote:
My question:
1. In what situations can this flag be harmful?

If a program relies upon unexpected exceptions being caught, and an unexpected exception is thrown, the program will behave in an undefined way. This could result in the program carrying on running when it should abort, aborting when it should carry on running or deleting all your files and mailing your girlfriend pictures of you having sex with her mother.
Back to top
View user's profile Send private message
vipernicus
Veteran
Veteran


Joined: 17 Jan 2005
Posts: 1462
Location: Your College IT Dept.

PostPosted: Thu Aug 31, 2006 8:58 pm    Post subject: Reply with quote

ciaranm wrote:
If a program relies upon unexpected exceptions being caught

Do you know of an example offhand of a program that 'relies upon unexpected exceptions being caught'?

ciaranm wrote:
or deleting all your files and mailing your girlfriend pictures of you having sex with her mother.


That explains everything! Can I quote you in court?

:lol:
_________________
Viper-Sources Maintainer || nesl247 Projects || vipernicus.org blog
Back to top
View user's profile Send private message
ciaranm
Retired Dev
Retired Dev


Joined: 19 Jul 2003
Posts: 1719
Location: In Hiding

PostPosted: Thu Aug 31, 2006 9:02 pm    Post subject: Reply with quote

vipernicus wrote:
ciaranm wrote:
If a program relies upon unexpected exceptions being caught

Do you know of an example offhand of a program that 'relies upon unexpected exceptions being caught'?

I'd imagine any program that uses throw() specifiers... Which means anything that uses the standard library for memory allocation... Which means everything...
Back to top
View user's profile Send private message
vipernicus
Veteran
Veteran


Joined: 17 Jan 2005
Posts: 1462
Location: Your College IT Dept.

PostPosted: Thu Aug 31, 2006 9:11 pm    Post subject: Reply with quote

ciaranm wrote:
vipernicus wrote:
ciaranm wrote:
If a program relies upon unexpected exceptions being caught

Do you know of an example offhand of a program that 'relies upon unexpected exceptions being caught'?

I'd imagine any program that uses throw() specifiers... Which means anything that uses the standard library for memory allocation... Which means everything...


So something like a memory leak could occur?
_________________
Viper-Sources Maintainer || nesl247 Projects || vipernicus.org blog
Back to top
View user's profile Send private message
ciaranm
Retired Dev
Retired Dev


Joined: 19 Jul 2003
Posts: 1719
Location: In Hiding

PostPosted: Thu Aug 31, 2006 9:21 pm    Post subject: Reply with quote

vipernicus wrote:
So something like a memory leak could occur?

More that if a memory allocation fails, the program won't necessarily handle it as expected.
Back to top
View user's profile Send private message
Gergan Penkov
Veteran
Veteran


Joined: 17 Jul 2004
Posts: 1464
Location: das kleinste Kuhdorf Deutschlands :)

PostPosted: Thu Aug 31, 2006 9:50 pm    Post subject: Reply with quote

Quote:
This does not give user code permission to throw exceptions in violation of the exception specifications; the compiler will still optimize based on the specifications, so throwing an unexpected exception will result in undefined behavior.

Does this vague explanation mean that if you have catch's, which do not look for every possible "unexpected" exceptions, the runtime could effectively swallow them?
_________________
"I knew when an angel whispered into my ear,
You gotta get him away, yeah
Hey little bitch!
Be glad you finally walked away or you may have not lived another day."
Godsmack
Back to top
View user's profile Send private message
Archangel1
Veteran
Veteran


Joined: 21 Apr 2004
Posts: 1212
Location: Work

PostPosted: Thu Aug 31, 2006 9:57 pm    Post subject: Reply with quote

cnhnln wrote:
This reduces code size and also improves performance of the runtime
Mandrake's kde packages are built with "-fvisibility=hidden" and "-fvisibility-inlines-hidden"

Yeah, I read that and tried it once upon a time. It blatantly broke stuff.
As far as I'm concerned, Mandrake were either using a different (possibly patched?) compiler to me, or they'd done something to KDE, because it just wasn't the go on my machine.
_________________
What are you, stupid?
Back to top
View user's profile Send private message
ciaranm
Retired Dev
Retired Dev


Joined: 19 Jul 2003
Posts: 1719
Location: In Hiding

PostPosted: Thu Aug 31, 2006 10:32 pm    Post subject: Reply with quote

Gergan Penkov wrote:
Quote:
This does not give user code permission to throw exceptions in violation of the exception specifications; the compiler will still optimize based on the specifications, so throwing an unexpected exception will result in undefined behavior.

Does this vague explanation mean that if you have catch's, which do not look for every possible "unexpected" exceptions, the runtime could effectively swallow them?

Ok, a demonstration.

demo.cc
Code:

#include <cstdlib>
#include <iostream>
#include <exception>
#include "f.hh"

namespace
{
    void exit_nicely()
    {
        std::cout << "Have a cookie" << std::endl;
        exit(EXIT_SUCCESS);
    }
}

int main(int, char *[])
{
    std::set_terminate(&exit_nicely);

    try
    {
        f::f();
    }
    catch (const f::S &)
    {
    }

    std::cout << "Deleting all your files!!!" << std::endl;
    return EXIT_FAILURE;
}


f.hh
Code:

#ifndef TMP_GUARD_F_HH
#define TMP_GUARD_F_HH 1

namespace f
{
    struct S
    {
    };

    struct T :
        S
    {
    };

    void f() throw (T);
}

#endif


f.cc
Code:

#include "f.hh"

void f::f() throw (f::T)
{
    throw f::S();
}


Makefile
Code:

all : demo

clean :
        rm *~ *.o demo || true

demo : f.o demo.o
        g++ $(CXXFLAGS) -o $@ $?

%.o : %.cc
        g++ -c $(CXXFLAGS) -o $@ $?


Then try running ./demo.
Back to top
View user's profile Send private message
Gergan Penkov
Veteran
Veteran


Joined: 17 Jul 2004
Posts: 1464
Location: das kleinste Kuhdorf Deutschlands :)

PostPosted: Thu Aug 31, 2006 11:14 pm    Post subject: Reply with quote

thanks for the demo, have refreshed a little bit my c++ trying to understand it :)
_________________
"I knew when an angel whispered into my ear,
You gotta get him away, yeah
Hey little bitch!
Be glad you finally walked away or you may have not lived another day."
Godsmack
Back to top
View user's profile Send private message
kamilian
n00b
n00b


Joined: 23 Jun 2003
Posts: 59
Location: Sydney, Australia

PostPosted: Fri Sep 01, 2006 12:05 pm    Post subject: Reply with quote

tsunam wrote:
Now here's the question, do either of you actually really know what those two do? Seriously, reading what the man pages say about those functions and actually knowing what they will do are entirely two different things. I'd like to hear the answer.

Would you mind explaining what they actually do?

These should be my variables (from memory, I'm not at that machine at the moment):
$CFLAGS:
-pipe -Os -march=pentium4 -fomit-frame-pointer

$CXXFLAGS:
${CFLAGS} -fvisibility-inlines-hidden


I nearly added -fvisibility=hidden to CXXFLAGS but chose not to after reading the man page. The man page gave the impression that the -fvisibility-inlines-hidden flag could only be good, although now it seems that it may be a bad idea! If so then I'll remove it and emerge -e system again as I'm just installing 2006.1.

Also, are there any problems in using the kdehiddenvisibility USE Flag?
_________________
May contain traces of nuts.
Back to top
View user's profile Send private message
ciaranm
Retired Dev
Retired Dev


Joined: 19 Jul 2003
Posts: 1719
Location: In Hiding

PostPosted: Fri Sep 01, 2006 2:34 pm    Post subject: Reply with quote

kamilian wrote:
I nearly added -fvisibility=hidden to CXXFLAGS but chose not to after reading the man page. The man page gave the impression that the -fvisibility-inlines-hidden flag could only be good, although now it seems that it may be a bad idea!

Well, it can prevent legit code from compiling...
Back to top
View user's profile Send private message
tsunam
Retired Dev
Retired Dev


Joined: 23 Feb 2004
Posts: 343

PostPosted: Fri Sep 01, 2006 3:57 pm    Post subject: Reply with quote

kamilian wrote:
tsunam wrote:
Now here's the question, do either of you actually really know what those two do? Seriously, reading what the man pages say about those functions and actually knowing what they will do are entirely two different things. I'd like to hear the answer.

Would you mind explaining what they actually do?


The point that I always ask this is to see if someone has done the research (note more then the manpage) to see if they know what they are doing with the flags. 99% of the time people come back and say I dunno or someone else uses it without problems. As far as what they actually do, ciaranm has done a fine example of showing how those flags can cause broken code with a fairly simple coding sample, as well explaining them as well.

As far as fomit-frame-pointer. Its actually a decent thing to have even if its a redunant use because its enabled at levels -O, -O2, -O3, -Os. What it does is free up a register (which x86 has a limit that's quite easy to hit). A frame pointer is as you can guess a pointer however what it points to is the current stack, which keeps track of all the subroutines of an application. So freeing up one register means that you can use it somewhere else, and thus why its enabled in those levels as its quite useful.

This lesson brought to you by the letter G, gee isn't gentoo ggggreat! ;)
_________________
I'm not afraid of happy endings, just afraid my life wont work that way.
Back to top
View user's profile Send private message
runningwithscissors
Guru
Guru


Joined: 21 Apr 2006
Posts: 454
Location: the third world

PostPosted: Fri Sep 01, 2006 4:04 pm    Post subject: Reply with quote

tsunam wrote:

The point that I always ask this is to see if someone has done the research (note more then the manpage) to see if they know what they are doing with the flags.


The manpage tells you _exactly_ what it does. People just pay more attention to the "smaller binary" part.
_________________
At some stage, the Hindus locked on to the nation destroying concepts like ahimsa (non-violence), shanti (peace), satya (truth) — the ‘ass’ syndrome.
Back to top
View user's profile Send private message
tsunam
Retired Dev
Retired Dev


Joined: 23 Feb 2004
Posts: 343

PostPosted: Fri Sep 01, 2006 4:17 pm    Post subject: Reply with quote

runningwithscissors wrote:
tsunam wrote:

The point that I always ask this is to see if someone has done the research (note more then the manpage) to see if they know what they are doing with the flags.


The manpage tells you _exactly_ what it does. People just pay more attention to the "smaller binary" part.


Quite honestly no it doesn't it tells you what it does, but that's a concept...you can grasp the concept without really understanding what it does. If you enable something, you should know what it does...so that if it breaks you know possibly why. It'd be even better if you could fix it so that it wouldn't break..however sadly that's part of why we are the ricer distro because people don't do it..they go OMG it broke with my l33t flags FIX IT!
_________________
I'm not afraid of happy endings, just afraid my life wont work that way.
Back to top
View user's profile Send private message
runningwithscissors
Guru
Guru


Joined: 21 Apr 2006
Posts: 454
Location: the third world

PostPosted: Fri Sep 01, 2006 4:28 pm    Post subject: Reply with quote

tsunam wrote:

Quite honestly no it doesn't it tells you what it does, but that's a concept...you can grasp the concept without really understanding what it does. If you enable something, you should know what it does...so that if it breaks you know possibly why. It'd be even better if you could fix it so that it wouldn't break..however sadly that's part of why we are the ricer distro because people don't do it..they go OMG it broke with my l33t flags FIX IT!


I thought what ciaranm demonstrated was made clear by the manpage.

manpage wrote:

-fno-enforce-eh-specs
Don't generate code to check for violation of exception specifications at runtime. This option violates the C++ standard, but may be useful for reducing code size in production builds, much like defining `NDEBUG'. This does not give user code permission to throw exceptions in violation of the exception specifications; the compiler will still optimize based on the specifications, so throwing an unexpected exception will result in undefined behavior.


I don't use mad CXXFLAGS. Also, I usually take little advantage of the generous support Gentoo and its users offer, so you won't find me complaining about a hosed system. ;)
_________________
At some stage, the Hindus locked on to the nation destroying concepts like ahimsa (non-violence), shanti (peace), satya (truth) — the ‘ass’ syndrome.
Back to top
View user's profile Send private message
vipernicus
Veteran
Veteran


Joined: 17 Jan 2005
Posts: 1462
Location: Your College IT Dept.

PostPosted: Fri Sep 01, 2006 5:31 pm    Post subject: Reply with quote

I wonder why I haven't encountered any issues with -fno-enforce-eh-specs in the last 6 months that I have used it?
_________________
Viper-Sources Maintainer || nesl247 Projects || vipernicus.org blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum