View previous topic :: View next topic |
Author |
Message |
cnhnln n00b
Joined: 20 Nov 2004 Posts: 11
|
Posted: Thu Aug 31, 2006 9:44 am Post subject: who can talk about CXXFLAGS? |
|
|
e.g. "-fvisibility-inlines-hidden" Parameters
thanks |
|
Back to top |
|
|
vipernicus Veteran
Joined: 17 Jan 2005 Posts: 1462 Location: Your College IT Dept.
|
|
Back to top |
|
|
tsunam Retired Dev
Joined: 23 Feb 2004 Posts: 343
|
Posted: Thu Aug 31, 2006 5:51 pm Post subject: |
|
|
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 |
|
|
Gergan Penkov Veteran
Joined: 17 Jul 2004 Posts: 1464 Location: das kleinste Kuhdorf Deutschlands :)
|
Posted: Thu Aug 31, 2006 6:05 pm Post subject: |
|
|
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 |
|
|
ciaranm Retired Dev
Joined: 19 Jul 2003 Posts: 1719 Location: In Hiding
|
Posted: Thu Aug 31, 2006 6:33 pm Post subject: |
|
|
Messing with visibility options can cause standard compliant code to break. Don't do it. |
|
Back to top |
|
|
cnhnln n00b
Joined: 20 Nov 2004 Posts: 11
|
Posted: Thu Aug 31, 2006 7:01 pm Post subject: |
|
|
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 |
|
|
ciaranm Retired Dev
Joined: 19 Jul 2003 Posts: 1719 Location: In Hiding
|
Posted: Thu Aug 31, 2006 7:07 pm Post subject: |
|
|
cnhnln wrote: | This reduces code size and also improves performance of the runtime |
And causes compile failures on legal code. |
|
Back to top |
|
|
Gergan Penkov Veteran
Joined: 17 Jul 2004 Posts: 1464 Location: das kleinste Kuhdorf Deutschlands :)
|
Posted: Thu Aug 31, 2006 7:12 pm Post subject: |
|
|
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 |
|
|
vipernicus Veteran
Joined: 17 Jan 2005 Posts: 1462 Location: Your College IT Dept.
|
Posted: Thu Aug 31, 2006 8:15 pm Post subject: |
|
|
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 |
|
|
ciaranm Retired Dev
Joined: 19 Jul 2003 Posts: 1719 Location: In Hiding
|
Posted: Thu Aug 31, 2006 8:23 pm Post subject: |
|
|
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 |
|
|
vipernicus Veteran
Joined: 17 Jan 2005 Posts: 1462 Location: Your College IT Dept.
|
Posted: Thu Aug 31, 2006 8:58 pm Post subject: |
|
|
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?
_________________ Viper-Sources Maintainer || nesl247 Projects || vipernicus.org blog |
|
Back to top |
|
|
ciaranm Retired Dev
Joined: 19 Jul 2003 Posts: 1719 Location: In Hiding
|
Posted: Thu Aug 31, 2006 9:02 pm Post subject: |
|
|
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 |
|
|
vipernicus Veteran
Joined: 17 Jan 2005 Posts: 1462 Location: Your College IT Dept.
|
Posted: Thu Aug 31, 2006 9:11 pm Post subject: |
|
|
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 |
|
|
ciaranm Retired Dev
Joined: 19 Jul 2003 Posts: 1719 Location: In Hiding
|
Posted: Thu Aug 31, 2006 9:21 pm Post subject: |
|
|
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 |
|
|
Gergan Penkov Veteran
Joined: 17 Jul 2004 Posts: 1464 Location: das kleinste Kuhdorf Deutschlands :)
|
Posted: Thu Aug 31, 2006 9:50 pm Post subject: |
|
|
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 |
|
|
Archangel1 Veteran
Joined: 21 Apr 2004 Posts: 1212 Location: Work
|
Posted: Thu Aug 31, 2006 9:57 pm Post subject: |
|
|
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 |
|
|
ciaranm Retired Dev
Joined: 19 Jul 2003 Posts: 1719 Location: In Hiding
|
Posted: Thu Aug 31, 2006 10:32 pm Post subject: |
|
|
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 |
|
|
Gergan Penkov Veteran
Joined: 17 Jul 2004 Posts: 1464 Location: das kleinste Kuhdorf Deutschlands :)
|
Posted: Thu Aug 31, 2006 11:14 pm Post subject: |
|
|
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 |
|
|
kamilian n00b
Joined: 23 Jun 2003 Posts: 59 Location: Sydney, Australia
|
Posted: Fri Sep 01, 2006 12:05 pm Post subject: |
|
|
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 |
|
|
ciaranm Retired Dev
Joined: 19 Jul 2003 Posts: 1719 Location: In Hiding
|
Posted: Fri Sep 01, 2006 2:34 pm Post subject: |
|
|
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 |
|
|
tsunam Retired Dev
Joined: 23 Feb 2004 Posts: 343
|
Posted: Fri Sep 01, 2006 3:57 pm Post subject: |
|
|
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 |
|
|
runningwithscissors Guru
Joined: 21 Apr 2006 Posts: 454 Location: the third world
|
Posted: Fri Sep 01, 2006 4:04 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
tsunam Retired Dev
Joined: 23 Feb 2004 Posts: 343
|
Posted: Fri Sep 01, 2006 4:17 pm Post subject: |
|
|
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 |
|
|
runningwithscissors Guru
Joined: 21 Apr 2006 Posts: 454 Location: the third world
|
Posted: Fri Sep 01, 2006 4:28 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
vipernicus Veteran
Joined: 17 Jan 2005 Posts: 1462 Location: Your College IT Dept.
|
|
Back to top |
|
|
|