public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Strange behavior of my program linked with -static option
@ 2004-12-28 15:12 Andrey Fomichev
  2004-12-29  8:36 ` Andrey Fomichev
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Fomichev @ 2004-12-28 15:12 UTC (permalink / raw)
  To: gcc-help

Hello!

I have a pretty big program written in C++. It is complicated enough and
it uses C++ exceptions, pthreads and a set of 3-d party libraries. As far
as I compile it with dynamic linking with gcc libraries, I have no problems.
It works fine. Problem arises when I add '-static' option to the linker.
The program is able to run, but it works in a very strange way. Signal
handlers do not handle signals. When I run it in background mode (the
program
then forks and the parent dies, but the child continues its execution)
I accidentally get 9 instances instead of 1.

I have to say that I'm not very familiar with gcc and its huge set of
compiler
options, so it's possible that I missed something... But I suspect that it
may
be a problem with gcc itself (when I use dynamic linking everything works
fine!).

I have looked around and found several links with similar problems (so I'm
not alone)
http://gcc.gnu.org/ml/gcc-help/2002-01/msg00199.html
http://www.monkey.org/openbsd/archive/bugs/0103/msg00129.html

But examples at these links work fine for me because (I suspect) I use other
version of gcc (3.2.2 comparing with 2.9x.x and 3.0.x). And note that nobody
proposed a solution to the problem discussed...

My environment:
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Red Hat Linux 9, kernel 2.4.20-8

Flags:
CFLAGS   = -DC_NO_PIC_NO_DLL -O3 -Wall -Wno-deprecated
$(INCLUDE_DIRECTIVES_GCC) -DEL_DEBUG=$(EL_DEBUG) -fomit-frame-pointer -fno-s
trict-aliasing -Wno-unused -Wno-uninitialized -DHAVE_ALLOCA_H -DC_STACK_GROW
S_DOWNWARD=1 -DC_USE_C_DEFAULTS -DC_EMBEDDED
CPPFLAGS = -O3 -Wall -Wno-deprecated  $(INCLUDE_DIRECTIVES_GCC)
LFLAGS


= -O3 -L$(PP)/libs/pg -L$(PP)/libs/expat -L$(PP)/libs/chicken -L$(PP)/libs/b
oost -static -lpccts -lpthread -lnsl -lcurses -lexpat -lchicken -lstuffed-ch
icken -lsrfi-chicken -lboost_regex-gcc-1_31


I hope somebody can guide me to the solution of the problem. Is there any
magic
with gcc options that might help?

P.S. Now I'm trying to switch to the latest gcc release. I'll let you know
about results.

Thanks in advance,
Andrey


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: Strange behavior of my program linked with -static option
  2004-12-28 15:12 Strange behavior of my program linked with -static option Andrey Fomichev
@ 2004-12-29  8:36 ` Andrey Fomichev
  0 siblings, 0 replies; 2+ messages in thread
From: Andrey Fomichev @ 2004-12-29  8:36 UTC (permalink / raw)
  To: Andrey Fomichev, gcc-help


Exactly the same problem exists with GCC 3.4.3!
I have no idea what to do...



> Hello!
>
> I have a pretty big program written in C++. It is complicated enough and
> it uses C++ exceptions, pthreads and a set of 3-d party libraries. As far
> as I compile it with dynamic linking with gcc libraries, I have
> no problems.
> It works fine. Problem arises when I add '-static' option to the linker.
> The program is able to run, but it works in a very strange way. Signal
> handlers do not handle signals. When I run it in background mode (the
> program
> then forks and the parent dies, but the child continues its execution)
> I accidentally get 9 instances instead of 1.
>
> I have to say that I'm not very familiar with gcc and its huge set of
> compiler
> options, so it's possible that I missed something... But I suspect that it
> may
> be a problem with gcc itself (when I use dynamic linking everything works
> fine!).
>
> I have looked around and found several links with similar problems (so I'm
> not alone)
> http://gcc.gnu.org/ml/gcc-help/2002-01/msg00199.html
> http://www.monkey.org/openbsd/archive/bugs/0103/msg00129.html
>
> But examples at these links work fine for me because (I suspect)
> I use other
> version of gcc (3.2.2 comparing with 2.9x.x and 3.0.x). And note
> that nobody
> proposed a solution to the problem discussed...
>
> My environment:
> gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
> Red Hat Linux 9, kernel 2.4.20-8
>
> Flags:
> CFLAGS   = -DC_NO_PIC_NO_DLL -O3 -Wall -Wno-deprecated
> $(INCLUDE_DIRECTIVES_GCC) -DEL_DEBUG=$(EL_DEBUG)
> -fomit-frame-pointer -fno-s
> trict-aliasing -Wno-unused -Wno-uninitialized -DHAVE_ALLOCA_H
> -DC_STACK_GROW
> S_DOWNWARD=1 -DC_USE_C_DEFAULTS -DC_EMBEDDED
> CPPFLAGS = -O3 -Wall -Wno-deprecated  $(INCLUDE_DIRECTIVES_GCC)
> LFLAGS
>
>
> = -O3 -L$(PP)/libs/pg -L$(PP)/libs/expat -L$(PP)/libs/chicken
> -L$(PP)/libs/b
> oost -static -lpccts -lpthread -lnsl -lcurses -lexpat -lchicken
> -lstuffed-ch
> icken -lsrfi-chicken -lboost_regex-gcc-1_31
>
>
> I hope somebody can guide me to the solution of the problem. Is there any
> magic
> with gcc options that might help?
>
> P.S. Now I'm trying to switch to the latest gcc release. I'll let you know
> about results.
>
> Thanks in advance,
> Andrey
>
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-29  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-28 15:12 Strange behavior of my program linked with -static option Andrey Fomichev
2004-12-29  8:36 ` Andrey Fomichev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).